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
25 \*---------------------------------------------------------------------------*/
29 #include "HashPtrTable.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 // Construct given initial table size
39 template<class T, class Key, class Hash>
40 HashPtrTable<T, Key, Hash>::HashPtrTable(label size)
42 HashTable<T*, Key, Hash>(size)
47 template<class T, class Key, class Hash>
48 HashPtrTable<T, Key, Hash>::HashPtrTable(const HashPtrTable<T, Key, Hash>& ht)
50 HashTable<T*, Key, Hash>()
52 for (const_iterator iter = ht.begin(); iter != ht.end(); ++iter)
54 insert(iter.key(), new T(**iter));
59 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
61 template<class T, class Key, class Hash>
62 HashPtrTable<T, Key, Hash>::~HashPtrTable()
68 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
70 template<class T, class Key, class Hash>
71 T* HashPtrTable<T, Key, Hash>::remove(iterator& it)
74 HashTable<T*, Key, Hash>::erase(it);
79 template<class T, class Key, class Hash>
80 bool HashPtrTable<T, Key, Hash>::erase(iterator& it)
84 if (HashTable<T*, Key, Hash>::erase(it))
100 template<class T, class Key, class Hash>
101 void HashPtrTable<T, Key, Hash>::clear()
105 iterator iter = this->begin();
113 HashTable<T*, Key, Hash>::clear();
117 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
119 template<class T, class Key, class Hash>
120 void HashPtrTable<T, Key, Hash>::operator=(const HashPtrTable<T, Key, Hash>& ht)
122 // Check for assignment to self
127 "HashPtrTable<T, Key, Hash>::operator="
128 "(const HashPtrTable<T, Key, Hash>&)"
129 ) << "attempted assignment to self"
130 << abort(FatalError);
135 for(const_iterator iter = ht.begin(); iter != ht.end(); ++iter)
137 insert(iter.key(), new T(**iter));
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144 } // End namespace Foam
146 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
148 #include "HashPtrTableIO.C"
150 // ************************************************************************* //