mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
HashTable minor/cosmetic changes
This commit is contained in:
@ -290,7 +290,7 @@ public:
|
||||
// Private data
|
||||
|
||||
//- Reference to the HashTable this is an iterator for
|
||||
HashTable<T, Key, Hash>& curHashTable_;
|
||||
HashTable<T, Key, Hash>& 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<T, Key, Hash>& curHashTable_;
|
||||
const HashTable<T, Key, Hash>& 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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -157,12 +157,12 @@ inline T& Foam::HashTable<T, Key, Hash>::operator()(const Key& key)
|
||||
template<class T, class Key, class Hash>
|
||||
inline Foam::HashTable<T, Key, Hash>::iterator::iterator
|
||||
(
|
||||
HashTable<T, Key, Hash>& curHashTable,
|
||||
HashTable<T, Key, Hash>& hashTbl,
|
||||
hashedEntry* elmt,
|
||||
label hashIndex
|
||||
)
|
||||
:
|
||||
curHashTable_(curHashTable),
|
||||
hashTable_(hashTbl),
|
||||
elmtPtr_(elmt),
|
||||
hashIndex_(hashIndex)
|
||||
{}
|
||||
@ -252,12 +252,12 @@ Foam::HashTable<T, Key, Hash>::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<T, Key, Hash>::iterator::operator++
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
inline
|
||||
const Key& Foam::HashTable<T, Key, Hash>::iterator::key()
|
||||
const Key& Foam::HashTable<T, Key, Hash>::iterator::key() const
|
||||
{
|
||||
return elmtPtr_->key_;
|
||||
}
|
||||
@ -335,12 +335,12 @@ Foam::HashTable<T, Key, Hash>::end()
|
||||
template<class T, class Key, class Hash>
|
||||
inline Foam::HashTable<T, Key, Hash>::const_iterator::const_iterator
|
||||
(
|
||||
const HashTable<T, Key, Hash>& curHashTable,
|
||||
const HashTable<T, Key, Hash>& hashTbl,
|
||||
const hashedEntry* elmt,
|
||||
label hashIndex
|
||||
)
|
||||
:
|
||||
curHashTable_(curHashTable),
|
||||
hashTable_(hashTbl),
|
||||
elmtPtr_(elmt),
|
||||
hashIndex_(hashIndex)
|
||||
{}
|
||||
@ -352,7 +352,7 @@ inline Foam::HashTable<T, Key, Hash>::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<T, Key, Hash>::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<T, Key, Hash>::const_iterator::operator++
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
inline
|
||||
const Key& Foam::HashTable<T, Key, Hash>::const_iterator::key()
|
||||
const Key& Foam::HashTable<T, Key, Hash>::const_iterator::key() const
|
||||
{
|
||||
return elmtPtr_->key_;
|
||||
}
|
||||
|
||||
@ -304,7 +304,7 @@ bool Foam::StaticHashTable<T, Key, Hash>::erase(const iterator& cit)
|
||||
List<T>& 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<T, Key, Hash>::erase(const iterator& cit)
|
||||
// adjust iterator after erase
|
||||
iterator& it = const_cast<iterator&>(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<T, Key, Hash>::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<T, Key, Hash>::erase(const iterator& cit)
|
||||
// - not end()
|
||||
// - handled by operator++
|
||||
it.hashIndex_ = -1;
|
||||
it.elementIndex_ = 0;
|
||||
it.elemIndex_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -150,14 +150,14 @@ template<class T, class Key, class Hash>
|
||||
template<class TRef, class TableRef>
|
||||
inline Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::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<T, Key, Hash>::Iterator<TRef, TableRef>::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<T, Key, Hash>::Iterator<TRef, TableRef>::operator=
|
||||
)
|
||||
{
|
||||
this->hashIndex_ = iter.hashIndex_;
|
||||
this->elementIndex_ = iter.elementIndex_;
|
||||
this->elemIndex_ = iter.elemIndex_;
|
||||
}
|
||||
|
||||
|
||||
@ -195,7 +195,7 @@ Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::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<T, Key, Hash>::Iterator<TRef, TableRef>::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<class TRef, class TableRef>
|
||||
inline TRef
|
||||
Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::operator*()
|
||||
{
|
||||
return curHashTable_.objects_[hashIndex_][elementIndex_];
|
||||
return hashTable_.objects_[hashIndex_][elemIndex_];
|
||||
}
|
||||
|
||||
|
||||
@ -271,29 +271,29 @@ Foam::StaticHashTable<T, Key, Hash>::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<T, Key, Hash>::Iterator
|
||||
template<class T, class Key, class Hash>
|
||||
template<class TRef, class TableRef>
|
||||
inline const Key&
|
||||
Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::key()
|
||||
Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::key() const
|
||||
{
|
||||
return curHashTable_.keys_[hashIndex_][elementIndex_];
|
||||
return hashTable_.keys_[hashIndex_][elemIndex_];
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user