34template<
class T,
class Key,
class Hash>
47template<
class T,
class Key,
class Hash>
51 const const_iterator iter(this->cfind(key));
60template<
class T,
class Key,
class Hash>
64 iterator iter(this->find(key));
73template<
class T,
class Key,
class Hash>
74template<
class... Args>
84 !parent_type::contains(key)
85 && this->parent_type::set(key,
new T(std::forward<Args>(
args)...))
90template<
class T,
class Key,
class Hash>
91template<
class... Args>
92inline T& Foam::HashPtrTable<T, Key, Hash>::emplaceImpl
103 iterator iter(this->
find(key));
108 if (overwrite || !ptr)
112 ptr =
new T(std::forward<Args>(
args)...);
118 ptr =
new T(std::forward<Args>(
args)...);
119 this->parent_type::set(key, ptr);
126template<
class T,
class Key,
class Hash>
127template<
class... Args>
135 return this->emplaceImpl(
true, key, std::forward<Args>(
args)...);
139template<
class T,
class Key,
class Hash>
140template<
class... Args>
148 return this->emplaceImpl(
false, key, std::forward<Args>(
args)...);
152template<
class T,
class Key,
class Hash>
156 std::unique_ptr<T>&& ptr
159 if (parent_type::insert(key, ptr.get()))
169template<
class T,
class Key,
class Hash>
186template<
class T,
class Key,
class Hash>
194 iterator iter(this->find(key));
197 if (iter.val() != ptr)
210template<
class T,
class Key,
class Hash>
214 std::unique_ptr<T>&& ptr
217 return this->
set(key, ptr.release());
221template<
class T,
class Key,
class Hash>
228 return this->
set(key, ptr.release());
232template<
class T,
class Key,
class Hash>
239 return this->
set(key, ptr.ptr());
243template<
class T,
class Key,
class Hash>
250 return this->set(key, ptr.
ptr());
const T * get(const Key &key) const
Return const pointer associated with given entry or a nullptr if the key does not exist in the table.
typename parent_type::iterator iterator
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.
T & emplace_set(const Key &key, Args &&... args)
Emplace set an entry, overwriting any existing entries.
bool insert(const Key &, T *)=delete
No insert() with raw pointers (potential memory leaks). Use insert() with autoPtr or set().
bool set(const Key &key, T *ptr)
Assign a new entry, overwrites existing.
typename parent_type::const_iterator const_iterator
T & try_emplace(const Key &key, Args &&... args)
Like emplace_set() but will not overwrite an occupied (non-null) location.
bool emplace(const Key &key, Args &&... args)
Emplace insert a new entry, not overwriting existing entries.
bool set(const Key &key, const T &obj)
bool contains(const Key &key) const
const_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
bool insert(const Key &key, const T &obj)
iterator find(const Key &key)
Find and return an iterator set at the hashed entry.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A class for managing references or pointers (no reference counting).
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
A class for managing temporary objects.
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
label find(const ListType &input, const UnaryPredicate &pred, const label start=0)
Same as ListOps::find_if.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Foam::argList args(argc, argv)