added HashTable::clearStorage() for symmetry with DynamicList

This commit is contained in:
Mark Olesen
2008-12-12 09:48:51 +01:00
parent cc571ba111
commit 8a5931f15a
3 changed files with 57 additions and 76 deletions

View File

@ -456,6 +456,14 @@ void HashTable<T, Key, Hash>::clear()
} }
template<class T, class Key, class Hash>
void HashTable<T, Key, Hash>::clearStorage()
{
clear();
resize(0);
}
template<class T, class Key, class Hash> template<class T, class Key, class Hash>
void HashTable<T, Key, Hash>::transfer(HashTable<T, Key, Hash>& ht) void HashTable<T, Key, Hash>::transfer(HashTable<T, Key, Hash>& ht)
{ {

View File

@ -102,7 +102,7 @@ class HashTable
//- Construct given key, next pointer and object //- Construct given key, next pointer and object
inline hashedEntry inline hashedEntry
( (
const Key& key, const Key&,
hashedEntry* next, hashedEntry* next,
const T& newEntry const T& newEntry
); );
@ -127,7 +127,7 @@ class HashTable
// Private Member Functions // Private Member Functions
//- Assign a new hashedEntry to a possibly already existing key //- Assign a new hashedEntry to a possibly already existing key
bool set(const Key& key, const T& newElmt, bool protect); bool set(const Key&, const T& newElmt, bool protect);
public: public:
@ -173,15 +173,15 @@ public:
inline label size() const; inline label size() const;
//- Return true if hashedEntry is found in table //- Return true if hashedEntry is found in table
bool found(const Key& key) const; bool found(const Key&) const;
//- Find and return an iterator set at the hashedEntry //- Find and return an iterator set at the hashedEntry
// If not found iterator = end() // If not found iterator = end()
iterator find(const Key& key); iterator find(const Key&);
//- Find and return an const_iterator set at the hashedEntry //- Find and return an const_iterator set at the hashedEntry
// If not found iterator = end() // If not found iterator = end()
const_iterator find(const Key& key) const; const_iterator find(const Key&) const;
//- Return the table of contents //- Return the table of contents
List<Key> toc() const; List<Key> toc() const;
@ -190,16 +190,16 @@ public:
// Edit // Edit
//- Insert a new hashedEntry //- Insert a new hashedEntry
inline bool insert(const Key& key, const T& newElmt); inline bool insert(const Key&, const T& newElmt);
//- Assign a new hashedEntry, overwriting existing entries //- Assign a new hashedEntry, overwriting existing entries
inline bool set(const Key& key, const T& newElmt); inline bool set(const Key&, const T& newElmt);
//- Erase an hashedEntry specified by given iterator //- Erase an hashedEntry specified by given iterator
bool erase(const iterator& it); bool erase(const iterator&);
//- Erase an hashedEntry specified by given key if in table //- Erase an hashedEntry specified by given key if in table
bool erase(const Key& key); bool erase(const Key&);
//- Resize the hash table for efficiency //- Resize the hash table for efficiency
void resize(const label newSize); void resize(const label newSize);
@ -207,6 +207,10 @@ public:
//- Clear all entries from table //- Clear all entries from table
void clear(); void clear();
//- Clear the table entries and the table itself.
// Equivalent to clear() followed by resize(0)
void clearStorage();
//- Transfer the contents of the argument table into this table //- Transfer the contents of the argument table into this table
// and annull the argument table. // and annull the argument table.
void transfer(HashTable<T, Key, Hash>&); void transfer(HashTable<T, Key, Hash>&);
@ -215,14 +219,14 @@ public:
// Member Operators // Member Operators
//- Find and return an hashedEntry //- Find and return an hashedEntry
inline T& operator[](const Key& key); inline T& operator[](const Key&);
//- Find and return an hashedEntry //- Find and return an hashedEntry
inline const T& operator[](const Key& key) const; inline const T& operator[](const Key&) const;
//- Find and return an hashedEntry and //- Find and return an hashedEntry and
// if it is not present create it null. // if it is not present create it null.
inline T& operator()(const Key& key); inline T& operator()(const Key&);
//- Assignment //- Assignment
void operator=(const HashTable<T, Key, Hash>&); void operator=(const HashTable<T, Key, Hash>&);
@ -290,13 +294,13 @@ public:
// Member operators // Member operators
inline void operator=(const iterator& iter); inline void operator=(const iterator&);
inline bool operator==(const iterator& iter) const; inline bool operator==(const iterator&) const;
inline bool operator!=(const iterator& iter) const; inline bool operator!=(const iterator&) const;
inline bool operator==(const const_iterator& iter) const; inline bool operator==(const const_iterator&) const;
inline bool operator!=(const const_iterator& iter) const; inline bool operator!=(const const_iterator&) const;
inline T& operator*(); inline T& operator*();
inline T& operator()(); inline T& operator()();
@ -352,13 +356,13 @@ public:
// Member operators // Member operators
inline void operator=(const const_iterator& iter); inline void operator=(const const_iterator&);
inline bool operator==(const const_iterator& iter) const; inline bool operator==(const const_iterator&) const;
inline bool operator!=(const const_iterator& iter) const; inline bool operator!=(const const_iterator&) const;
inline bool operator==(const iterator& iter) const; inline bool operator==(const iterator&) const;
inline bool operator!=(const iterator& iter) const; inline bool operator!=(const iterator&) const;
inline const T& operator*(); inline const T& operator*();
inline const T& operator()(); inline const T& operator()();

View File

@ -1964,21 +1964,15 @@ void Foam::polyTopoChange::compactAndReorder
// Clear inflation info // Clear inflation info
{ {
faceFromPoint_.clear(); faceFromPoint_.clearStorage();
faceFromPoint_.resize(0); faceFromEdge_.clearStorage();
faceFromEdge_.clear();
faceFromEdge_.resize(0);
cellFromPoint_.clear(); cellFromPoint_.clearStorage();
cellFromPoint_.resize(0); cellFromEdge_.clearStorage();
cellFromEdge_.clear(); cellFromFace_.clearStorage();
cellFromEdge_.resize(0);
cellFromFace_.clear();
cellFromFace_.resize(0);
} }
const polyBoundaryMesh& boundary = mesh.boundaryMesh(); const polyBoundaryMesh& boundary = mesh.boundaryMesh();
// Grab patch mesh point maps // Grab patch mesh point maps
@ -2092,10 +2086,8 @@ void Foam::polyTopoChange::clear()
points_.clearStorage(); points_.clearStorage();
pointMap_.clearStorage(); pointMap_.clearStorage();
reversePointMap_.clearStorage(); reversePointMap_.clearStorage();
pointZone_.clear(); pointZone_.clearStorage();
pointZone_.resize(0); retiredPoints_.clearStorage();
retiredPoints_.clear();
retiredPoints_.resize(0);
faces_.clearStorage(); faces_.clearStorage();
region_.clearStorage(); region_.clearStorage();
@ -2103,27 +2095,19 @@ void Foam::polyTopoChange::clear()
faceNeighbour_.clearStorage(); faceNeighbour_.clearStorage();
faceMap_.clearStorage(); faceMap_.clearStorage();
reverseFaceMap_.clearStorage(); reverseFaceMap_.clearStorage();
faceFromPoint_.clear(); faceFromPoint_.clearStorage();
faceFromPoint_.resize(0); faceFromEdge_.clearStorage();
faceFromEdge_.clear(); flipFaceFlux_.clearStorage();
faceFromEdge_.resize(0); faceZone_.clearStorage();
flipFaceFlux_.clear(); faceZoneFlip_.clearStorage();
flipFaceFlux_.resize(0);
faceZone_.clear();
faceZone_.resize(0);
faceZoneFlip_.clear();
faceZoneFlip_.resize(0);
nActiveFaces_ = 0; nActiveFaces_ = 0;
cellMap_.clearStorage(); cellMap_.clearStorage();
reverseCellMap_.clearStorage(); reverseCellMap_.clearStorage();
cellZone_.clearStorage(); cellZone_.clearStorage();
cellFromPoint_.clear(); cellFromPoint_.clearStorage();
cellFromPoint_.resize(0); cellFromEdge_.clearStorage();
cellFromEdge_.clear(); cellFromFace_.clearStorage();
cellFromEdge_.resize(0);
cellFromFace_.clear();
cellFromFace_.resize(0);
} }
@ -2996,8 +2980,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::changeMesh
// Clear out primitives // Clear out primitives
{ {
retiredPoints_.clear(); retiredPoints_.clearStorage();
retiredPoints_.resize(0);
region_.clearStorage(); region_.clearStorage();
} }
@ -3053,15 +3036,9 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::changeMesh
// Clear zone info // Clear zone info
{ {
pointZone_.clear(); pointZone_.clearStorage();
pointZone_.resize(0); faceZone_.clearStorage();
faceZoneFlip_.clearStorage();
faceZone_.clear();
faceZone_.resize(0);
faceZoneFlip_.clear();
faceZoneFlip_.resize(0);
cellZone_.clearStorage(); cellZone_.clearStorage();
} }
@ -3227,8 +3204,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::makeMesh
// Clear out primitives // Clear out primitives
{ {
retiredPoints_.clear(); retiredPoints_.clearStorage();
retiredPoints_.resize(0);
region_.clearStorage(); region_.clearStorage();
} }
@ -3346,16 +3322,9 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::makeMesh
// Clear zone info // Clear zone info
{ {
pointZone_.clear(); pointZone_.clearStorage();
pointZone_.resize(0); faceZone_.clearStorage();
faceZoneFlip_.clearStorage();
faceZone_.clear();
faceZone_.resize(0);
faceZoneFlip_.clear();
faceZoneFlip_.resize(0);
cellZone_.clear();
cellZone_.clearStorage(); cellZone_.clearStorage();
} }