From 8a5931f15a703331d9d151788f92287ed8348350 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@Germany> Date: Fri, 12 Dec 2008 09:48:51 +0100 Subject: [PATCH] added HashTable::clearStorage() for symmetry with DynamicList --- .../HashTables/HashTable/HashTable.C | 8 ++ .../HashTables/HashTable/HashTable.H | 48 ++++++------ .../polyTopoChange/polyTopoChange.C | 77 ++++++------------- 3 files changed, 57 insertions(+), 76 deletions(-) diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C index d9d74fd1ad4..37c595222e5 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C @@ -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> void HashTable<T, Key, Hash>::transfer(HashTable<T, Key, Hash>& ht) { diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index 701d8456156..ac30f878a83 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -102,7 +102,7 @@ class HashTable //- Construct given key, next pointer and object inline hashedEntry ( - const Key& key, + const Key&, hashedEntry* next, const T& newEntry ); @@ -127,7 +127,7 @@ class HashTable // Private Member Functions //- 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: @@ -173,15 +173,15 @@ public: inline label size() const; //- 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 // If not found iterator = end() - iterator find(const Key& key); + iterator find(const Key&); //- Find and return an const_iterator set at the hashedEntry // If not found iterator = end() - const_iterator find(const Key& key) const; + const_iterator find(const Key&) const; //- Return the table of contents List<Key> toc() const; @@ -190,16 +190,16 @@ public: // Edit //- 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 - inline bool set(const Key& key, const T& newElmt); + inline bool set(const Key&, const T& newElmt); //- 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 - bool erase(const Key& key); + bool erase(const Key&); //- Resize the hash table for efficiency void resize(const label newSize); @@ -207,6 +207,10 @@ public: //- Clear all entries from table 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 // and annull the argument table. void transfer(HashTable<T, Key, Hash>&); @@ -215,14 +219,14 @@ public: // Member Operators //- Find and return an hashedEntry - inline T& operator[](const Key& key); + inline T& operator[](const Key&); //- 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 // if it is not present create it null. - inline T& operator()(const Key& key); + inline T& operator()(const Key&); //- Assignment void operator=(const HashTable<T, Key, Hash>&); @@ -290,13 +294,13 @@ public: // 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& iter) const; + inline bool operator==(const iterator&) const; + inline bool operator!=(const iterator&) const; - inline bool operator==(const const_iterator& iter) const; - inline bool operator!=(const const_iterator& iter) const; + inline bool operator==(const const_iterator&) const; + inline bool operator!=(const const_iterator&) const; inline T& operator*(); inline T& operator()(); @@ -352,13 +356,13 @@ public: // 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& iter) const; + inline bool operator==(const const_iterator&) const; + inline bool operator!=(const const_iterator&) const; - inline bool operator==(const iterator& iter) const; - inline bool operator!=(const iterator& iter) const; + inline bool operator==(const iterator&) const; + inline bool operator!=(const iterator&) const; inline const T& operator*(); inline const T& operator()(); diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C index 1ec3f9d0f09..e22ca0cd69f 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C @@ -1964,21 +1964,15 @@ void Foam::polyTopoChange::compactAndReorder // Clear inflation info { - faceFromPoint_.clear(); - faceFromPoint_.resize(0); - faceFromEdge_.clear(); - faceFromEdge_.resize(0); + faceFromPoint_.clearStorage(); + faceFromEdge_.clearStorage(); - cellFromPoint_.clear(); - cellFromPoint_.resize(0); - cellFromEdge_.clear(); - cellFromEdge_.resize(0); - cellFromFace_.clear(); - cellFromFace_.resize(0); + cellFromPoint_.clearStorage(); + cellFromEdge_.clearStorage(); + cellFromFace_.clearStorage(); } - const polyBoundaryMesh& boundary = mesh.boundaryMesh(); // Grab patch mesh point maps @@ -2092,10 +2086,8 @@ void Foam::polyTopoChange::clear() points_.clearStorage(); pointMap_.clearStorage(); reversePointMap_.clearStorage(); - pointZone_.clear(); - pointZone_.resize(0); - retiredPoints_.clear(); - retiredPoints_.resize(0); + pointZone_.clearStorage(); + retiredPoints_.clearStorage(); faces_.clearStorage(); region_.clearStorage(); @@ -2103,27 +2095,19 @@ void Foam::polyTopoChange::clear() faceNeighbour_.clearStorage(); faceMap_.clearStorage(); reverseFaceMap_.clearStorage(); - faceFromPoint_.clear(); - faceFromPoint_.resize(0); - faceFromEdge_.clear(); - faceFromEdge_.resize(0); - flipFaceFlux_.clear(); - flipFaceFlux_.resize(0); - faceZone_.clear(); - faceZone_.resize(0); - faceZoneFlip_.clear(); - faceZoneFlip_.resize(0); + faceFromPoint_.clearStorage(); + faceFromEdge_.clearStorage(); + flipFaceFlux_.clearStorage(); + faceZone_.clearStorage(); + faceZoneFlip_.clearStorage(); nActiveFaces_ = 0; cellMap_.clearStorage(); reverseCellMap_.clearStorage(); cellZone_.clearStorage(); - cellFromPoint_.clear(); - cellFromPoint_.resize(0); - cellFromEdge_.clear(); - cellFromEdge_.resize(0); - cellFromFace_.clear(); - cellFromFace_.resize(0); + cellFromPoint_.clearStorage(); + cellFromEdge_.clearStorage(); + cellFromFace_.clearStorage(); } @@ -2996,8 +2980,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::changeMesh // Clear out primitives { - retiredPoints_.clear(); - retiredPoints_.resize(0); + retiredPoints_.clearStorage(); region_.clearStorage(); } @@ -3053,15 +3036,9 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::changeMesh // Clear zone info { - pointZone_.clear(); - pointZone_.resize(0); - - faceZone_.clear(); - faceZone_.resize(0); - - faceZoneFlip_.clear(); - faceZoneFlip_.resize(0); - + pointZone_.clearStorage(); + faceZone_.clearStorage(); + faceZoneFlip_.clearStorage(); cellZone_.clearStorage(); } @@ -3227,8 +3204,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::makeMesh // Clear out primitives { - retiredPoints_.clear(); - retiredPoints_.resize(0); + retiredPoints_.clearStorage(); region_.clearStorage(); } @@ -3346,16 +3322,9 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::makeMesh // Clear zone info { - pointZone_.clear(); - pointZone_.resize(0); - - faceZone_.clear(); - faceZone_.resize(0); - - faceZoneFlip_.clear(); - faceZoneFlip_.resize(0); - - cellZone_.clear(); + pointZone_.clearStorage(); + faceZone_.clearStorage(); + faceZoneFlip_.clearStorage(); cellZone_.clearStorage(); } -- GitLab