/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . \*---------------------------------------------------------------------------*/ #include "error.H" #include "HashPtrTable.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // Construct given initial table size template Foam::HashPtrTable::HashPtrTable(const label size) : HashTable(size) {} // Construct as copy template Foam::HashPtrTable::HashPtrTable ( const HashPtrTable& ht ) : HashTable() { for (const_iterator iter = ht.begin(); iter != ht.end(); ++iter) { this->insert(iter.key(), new T(**iter)); } } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template Foam::HashPtrTable::~HashPtrTable() { clear(); } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template T* Foam::HashPtrTable::remove(iterator& it) { T* elemPtr = *it; HashTable::erase(it); return elemPtr; } template bool Foam::HashPtrTable::erase(iterator& it) { T* elemPtr = *it; if (HashTable::erase(it)) { if (elemPtr) { delete elemPtr; } return true; } else { return false; } } template void Foam::HashPtrTable::clear() { for ( iterator iter = this->begin(); iter != this->end(); ++iter ) { delete *iter; } HashTable::clear(); } // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template void Foam::HashPtrTable::operator= ( const HashPtrTable& rhs ) { // Check for assignment to self if (this == &rhs) { FatalErrorIn ( "HashPtrTable::operator=" "(const HashPtrTable&)" ) << "attempted assignment to self" << abort(FatalError); } this->clear(); for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter) { this->insert(iter.key(), new T(**iter)); } } // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // #include "HashPtrTableIO.C" // ************************************************************************* //