Go to the documentation of this file.
32 template<
class T,
class Key,
class Hash>
37 tableSize_(HashTableCore::canonicalSize(size)),
42 table_ =
new hashedEntry*[tableSize_];
44 for (
label hashIdx = 0; hashIdx < tableSize_; hashIdx++)
56 template<
class T,
class Key,
class Hash>
62 unsigned avgChain = 0;
64 for (
label hashIdx = 0; hashIdx < tableSize_; ++hashIdx)
67 for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_)
84 os <<
"HashTable<T,Key,Hash>"
85 <<
" elements:" << size() <<
" slots:" << used <<
"/" << tableSize_
86 <<
" chaining(avg/max):" << (used ? (float(avgChain)/used) : 0)
87 <<
"/" << maxChain <<
endl;
95 template<
class T,
class Key,
class Hash>
102 is.
fatalCheck(
"operator>>(Istream&, HashTable<T, Key, Hash>&)");
107 is.fatalCheck(
"operator>>(Istream&, HashTable<T, Key, Hash>&)");
109 token firstToken(is);
113 "operator>>(Istream&, HashTable<T, Key, Hash>&) : "
114 "reading first token"
117 if (firstToken.isLabel())
119 label s = firstToken.labelToken();
122 char delimiter = is.readBeginList(
"HashTable<T, Key, Hash>");
126 if (2*
s > L.tableSize_)
131 if (delimiter == token::BEGIN_LIST)
137 L.insert(key, pTraits<T>(is));
141 "operator>>(Istream&, HashTable<T, Key, Hash>&) : "
151 ) <<
"incorrect first token, '(', found " << firstToken.info()
157 is.readEndList(
"HashTable");
159 else if (firstToken.isPunctuation())
161 if (firstToken.pToken() != token::BEGIN_LIST)
166 ) <<
"incorrect first token, '(', found " << firstToken.info()
174 lastToken.isPunctuation()
175 && lastToken.pToken() == token::END_LIST
179 is.putBack(lastToken);
187 L.insert(key, element);
191 "operator>>(Istream&, HashTable<T, Key, Hash>&) : "
203 ) <<
"incorrect first token, expected <int> or '(', found "
208 is.fatalCheck(
"operator>>(Istream&, HashTable<T, Key, Hash>&)");
214 template<
class T,
class Key,
class Hash>
218 const HashTable<T, Key, Hash>& L
222 os <<
nl << L.size() <<
nl << token::BEGIN_LIST <<
nl;
227 typename HashTable<T, Key, Hash>::const_iterator iter = L.cbegin();
232 os << iter.key() << token::SPACE << iter() <<
nl;
236 os << token::END_LIST;
239 os.check(
"Ostream& operator<<(Ostream&, const HashTable&)");
void fatalCheck(const char *operation) const
Check IOstream status for given operation.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A token holds items read from Istream.
HashTable(const label size=128)
Construct given initial table size.
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)....
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)
An STL-conforming hash table.
Istream & operator>>(Istream &, edgeMesh &)
#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,...