Loading...
Searching...
No Matches
DictionaryBase< IDLListType, T > Class Template Reference

Base dictionary class templated on both the form of doubly-linked list it uses as well as the type it holds. More...

#include <DictionaryBase.H>

Inheritance diagram for DictionaryBase< IDLListType, T >:
Collaboration diagram for DictionaryBase< IDLListType, T >:

Public Member Functions

 DictionaryBase ()=default
 Default construct: empty without allocation (capacity=0).
 DictionaryBase (const label initialCapacity)
 Construct empty with initial table capacity.
 DictionaryBase (const DictionaryBase &dict)
 Copy construct.
template<class INew>
 DictionaryBase (Istream &is, const INew &inew)
 Construct from Istream using given Istream constructor class.
 DictionaryBase (Istream &is)
 Construct from Istream using default Istream constructor class.
bool contains (const word &keyword) const
 Search for given keyword.
const Tcfind (const word &keyword) const
 Find and return an entry, nullptr on failure.
Tfind (const word &keyword)
 Find and return an entry, nullptr on failure.
const Tlookup (const word &keyword) const
 Find and return entry, FatalError on failure.
Tlookup (const word &keyword)
 Find and return entry, FatalError on failure.
wordList toc () const
 The table of contents (as a sorted list).
wordList sortedToc () const
 The table of contents as a sorted list.
template<class Compare>
wordList sortedToc (const Compare &comp) const
 The table of contents sorted using the specified comparator.
void push_front (const word &keyword, T *ptr)
 Add to front of dictionary.
void push_back (const word &keyword, T *ptr)
 Add to back of dictionary.
Tremove (const word &keyword)
 Remove and return entry specified by keyword.
void clear ()
 Clear the dictionary.
void transfer (DictionaryBase< IDLListType, T > &dict)
 Transfer the contents of the argument into this DictionaryBase.
void operator= (const DictionaryBase &)
 Copy assignment.
const Toperator[] (const word &key) const
 Find and return entry.
Toperator[] (const word &key)
 Find and return entry.
bool found (const word &key) const
 Same as contains().
const TlookupPtr (const word &k) const
 Deprecated(2020-03) use cfind().
TlookupPtr (const word &k)
 Deprecated(2020-03) use find().
void insert (const word &k, T *ptr)
 Add to front of dictionary.
void prepend (const word &k, T *ptr)
 Add to front of dictionary.
void append (const word &k, T *ptr)
 Add to back of dictionary.

Protected Member Functions

bool addHashEntry (const word &key, T *ptr)
 Add an entry to the HashTable.
void addEntries ()
 Add the IDLListType entries into the HashTable.

Protected Attributes

HashTable< T * > hashedTs_
 HashTable of the entries held on the IDLListType for quick lookup.

Friends

Ostreamoperator (Ostream &, const DictionaryBase< IDLListType, T > &)

Detailed Description

template<class IDLListType, class T>
class Foam::DictionaryBase< IDLListType, T >

Base dictionary class templated on both the form of doubly-linked list it uses as well as the type it holds.

The double templating allows for the instantiation of forms with or without storage management.

Note
The IDLListType parameter should itself be a template but this confused gcc 2.95.2 so it has to be instantiated for T when an instantiation of DictionaryBase is requested
See also
Dictionary and UDictionary
Source files

Definition at line 71 of file DictionaryBase.H.

Constructor & Destructor Documentation

◆ DictionaryBase() [1/5]

template<class IDLListType, class T>
DictionaryBase ( )
default

Default construct: empty without allocation (capacity=0).

Referenced by DictionaryBase(), and operator=().

Here is the caller graph for this function:

◆ DictionaryBase() [2/5]

template<class IDLListType, class T>
DictionaryBase ( const label initialCapacity)
inlineexplicit

Construct empty with initial table capacity.

Definition at line 113 of file DictionaryBase.H.

◆ DictionaryBase() [3/5]

