35template<
class T,
class Key,
class Hash>
47 for (label i=0; i < capacity_; ++i)
59template<
class T,
class Key,
class Hash>
64 unsigned avgChain = 0;
66 for (label i=0; i < capacity_; ++i)
69 for (
node_type* ep = table_[i]; ep; ep = ep->next_)
86 os <<
"HashTable<T,Key,Hash>"
87 <<
" elements:" << size() <<
" slots:" << used <<
"/" << capacity_
88 <<
" chaining(avg/max):" << (used ? (float(avgChain)/used) : 0)
89 <<
"/" << maxChain <<
endl;
95template<
class T,
class Key,
class Hash>
106 label i = this->size();
110 (i <= 1 || !shortLen)
118 for (
const_iterator iter = this->cbegin(); iter != this->cend(); ++iter)
131 for (
const_iterator iter = this->cbegin(); iter != this->cend(); ++iter)
133 os << iter.key() <<
nl;
144template<
class T,
class Key,
class Hash>
161 "operator>>(Istream&, HashTable&) : "
162 "reading first token"
167 const label len = tok.labelToken();
177 <<
"incorrect first token, '(', found "
187 for (label i=0; i<len; ++i)
197 "operator>>(Istream&, HashTable&) : "
221 "operator>>(Istream&, HashTable&) : "
231 <<
"incorrect first token, expected <int> or '(', found "
241template<
class T,
class Key,
class Hash>
249 const label len = tbl.
size();
257 for (
auto iter = tbl.
cbegin(); iter != tbl.
cend(); ++iter)
259 iter.print(
os) <<
nl;
277template<
class T,
class Key,
class Hash>
284 return tbl.readTable(is);
288template<
class T,
class Key,
class Hash>
292 const HashTable<T, Key, Hash>& tbl
295 return tbl.writeTable(
os);
Forward iterator with const access.
A HashTable similar to std::unordered_map.
Ostream & writeKeys(Ostream &os, const label shortLen=0) const
const_iterator cbegin() const
const_iterator set to the beginning of the HashTable
void resize(const label sz)
Resize the hash table for efficiency.
label capacity() const noexcept
The size of the underlying table.
std::conditional< std::is_same< zero::null, typenamestd::remove_cv< T >::type >::value, Detail::HashTableSingle< Key >, Detail::HashTablePair< Key, T > >::type node_type
label size() const noexcept
The number of elements in table.
HashTable()
Default construct with default (128) table capacity.
void clear()
Clear all entries from table.
constexpr const_iterator cend() const noexcept
const_iterator to signal the end (for any HashTable)
friend Istream & operator>>(Istream &, HashTable< T, Key, Hash > &tbl)
bool fatalCheck(const char *operation) const
Check IOstream status for given operation.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
char readEndList(const char *funcName)
End read of list data, ends with ')' or '}'.
char readBeginList(const char *funcName)
Begin read of list data, starts with '(' or '{'.
void putBack(const token &tok)
Put back a token. Only a single put back is permitted.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
void printInfo() const
Print general information about the mesh.
A token holds an item read from Istream.
@ BEGIN_LIST
Begin list [isseparator].
@ END_LIST
End list [isseparator].
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
OBJstream os(runTime.globalPath()/outputName)
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
Bits that are independent of HashTable template parameters.