1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 A HashTable specialization for hashing pointers.
34 \*---------------------------------------------------------------------------*/
36 #ifndef HashPtrTable_H
37 #define HashPtrTable_H
39 #include "HashTable.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 // Forward declaration of friend functions and operators
51 template<class T, class Key, class Hash> class HashPtrTable;
53 template<class T, class Key, class Hash>
54 Istream& operator>>(Istream&, HashPtrTable<T, Key, Hash>&);
56 template<class T, class Key, class Hash>
57 Ostream& operator<<(Ostream&, const HashPtrTable<T, Key, Hash>&);
60 /*---------------------------------------------------------------------------*\
61 Class HashPtrTable Declaration
62 \*---------------------------------------------------------------------------*/
64 template<class T, class Key=word, class Hash=string::hash>
67 public HashTable<T*, Key, Hash>
69 // Private Member Functions
71 //- Read from Istream using given Istream constructor class
73 void read(Istream&, const INew& inewt);
75 //- Read from dictionary using given dictionary constructor class
77 void read(const dictionary& dict, const INew& inewt);
83 typedef typename HashTable<T*, Key, Hash>::iterator iterator;
84 typedef typename HashTable<T*, Key, Hash>::const_iterator const_iterator;
89 //- Construct given initial table size
90 HashPtrTable(const label size = 128);
92 //- Construct from Istream using given Istream constructor class
94 HashPtrTable(Istream&, const INew&);
96 //- Construct from Istream using default Istream constructor class
97 HashPtrTable(Istream&);
99 //- Construct from dictionary using default dictionary constructor
101 HashPtrTable(const dictionary&);
103 //- Construct as copy
104 HashPtrTable(const HashPtrTable<T, Key, Hash>&);
115 //- Remove and return the pointer specified by given iterator
116 T* remove(iterator&);
118 //- Erase an hashedEntry specified by given iterator
119 bool erase(iterator&);
121 //- Clear all entries from table
125 void write(Ostream& os) const;
130 void operator=(const HashPtrTable<T, Key, Hash>&);
133 // IOstream Operators
135 friend Istream& operator>> <T, Key, Hash>
138 HashPtrTable<T, Key, Hash>&
141 friend Ostream& operator<< <T, Key, Hash>
144 const HashPtrTable<T, Key, Hash>&
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 } // End namespace Foam
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 # include "HashPtrTable.C"
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 // ************************************************************************* //