template<class IDLListType, class T>
DictionaryBase ( const DictionaryBase< IDLListType, T > & dict)

Copy construct.

Definition at line 39 of file DictionaryBase.C.

References addEntries(), dict, and DictionaryBase().

Here is the call graph for this function:

◆ DictionaryBase() [4/5]

template<class IDLListType, class T>
template<class INew>
DictionaryBase ( Istream & is,
const INew & inew )

Construct from Istream using given Istream constructor class.

Definition at line 52 of file DictionaryBase.C.

References addEntries().

Here is the call graph for this function:

◆ DictionaryBase() [5/5]

template<class IDLListType, class T>
DictionaryBase ( Istream & is)

Construct from Istream using default Istream constructor class.

Definition at line 65 of file DictionaryBase.C.

References addEntries().

Here is the call graph for this function:

Member Function Documentation

◆ addHashEntry()

template<class IDLListType, class T>
bool addHashEntry ( const word & key,
T * ptr )
inlineprotected

Add an entry to the HashTable.

Definition at line 90 of file DictionaryBase.H.

Referenced by PtrListDictionary< phaseModel >::set().

Here is the caller graph for this function:

◆ addEntries()

template<class IDLListType, class T>
void addEntries ( )
protected

Add the IDLListType entries into the HashTable.

Definition at line 27 of file DictionaryBase.C.

References hashedTs_.

Referenced by DictionaryBase(), DictionaryBase(), and DictionaryBase().

Here is the caller graph for this function:

◆ contains()

template<class IDLListType, class T>
bool contains ( const word & keyword) const

Search for given keyword.

Definition at line 76 of file DictionaryBase.C.

References hashedTs_.

Referenced by DictionaryBase< IDLList< T >, T >::found().

Here is the caller graph for this function:

◆ cfind()

template<class IDLListType, class T>
const T * cfind ( const word & keyword) const

Find and return an entry, nullptr on failure.

Definition at line 83 of file DictionaryBase.C.

References hashedTs_, and Foam::T().

Referenced by DictionaryBase< IDLList< T >, T >::lookupPtr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find()

template<class IDLListType, class T>
T * find ( const word & keyword)

Find and return an entry, nullptr on failure.

Definition at line 100 of file DictionaryBase.C.

References hashedTs_, and Foam::T().

Referenced by Foam::appendNamedEntry(), DictionaryBase< IDLList< T >, T >::lookupPtr(), and Time::readDict().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lookup() [1/2]

template<class IDLListType, class T>
const T * lookup ( const word & keyword) const

Find and return entry, FatalError on failure.

Definition at line 114 of file DictionaryBase.C.

References Foam::exit(), Foam::FatalError, FatalErrorInFunction, hashedTs_, and Foam::T().

Referenced by DictionaryBase< IDLList< T >, T >::operator[](), and DictionaryBase< IDLList< T >, T >::operator[]().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lookup() [2/2]

template<class IDLListType, class T>
T * lookup ( const word & keyword)

Find and return entry, FatalError on failure.

Definition at line 130 of file DictionaryBase.C.

References Foam::exit(), Foam::FatalError, FatalErrorInFunction, hashedTs_, and Foam::T().

Here is the call graph for this function:

◆ toc()

template<class IDLListType, class T>
wordList toc ( ) const
inline

The table of contents (as a sorted list).

Definition at line 167 of file DictionaryBase.H.

◆ sortedToc() [1/2]

template<class IDLListType, class T>
wordList sortedToc ( ) const
inline

The table of contents as a sorted list.

Definition at line 175 of file DictionaryBase.H.

◆ sortedToc() [2/2]

template<class IDLListType, class T>
template<class Compare>
wordList sortedToc ( const Compare & comp) const
inline

The table of contents sorted using the specified comparator.

Definition at line 184 of file DictionaryBase.H.

◆ push_front()

template<class IDLListType, class T>
void push_front ( const word & keyword,
T * ptr )

Add to front of dictionary.

