1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
27 #include "HashPtrTable.H"
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 // Construct given initial table size
32 template<class T, class Key, class Hash>
33 Foam::HashPtrTable<T, Key, Hash>::HashPtrTable(const label size)
35 HashTable<T*, Key, Hash>(size)
40 template<class T, class Key, class Hash>
41 Foam::HashPtrTable<T, Key, Hash>::HashPtrTable
43 const HashPtrTable<T, Key, Hash>& ht
46 HashTable<T*, Key, Hash>()
48 for (const_iterator iter = ht.begin(); iter != ht.end(); ++iter)
50 this->insert(iter.key(), new T(**iter));
55 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
57 template<class T, class Key, class Hash>
58 Foam::HashPtrTable<T, Key, Hash>::~HashPtrTable()
64 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
66 template<class T, class Key, class Hash>
67 T* Foam::HashPtrTable<T, Key, Hash>::remove(iterator& it)
70 HashTable<T*, Key, Hash>::erase(it);
75 template<class T, class Key, class Hash>
76 bool Foam::HashPtrTable<T, Key, Hash>::erase(iterator& it)
80 if (HashTable<T*, Key, Hash>::erase(it))
96 template<class T, class Key, class Hash>
97 void Foam::HashPtrTable<T, Key, Hash>::clear()
101 iterator iter = this->begin();
109 HashTable<T*, Key, Hash>::clear();
113 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
115 template<class T, class Key, class Hash>
116 void Foam::HashPtrTable<T, Key, Hash>::operator=
118 const HashPtrTable<T, Key, Hash>& rhs
121 // Check for assignment to self
126 "HashPtrTable<T, Key, Hash>::operator="
127 "(const HashPtrTable<T, Key, Hash>&)"
128 ) << "attempted assignment to self"
129 << abort(FatalError);
134 for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter)
136 this->insert(iter.key(), new T(**iter));
140 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
142 #include "HashPtrTableIO.C"
144 // ************************************************************************* //