41 #ifndef Foam_HashPtrTable_H 42 #define Foam_HashPtrTable_H 53 template<
class T>
class autoPtr;
54 template<
class T>
class refPtr;
55 template<
class T>
class tmp;
56 template<
class T,
class Key,
class Hash>
class HashPtrTable;
58 template<
class T,
class Key,
class Hash>
66 template<
class T,
class Key=word,
class Hash=Foam::Hash<Key>>
82 template<
class... Args>
149 inline const T*
test(
const Key&
key)
const;
153 inline const T*
get(
const Key&
key)
const;
236 template<
class... Args>
241 template<
class... Args>
249 template<
class... Args>
254 inline bool insert(
const Key&,
T*) =
delete;
258 inline bool insert(
const Key&
key, std::unique_ptr<T>&& ptr);
265 inline bool set(
const Key&
key,
T* ptr);
268 inline bool set(
const Key&
key, std::unique_ptr<T>&& ptr);
277 inline bool set(
const Key&
key,
const tmp<T>& ptr);
286 return this->
insert(key, std::move(ptr));
292 return this->
set(
key, std::move(ptr));
T & try_emplace(const Key &key, Args &&... args)
Like emplace_set() but will not overwrite an occupied (non-null) location.
HashPtrTable< T, Key, Hash > this_type
The template instance used for this table.
~HashPtrTable()
Destructor.
Forward iterator with const access.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
bool emplace(const Key &key, Args &&... args)
Emplace insert a new entry, not overwriting existing entries.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
bool erase(iterator &iter)
Erase entry specified by given iterator and delete the allocated pointer.
A HashTable of pointers to objects of type <T>, with deallocation management of the pointers...
A class for managing references or pointers (no reference counting)
void clear()
Clear all entries from table and delete any allocated pointers.
const T * test(const Key &key) const
Return const pointer associated with given entry or a nullptr if the key does not exist in the table...
void write(Ostream &os) const
Invoke write() on each non-null entry.
Forward iterator with non-const access.
T & emplace_set(const Key &key, Args &&... args)
Emplace set an entry, overwriting any existing entries.
autoPtr< T > release(iterator &iter)
Release ownership of the pointer and replace with a nullptr.
Istream & operator>>(Istream &, directionInfo &)
typename parent_type::const_iterator const_iterator
A HashTable similar to std::unordered_map.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
HashPtrTable()=default
Default construct with default table capacity.
OBJstream os(runTime.globalPath()/outputName)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
HashTable< T *, Key, Hash > parent_type
The template instance used for the parent HashTable.
void operator=(const this_type &rhs)
Copy assignment.
typename parent_type::iterator iterator
bool insert(const Key &, T *)=delete
No insert() with raw pointers (potential memory leaks). Use insert() with autoPtr or set() ...
Hash function class. The default definition is for primitives. Non-primitives used to hash entries on...
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
A helper class when constructing from an Istream or dictionary.
void merge(HashPtrTable< T, Key, Hash > &source)
Attempts to extract entries from source parameter and insert them into this, does not overwrite exist...
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
A class for managing temporary objects.
Foam::argList args(argc, argv)