From 9b8de83ab493f46e6f2ef430517a61bac0e5d30b Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 4 Mar 2009 12:15:01 +0100 Subject: [PATCH] HashTable minor/cosmetic changes --- .../HashTables/HashTable/HashTable.H | 10 ++--- .../HashTables/HashTable/HashTableI.H | 28 +++++++------- .../StaticHashTable/StaticHashTable.C | 10 ++--- .../StaticHashTable/StaticHashTable.H | 21 +++++----- .../StaticHashTable/StaticHashTableI.H | 38 +++++++++---------- 5 files changed, 52 insertions(+), 55 deletions(-) diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index 696ab41075..5112f6fb7d 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -290,7 +290,7 @@ public: // Private data //- Reference to the HashTable this is an iterator for - HashTable& curHashTable_; + HashTable& hashTable_; //- Current element hashedEntry* elmtPtr_; @@ -298,7 +298,6 @@ public: //- Current hash index label hashIndex_; - public: // Constructors @@ -311,7 +310,6 @@ public: label hashIndex ); - // Member operators inline void operator=(const iterator&); @@ -328,7 +326,7 @@ public: inline iterator& operator++(); inline iterator operator++(int); - inline const Key& key(); + inline const Key& key() const; }; @@ -349,7 +347,7 @@ public: // Private data //- Reference to the HashTable this is an iterator for - const HashTable& curHashTable_; + const HashTable& hashTable_; //- Current element const hashedEntry* elmtPtr_; @@ -390,7 +388,7 @@ public: inline const_iterator& operator++(); inline const_iterator operator++(int); - inline const Key& key(); + inline const Key& key() const; }; diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H index e50d307968..005979df3f 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H @@ -157,12 +157,12 @@ inline T& Foam::HashTable::operator()(const Key& key) template inline Foam::HashTable::iterator::iterator ( - HashTable& curHashTable, + HashTable& hashTbl, hashedEntry* elmt, label hashIndex ) : - curHashTable_(curHashTable), + hashTable_(hashTbl), elmtPtr_(elmt), hashIndex_(hashIndex) {} @@ -252,12 +252,12 @@ Foam::HashTable::iterator::operator++() // Step to the next table entry while ( - ++hashIndex_ < curHashTable_.tableSize_ - && !(elmtPtr_ = curHashTable_.table_[hashIndex_]) + ++hashIndex_ < hashTable_.tableSize_ + && !(elmtPtr_ = hashTable_.table_[hashIndex_]) ) {} - if (hashIndex_ == curHashTable_.tableSize_) + if (hashIndex_ == hashTable_.tableSize_) { // make end iterator elmtPtr_ = 0; @@ -282,7 +282,7 @@ Foam::HashTable::iterator::operator++ template inline -const Key& Foam::HashTable::iterator::key() +const Key& Foam::HashTable::iterator::key() const { return elmtPtr_->key_; } @@ -335,12 +335,12 @@ Foam::HashTable::end() template inline Foam::HashTable::const_iterator::const_iterator ( - const HashTable& curHashTable, + const HashTable& hashTbl, const hashedEntry* elmt, label hashIndex ) : - curHashTable_(curHashTable), + hashTable_(hashTbl), elmtPtr_(elmt), hashIndex_(hashIndex) {} @@ -352,7 +352,7 @@ inline Foam::HashTable::const_iterator::const_iterator const iterator& iter ) : - curHashTable_(iter.curHashTable_), + hashTable_(iter.hashTable_), elmtPtr_(iter.elmtPtr_), hashIndex_(iter.hashIndex_) {} @@ -431,14 +431,14 @@ Foam::HashTable::const_iterator::operator++() if ( !(elmtPtr_ = elmtPtr_->next_) - && ++hashIndex_ < curHashTable_.tableSize_ - && !(elmtPtr_ = curHashTable_.table_[hashIndex_]) + && ++hashIndex_ < hashTable_.tableSize_ + && !(elmtPtr_ = hashTable_.table_[hashIndex_]) ) { while ( - ++hashIndex_ < curHashTable_.tableSize_ - && !(elmtPtr_ = curHashTable_.table_[hashIndex_]) + ++hashIndex_ < hashTable_.tableSize_ + && !(elmtPtr_ = hashTable_.table_[hashIndex_]) ) {} } @@ -462,7 +462,7 @@ Foam::HashTable::const_iterator::operator++ template inline -const Key& Foam::HashTable::const_iterator::key() +const Key& Foam::HashTable::const_iterator::key() const { return elmtPtr_->key_; } diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C index 9b08bb3e67..8d5362b89d 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C @@ -304,7 +304,7 @@ bool Foam::StaticHashTable::erase(const iterator& cit) List& localObjects = objects_[cit.hashIndex_]; // Copy down - for (label i = cit.elementIndex_+1; i < localKeys.size(); i++) + for (label i = cit.elemIndex_+1; i < localKeys.size(); i++) { localKeys[i-1] = localKeys[i]; localObjects[i-1] = localObjects[i]; @@ -315,8 +315,8 @@ bool Foam::StaticHashTable::erase(const iterator& cit) // adjust iterator after erase iterator& it = const_cast(cit); - it.elementIndex_--; - if (it.elementIndex_ < 0) + it.elemIndex_--; + if (it.elemIndex_ < 0) { // No previous element in the local list @@ -327,7 +327,7 @@ bool Foam::StaticHashTable::erase(const iterator& cit) if (it.hashIndex_ >= 0) { // The last element in the local list - it.elementIndex_ = objects_[it.hashIndex_].size() - 1; + it.elemIndex_ = objects_[it.hashIndex_].size() - 1; } else { @@ -335,7 +335,7 @@ bool Foam::StaticHashTable::erase(const iterator& cit) // - not end() // - handled by operator++ it.hashIndex_ = -1; - it.elementIndex_ = 0; + it.elemIndex_ = 0; } } diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H index 3c3264e42a..25b5933e9d 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H @@ -32,7 +32,6 @@ Note Uses straight lists as underlying type. Is slower to insert than the standard HashTable, but should be more memory efficient and faster to access. - Explicitly does not have default size. SourceFiles StaticHashTableI.H @@ -284,13 +283,13 @@ public: // Private data //- Reference to the StaticHashTable this is an iterator for - TableRef curHashTable_; + TableRef hashTable_; //- Current hash index label hashIndex_; //- Index of current element at hashIndex - label elementIndex_; + label elemIndex_; public: @@ -299,9 +298,9 @@ public: //- Construct from hash table, hash index and element index inline Iterator ( - TableRef curHashTable, + TableRef, label hashIndex_, - label elementIndex_ + label elemIndex_ ); //- Construct from the non-const iterator @@ -310,13 +309,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 const_iterator& iter) const; + inline bool operator==(const iterator&) const; + inline bool operator==(const const_iterator&) const; - inline bool operator!=(const iterator& iter) const; - inline bool operator!=(const const_iterator& iter) const; + inline bool operator!=(const iterator&) const; + inline bool operator!=(const const_iterator&) const; inline TRef operator*(); inline TRef operator()(); @@ -324,7 +323,7 @@ public: inline Iterator& operator++(); inline Iterator operator++(int); - inline const Key& key(); + inline const Key& key() const; }; diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H index 88f2d9bdb9..abd988a4df 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H @@ -150,14 +150,14 @@ template template inline Foam::StaticHashTable::Iterator::Iterator ( - TableRef curHashTable, + TableRef hashTbl, label hashIndex, - label elementIndex + label elemIndex ) : - curHashTable_(curHashTable), + hashTable_(hashTbl), hashIndex_(hashIndex), - elementIndex_(elementIndex) + elemIndex_(elemIndex) {} @@ -168,9 +168,9 @@ inline Foam::StaticHashTable::Iterator::Iterator const iterator& iter ) : - curHashTable_(iter.curHashTable_), + hashTable_(iter.hashTable_), hashIndex_(iter.hashIndex_), - elementIndex_(iter.elementIndex_) + elemIndex_(iter.elemIndex_) {} @@ -183,7 +183,7 @@ Foam::StaticHashTable::Iterator::operator= ) { this->hashIndex_ = iter.hashIndex_; - this->elementIndex_ = iter.elementIndex_; + this->elemIndex_ = iter.elemIndex_; } @@ -195,7 +195,7 @@ Foam::StaticHashTable::Iterator::operator== const iterator& iter ) const { - return hashIndex_ == iter.hashIndex_ && elementIndex_ == iter.elementIndex_; + return hashIndex_ == iter.hashIndex_ && elemIndex_ == iter.elemIndex_; } @@ -207,7 +207,7 @@ Foam::StaticHashTable::Iterator::operator== const const_iterator& iter ) const { - return hashIndex_ == iter.hashIndex_ && elementIndex_ == iter.elementIndex_; + return hashIndex_ == iter.hashIndex_ && elemIndex_ == iter.elemIndex_; } @@ -240,7 +240,7 @@ template inline TRef Foam::StaticHashTable::Iterator::operator*() { - return curHashTable_.objects_[hashIndex_][elementIndex_]; + return hashTable_.objects_[hashIndex_][elemIndex_]; } @@ -271,29 +271,29 @@ Foam::StaticHashTable::Iterator if (hashIndex_ >= 0) { // Try the next element on the local list - elementIndex_++; + elemIndex_++; - if (elementIndex_ < curHashTable_.objects_[hashIndex_].size()) + if (elemIndex_ < hashTable_.objects_[hashIndex_].size()) { return *this; } } // Step to the next table entry - elementIndex_ = 0; + elemIndex_ = 0; while ( - ++hashIndex_ < curHashTable_.objects_.size() - && !curHashTable_.objects_[hashIndex_].size() + ++hashIndex_ < hashTable_.objects_.size() + && !hashTable_.objects_[hashIndex_].size() ) {} - if (hashIndex_ >= curHashTable_.objects_.size()) + if (hashIndex_ >= hashTable_.objects_.size()) { // make end iterator - hashIndex_ = curHashTable_.keys_.size(); + hashIndex_ = hashTable_.keys_.size(); } return *this; @@ -326,9 +326,9 @@ Foam::StaticHashTable::Iterator template template inline const Key& -Foam::StaticHashTable::Iterator::key() +Foam::StaticHashTable::Iterator::key() const { - return curHashTable_.keys_[hashIndex_][elementIndex_]; + return hashTable_.keys_[hashIndex_][elemIndex_]; }