1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM 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 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 A HashTable specialization for hashing pointers.
35 \*---------------------------------------------------------------------------*/
37 #ifndef HashPtrTable_H
38 #define HashPtrTable_H
40 #include "HashTable.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 // Forward declaration of friend functions and operators
52 template<class T, class Key, class Hash> class HashPtrTable;
54 template<class T, class Key, class Hash>
55 Istream& operator>>(Istream&, HashPtrTable<T, Key, Hash>&);
57 template<class T, class Key, class Hash>
58 Ostream& operator<<(Ostream&, const HashPtrTable<T, Key, Hash>&);
61 /*---------------------------------------------------------------------------*\
62 Class HashPtrTable Declaration
63 \*---------------------------------------------------------------------------*/
65 template<class T, class Key=word, class Hash=string::hash>
68 public HashTable<T*, Key, Hash>
70 // Private member functions
72 //- Read from Istream using given Istream constructor class
74 void read(Istream&, const INew& inewt);
79 typedef typename HashTable<T*, Key, Hash>::iterator iterator;
80 typedef typename HashTable<T*, Key, Hash>::const_iterator const_iterator;
85 //- Construct given initial table size
86 HashPtrTable(const label size = 128);
88 //- Construct from Istream using given Istream constructor class
90 HashPtrTable(Istream&, const INew&);
92 //- Construct from Istream using default Istream constructor class
93 HashPtrTable(Istream&);
96 HashPtrTable(const HashPtrTable<T, Key, Hash>&);
108 //- Remove and return the pointer specified by given iterator
109 T* remove(iterator&);
111 //- Erase an hashedEntry specified by given iterator
112 bool erase(iterator&);
114 //- Clear all entries from table
120 void operator=(const HashPtrTable<T, Key, Hash>&);
123 // IOstream Operators
125 friend Istream& operator>> <T, Key, Hash>
128 HashPtrTable<T, Key, Hash>&
131 friend Ostream& operator<< <T, Key, Hash>
134 const HashPtrTable<T, Key, Hash>&
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 } // End namespace Foam
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 # include "HashPtrTable.C"
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 // ************************************************************************* //