Go to the documentation of this file.
32 template<
class T,
class Key,
class Hash>
39 StaticHashTableCore(),
40 keys_(StaticHashTableCore::canonicalSize(size)),
41 objects_(StaticHashTableCore::canonicalSize(size)),
43 endIter_(*this, keys_.size(), 0),
44 endConstIter_(*this, keys_.size(), 0)
49 <<
"Illegal size " << size <<
" for StaticHashTable."
59 template<
class T,
class Key,
class Hash>
65 unsigned avgChain = 0;
70 const label count = keys_[hashIdx].size();
83 os <<
"StaticHashTable<T,Key,Hash>"
84 <<
" elements:" << size() <<
" slots:" << used <<
"/" << keys_.size()
85 <<
" chaining(avg/max):" << (used ? float(avgChain/used) : 0)
86 <<
"/" << maxChain <<
endl;
94 template<
class T,
class Key,
class Hash>
97 is.
fatalCheck(
"operator>>(Istream&, StaticHashTable<T, Key, Hash>&)");
102 is.
fatalCheck(
"operator>>(Istream&, StaticHashTable<T, Key, Hash>&)");
104 token firstToken(is);
108 "operator>>(Istream&, StaticHashTable<T, Key, Hash>&) : "
109 "reading first token"
112 if (firstToken.isLabel())
114 label s = firstToken.labelToken();
117 char delimiter = is.
readBeginList(
"StaticHashTable<T, Key, Hash>");
126 if (delimiter == token::BEGIN_LIST)
132 L.
insert(key, pTraits<T>(is));
136 "operator>>(Istream&, StaticHashTable<T, Key, Hash>&)"
146 ) <<
"incorrect first token, '(', found " << firstToken.info()
154 else if (firstToken.isPunctuation())
156 if (firstToken.pToken() != token::BEGIN_LIST)
161 ) <<
"incorrect first token, '(', found " << firstToken.info()
169 lastToken.isPunctuation()
170 && lastToken.pToken() == token::END_LIST
186 "operator>>(Istream&, StaticHashTable<T, Key, Hash>&) : "
198 ) <<
"incorrect first token, expected <int> or '(', found "
203 is.
fatalCheck(
"operator>>(Istream&, StaticHashTable<T, Key, Hash>&)");
209 template<
class T,
class Key,
class Hash>
213 const StaticHashTable<T, Key, Hash>& L)
216 os <<
nl << L.
size() <<
nl << token::BEGIN_LIST <<
nl;
226 os << iter.key() << token::SPACE << iter() <<
nl;
230 os << token::END_LIST;
233 os.check(
"Ostream& operator<<(Ostream&, const StaticHashTable&)");
void fatalCheck(const char *operation) const
Check IOstream status for given operation.
#define forAll(list, i)
Loop across all elements in list.
char readBeginList(const char *funcName)
char readEndList(const char *funcName)
Ostream & endl(Ostream &os)
Add newline and flush stream.
A token holds items read from Istream.
List< List< Key > > keys_
The lookup keys, ordered per hash value.
void clear()
Clear all entries from table.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & printInfo(Ostream &) const
Print information.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
label size() const
Return number of elements in table.
errorManip< error > abort(error &err)
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
errorManipArg< error, int > exit(error &err, const int errNo=1)
void resize(const label newSize)
Resize the hash table for efficiency.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const iterator & end()
Iterator set to beyond the end of the StaticHashTable.
Iterator< const T &, const StaticHashTable< T, Key, Hash > & > const_iterator
bool insert(const Key &key, const T &newElmt)
Insert a new hashed entry.
void putBack(const token &)
Put back token.
Istream & operator>>(Istream &, edgeMesh &)
iterator begin()
Iterator set to the beginning of the StaticHashTable.
StaticHashTable(const label size=128)
Construct given initial table size.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...