Definition at line 146 of file DictionaryBase.C.

Referenced by DictionaryBase< IDLList< T >, T >::insert(), and DictionaryBase< IDLList< T >, T >::prepend().

Here is the caller graph for this function:

◆ push_back()

template<class IDLListType, class T>
void push_back ( const word & keyword,
T * ptr )

Add to back of dictionary.

Definition at line 159 of file DictionaryBase.C.

References hashedTs_, and Foam::T().

Referenced by DictionaryBase< IDLList< T >, T >::append().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove()

template<class IDLListType, class T>
T * remove ( const word & keyword)

Remove and return entry specified by keyword.

Return nullptr if the keyword was not found.

Definition at line 172 of file DictionaryBase.C.

References hashedTs_, and Foam::T().

Here is the call graph for this function:

◆ clear()

template<class IDLListType, class T>
void clear ( )

Clear the dictionary.

Definition at line 187 of file DictionaryBase.C.

References hashedTs_.

◆ transfer()

template<class IDLListType, class T>
void transfer ( DictionaryBase< IDLListType, T > & dict)

Transfer the contents of the argument into this DictionaryBase.

and annul the argument.

Definition at line 195 of file DictionaryBase.C.

◆ operator=()

template<class IDLListType, class T>
void operator= ( const DictionaryBase< IDLListType, T > & )

Copy assignment.

Definition at line 213 of file DictionaryBase.C.

References dict, DictionaryBase(), and operator.

Here is the call graph for this function:

◆ operator[]() [1/2]

template<class IDLListType, class T>
const T * operator[] ( const word & key) const
inline

Find and return entry.

Definition at line 232 of file DictionaryBase.H.

◆ operator[]() [2/2]

template<class IDLListType, class T>
T * operator[] ( const word & key)
inline

Find and return entry.

Definition at line 240 of file DictionaryBase.H.

◆ found()

template<class IDLListType, class T>
bool found ( const word & key) const
inline

Same as contains().

Definition at line 260 of file DictionaryBase.H.

◆ lookupPtr() [1/2]

template<class IDLListType, class T>
const T * lookupPtr ( const word & k) const
inline

Deprecated(2020-03) use cfind().

Deprecated
(2020-03) - use cfind() method

Definition at line 268 of file DictionaryBase.H.

◆ lookupPtr() [2/2]

template<class IDLListType, class T>
T * lookupPtr ( const word & k)
inline

Deprecated(2020-03) use find().

Deprecated
(2020-03) - use find() method

Definition at line 276 of file DictionaryBase.H.

◆ insert()

template<class IDLListType, class T>
void insert ( const word & k,
T * ptr )
inline

Add to front of dictionary.

FOAM_DEPRECATED_FOR(2022-10, "push_front()")

Definition at line 283 of file DictionaryBase.H.

◆ prepend()

template<class IDLListType, class T>
void prepend ( const word & k,
T * ptr )
inline

Add to front of dictionary.

FOAM_DEPRECATED_FOR(2022-10, "push_front()")

Definition at line 290 of file DictionaryBase.H.

◆ append()

template<class IDLListType, class T>
void append ( const word & k,
T * ptr )
inline

Add to back of dictionary.

FOAM_DEPRECATED_FOR(2022-10, "push_back()")

Definition at line 297 of file DictionaryBase.H.

Referenced by Foam::appendNamedEntry().

Here is the caller graph for this function:

◆ operator

template<class IDLListType, class T>
Ostream & operator ( Ostream & ,
const DictionaryBase< IDLListType, T > &  )
friend

Referenced by operator=().

Member Data Documentation

◆ hashedTs_

template<class IDLListType, class T>
HashTable<T*> hashedTs_
protected

HashTable of the entries held on the IDLListType for quick lookup.

Definition at line 82 of file DictionaryBase.H.

Referenced by addEntries(), cfind(), clear(), contains(), find(), lookup(), lookup(), push_back(), and remove().


The documentation for this class was generated from the following files: