1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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> Istream& operator>>
57 HashPtrTable<T, Key, Hash>&
60 template<class T, class Key, class Hash> Ostream& operator<<
63 const HashPtrTable<T, Key, Hash>&
67 /*---------------------------------------------------------------------------*\
68 Class HashPtrTable Declaration
69 \*---------------------------------------------------------------------------*/
71 template<class T, class Key=word, class Hash=string::hash>
74 public HashTable<T*, Key, Hash>
76 // Private member functions
78 //- Read from Istream using given Istream constructor class
80 void read(Istream&, const INew& inewt);
85 typedef typename HashTable<T*, Key, Hash>::iterator iterator;
86 typedef typename HashTable<T*, Key, Hash>::const_iterator const_iterator;
91 //- Construct given initial table size
92 HashPtrTable(label size = 100);
94 //- Construct from Istream using given Istream constructor class
96 HashPtrTable(Istream&, const INew&);
98 //- Construct from Istream using default Istream constructor class
99 HashPtrTable(Istream&);
101 //- Construct as copy
102 HashPtrTable(const HashPtrTable<T, Key, Hash>&);
114 //- Remove and return the pointer specified by given iterator
115 T* remove(iterator&);
117 //- Erase an hashedEntry specified by given iterator
118 bool erase(iterator&);
120 //- Clear all entries from table
126 void operator=(const HashPtrTable<T, Key, Hash>&);
129 // IOstream Operators
131 friend Istream& operator>>
137 HashPtrTable<T, Key, Hash>&
140 friend Ostream& operator<<
146 const HashPtrTable<T, Key, Hash>&
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 } // End namespace Foam
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 # include "HashPtrTable.C"
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 // ************************************************************************* //