32 template<
class T,
class Key,
class Hash>
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>
104 template<
class T,
class Key,
class Hash>
108 HashTable<T, Key, Hash>& L
111 is.
fatalCheck(
"operator>>(Istream&, HashTable<T, Key, Hash>&)");
116 is.fatalCheck(
"operator>>(Istream&, HashTable<T, Key, Hash>&)");
118 token firstToken(is);
122 "operator>>(Istream&, HashTable<T, Key, Hash>&) : "
123 "reading first token"
126 if (firstToken.isLabel())
128 label s = firstToken.labelToken();
131 char delimiter = is.readBeginList(
"HashTable<T, Key, Hash>");
135 if (2*
s > L.tableSize_)
146 L.insert(key, pTraits<T>(is));
150 "operator>>(Istream&, HashTable<T, Key, Hash>&) : "
160 ) <<
"incorrect first token, '(', found " << firstToken.info()
166 is.readEndList(
"HashTable");
168 else if (firstToken.isPunctuation())
175 ) <<
"incorrect first token, '(', found " << firstToken.info()
183 lastToken.isPunctuation()
188 is.putBack(lastToken);
196 L.insert(key, element);
200 "operator>>(Istream&, HashTable<T, Key, Hash>&) : "
212 ) <<
"incorrect first token, expected <int> or '(', found "
217 is.fatalCheck(
"operator>>(Istream&, HashTable<T, Key, Hash>&)");
223 template<
class T,
class Key,
class Hash>
227 const HashTable<T, Key, Hash>& L
248 os.check(
"Ostream& operator<<(Ostream&, const HashTable&)");
An STL-conforming hash table.
Ostream & printInfo(Ostream &) const
Print information.
friend Istream & operator>>(Istream &, HashTable< T, Key, Hash > &)
friend class const_iterator
Declare friendship with the const_iterator.
HashTable(const label size=128)
Construct given initial table size.
void fatalCheck(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)....
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
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.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
errorManipArg< error, int > exit(error &err, const int errNo=1)
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 & endl(Ostream &os)
Add newline and flush stream.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
label count(const ListType &l, typename ListType::const_reference x)
Count the number of occurrences of a value in a list.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Template-invariant bits for HashTable.