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
25 \*---------------------------------------------------------------------------*/
28 #include "HashPtrTable.H"
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 // Construct given initial table size
33 template<class T, class Key, class Hash>
34 Foam::HashPtrTable<T, Key, Hash>::HashPtrTable(const label size)
36 HashTable<T*, Key, Hash>(size)
41 template<class T, class Key, class Hash>
42 Foam::HashPtrTable<T, Key, Hash>::HashPtrTable
44 const HashPtrTable<T, Key, Hash>& ht
47 HashTable<T*, Key, Hash>()
49 for (const_iterator iter = ht.begin(); iter != ht.end(); ++iter)
51 insert(iter.key(), new T(**iter));
56 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
58 template<class T, class Key, class Hash>
59 Foam::HashPtrTable<T, Key, Hash>::~HashPtrTable()
65 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
67 template<class T, class Key, class Hash>
68 T* Foam::HashPtrTable<T, Key, Hash>::remove(iterator& it)
71 HashTable<T*, Key, Hash>::erase(it);
76 template<class T, class Key, class Hash>
77 bool Foam::HashPtrTable<T, Key, Hash>::erase(iterator& it)
81 if (HashTable<T*, Key, Hash>::erase(it))
97 template<class T, class Key, class Hash>
98 void Foam::HashPtrTable<T, Key, Hash>::clear()
102 iterator iter = this->begin();
110 HashTable<T*, Key, Hash>::clear();
114 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
116 template<class T, class Key, class Hash>
117 void Foam::HashPtrTable<T, Key, Hash>::operator=
119 const HashPtrTable<T, Key, Hash>& rhs
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 = rhs.begin(); iter != rhs.end(); ++iter)
137 insert(iter.key(), new T(**iter));
141 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
143 #include "HashPtrTableIO.C"
145 // ************************************************************************* //