Forward compatibility: flex
[foam-extend-3.2.git] / src / foam / containers / HashTables / HashPtrTable / HashPtrTable.H
blob9f017a645c455911ab03349128da62c6f2581d51
1 /*---------------------------------------------------------------------------*\
2   =========                 |
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 -------------------------------------------------------------------------------
8 License
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/>.
24 Class
25     Foam::HashPtrTable
27 Description
28     A HashTable specialization for hashing pointers.
30 SourceFiles
31     HashPtrTable.C
32     HashPtrTableIO.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef HashPtrTable_H
37 #define HashPtrTable_H
39 #include "HashTable.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 namespace Foam
46 class Istream;
47 class Ostream;
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>
65 class HashPtrTable
67     public HashTable<T*, Key, Hash>
69     // Private Member Functions
71         //- Read from Istream using given Istream constructor class
72         template<class INew>
73         void read(Istream&, const INew& inewt);
75         //- Read from dictionary using given dictionary constructor class
76         template<class INew>
77         void read(const dictionary& dict, const INew& inewt);
81 public:
83     typedef typename HashTable<T*, Key, Hash>::iterator iterator;
84     typedef typename HashTable<T*, Key, Hash>::const_iterator const_iterator;
87     // Constructors
89         //- Construct given initial table size
90         HashPtrTable(const label size = 128);
92         //- Construct from Istream using given Istream constructor class
93         template<class INew>
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
100         //  class
101         HashPtrTable(const dictionary&);
103         //- Construct as copy
104         HashPtrTable(const HashPtrTable<T, Key, Hash>&);
107     //- Destructor
108     ~HashPtrTable();
111     // Member Functions
113         // Edit
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
122             void clear();
124             //- Write
125             void write(Ostream& os) const;
128     // Member Operators
130         void operator=(const HashPtrTable<T, Key, Hash>&);
133     // IOstream Operators
135         friend Istream& operator>> <T, Key, Hash>
136         (
137             Istream&,
138             HashPtrTable<T, Key, Hash>&
139         );
141         friend Ostream& operator<< <T, Key, Hash>
142         (
143             Ostream&,
144             const HashPtrTable<T, Key, Hash>&
145         );
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 } // End namespace Foam
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 #ifdef NoRepository
156 #   include "HashPtrTable.C"
157 #endif
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 #endif
163 // ************************************************************************* //