hashedWordList Class Reference

A wordList with hashed named lookup, which can be faster in some situations than using the normal list find/found methods. More...

Inheritance diagram for hashedWordList:
[legend]
Collaboration diagram for hashedWordList:
[legend]

Public Member Functions

 hashedWordList ()=default
 Default construct an empty list. More...
 
 hashedWordList (const hashedWordList &list)
 Copy construct. More...
 
 hashedWordList (hashedWordList &&list)
 Move construct. More...
 
 hashedWordList (const wordUList &list)
 Copy construct from list of words. More...
 
 hashedWordList (const wordUList &list, bool unique)
 Copy construct from list of words, eliminating duplicates. More...
 
 hashedWordList (wordList &&list, bool unique=false)
 Move construct from list of words, optionally eliminating duplicates. More...
 
 hashedWordList (std::initializer_list< word > list)
 Construct from an initializer list. More...
 
template<class AnyType , class AnyHash >
 hashedWordList (const HashTable< AnyType, word, AnyHash > &tbl)
 Construct from the word keys of any HashTable, sorting immediately. More...
 
 hashedWordList (const label len, const char **array, bool unique=false)
 Construct from number and list of words,. More...
 
 hashedWordList (const char **array, bool unique=false)
 
 hashedWordList (Istream &is)
 Construct from Istream. More...
 
void clear ()
 Clear the list, i.e. set size to zero. More...
 
void append (const word &name, bool unique=false)
 
bool found (const word &name) const
 Search hashed values for the specified name. More...
 
const HashTable< label > & lookup () const
 Return the hash of words/indices for inspection. More...
 
void swap (hashedWordList &list)
 Swap contents. More...
 
void transfer (hashedWordList &list)
 
void transfer (wordList &list, bool unique=false)
 
void rehash () const
 Rebuild the lookup hash indices. More...
 
void rehash (bool unique)
 Rebuild the lookup hash indices, or make unique entries first. More...
 
void uniq ()
 
void sort ()
 Sort the list and rehash the indices. More...
 
const wordoperator[] (const label index) const
 Return name corresponding to specified index. More...
 
label operator[] (const word &name) const
 Return index corresponding to specified name, or -1 on failure. More...
 
bool operator() (const word &name) const
 Check hashed values for the specified name - same as found. More...
 
void operator= (const hashedWordList &list)
 Copy assignment. Rehashes the indices. More...
 
void operator= (const wordUList &list)
 Copy assignment from list of words. Rehashes the indices. More...
 
void operator= (std::initializer_list< word > list)
 Copy assignment from initializer list. Rehashes the indices. More...
 
void operator= (hashedWordList &&list)
 Move assignment operator. More...
 
void operator= (wordList &&list)
 Move assignment from list of words. Rehashes the indices. More...
 
bool contains (const word &name) const
 Deprecated(2019-01) Is the specified name found in the list? More...
 
- Public Member Functions inherited from List< word >
constexpr List () noexcept
 Default construct. More...
 
 List (const label len)
 Construct with given size. More...
 
 List (const label len, const word &val)
 Construct with given size and value for all elements. More...
 
 List (const label len, const Foam::zero)
 Construct with given size initializing all elements to zero. More...
 
 List (const Foam::one, const word &val)
 Construct with length=1, copying the value as the only content. More...
 
 List (const Foam::one, word &&val)
 Construct with length=1, moving the value as the only content. More...
 
 List (const Foam::one, const Foam::zero)
 Construct with length=1, initializing content to zero. More...
 
 List (const List< word > &a)
 Copy construct from list. More...
 
 List (const UList< word > &a)
 Copy construct contents from list. More...
 
 List (List< word > &a, bool reuse)
 Construct as copy or re-use as specified. More...
 
 List (const UList< word > &list, const labelUList &indices)
 Copy construct subset of list. More...
 
 List (const UList< word > &list, const FixedList< label, N > &indices)
 Copy construct subset of list. More...
 
 List (const FixedList< word, N > &list)
 Construct as copy of FixedList<T, N> More...
 
 List (const PtrList< word > &list)
 Construct as copy of PtrList<T> More...
 
 List (const SLList< word > &list)
 Construct as copy of SLList<T> More...
 
 List (const IndirectListBase< word, Addr > &list)
 Construct as copy of IndirectList contents. More...
 
 List (std::initializer_list< word > list)
 Construct from an initializer list. More...
 
 List (List< word > &&list)
 Move construct from List. More...
 
 List (DynamicList< word, SizeMin > &&list)
 Move construct from DynamicList. More...
 
 List (SortableList< word > &&list)
 Move construct from SortableList. More...
 
 List (SLList< word > &&list)
 Move construct from SLList. More...
 
 List (Istream &is)
 Construct from Istream. More...
 
autoPtr< List< word > > clone () const
 Clone. More...
 
 ~List ()
 Destructor. More...
 
void clear ()
 Clear the list, i.e. set size to zero. More...
 
void resize (const label len)
 Adjust allocated size of list. More...
 
void resize (const label len, const word &val)
 Adjust allocated size of list and set val for new elements. More...
 
void resize (const label newLen)
 
void resize_nocopy (const label len)
 Adjust allocated size of list without necessarily. More...
 
void setSize (const label n)
 Alias for resize() More...
 
void setSize (const label n, const word &val)
 Alias for resize() More...
 
void append (const word &val)
 Append an element at the end of the list. More...
 
void append (word &&val)
 Move append an element at the end of the list. More...
 
void append (const UList< word > &list)
 Append a List to the end of this list. More...
 
void append (const IndirectListBase< word, Addr > &list)
 Append IndirectList contents at the end of this list. More...
 
label appendUniq (const word &val)
 Append an element if not already in the list. More...
 
void transfer (List< word > &list)
 
void transfer (DynamicList< word, SizeMin > &list)
 
void transfer (SortableList< word > &list)
 
wordnewElmt (const label i)
 
void operator= (const UList< word > &a)
 Assignment to UList operator. Takes linear time. More...
 
void operator= (const List< word > &list)
 Assignment operator. Takes linear time. More...
 
void operator= (const SLList< word > &list)
 Assignment to SLList operator. Takes linear time. More...
 
void operator= (const IndirectListBase< word, Addr > &list)
 Assignment from IndirectList. Takes linear time. More...
 
void operator= (const FixedList< word, N > &list)
 Copy assignment from FixedList. More...
 
void operator= (std::initializer_list< word > list)
 Assignment to an initializer list. More...
 
void operator= (const word &val)
 Assignment of all entries to the given value. More...
 
void operator= (const Foam::zero)
 Assignment of all entries to zero. More...
 
void operator= (List< word > &&list)
 Move assignment. Takes constant time. More...
 
void operator= (DynamicList< word, SizeMin > &&list)
 Move assignment. Takes constant time. More...
 
void operator= (SortableList< word > &&list)
 Move assignment. Takes constant time. More...
 
void operator= (SLList< word > &&list)
 Move assignment. Takes constant time. More...
 
IstreamreadList (Istream &is)
 Read List from Istream, discarding contents of existing List. More...
 
IstreamreadList (Istream &is)
 
IstreamreadList (Istream &is)
 
void shallowCopy (const UList< word > &)=delete
 No shallowCopy permitted. More...
 
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type set (const label i, bool val=true)
 A bitSet::set() method for a list of bool. More...
 

Additional Inherited Members

- Public Types inherited from List< word >
typedef SubList< wordsubList
 Declare type of subList. More...
 
- Static Public Member Functions inherited from List< word >
static const List< word > & null ()
 Return a null List. More...
 

Detailed Description

A wordList with hashed named lookup, which can be faster in some situations than using the normal list find/found methods.

Source files

Definition at line 54 of file hashedWordList.H.

Constructor & Destructor Documentation

◆ hashedWordList() [1/11]

hashedWordList ( )
default

Default construct an empty list.

◆ hashedWordList() [2/11]

hashedWordList ( const hashedWordList list)
inline

Copy construct.

Definition at line 30 of file hashedWordListI.H.

◆ hashedWordList() [3/11]

hashedWordList ( hashedWordList &&  list)
inline

Move construct.

Definition at line 36 of file hashedWordListI.H.

◆ hashedWordList() [4/11]

hashedWordList ( const wordUList list)
inlineexplicit

Copy construct from list of words.

Definition at line 43 of file hashedWordListI.H.

◆ hashedWordList() [5/11]

hashedWordList ( const wordUList list,
bool  unique 
)
inline

Copy construct from list of words, eliminating duplicates.

Definition at line 49 of file hashedWordListI.H.

References hashedWordList::rehash().

Here is the call graph for this function:

◆ hashedWordList() [6/11]

hashedWordList ( wordList &&  list,
bool  unique = false 
)
inline

Move construct from list of words, optionally eliminating duplicates.

Definition at line 57 of file hashedWordListI.H.

References hashedWordList::rehash().

Here is the call graph for this function:

◆ hashedWordList() [7/11]

hashedWordList ( std::initializer_list< word list)
inline

Construct from an initializer list.

Definition at line 65 of file hashedWordListI.H.

References hashedWordList::rehash().

Here is the call graph for this function:

◆ hashedWordList() [8/11]

hashedWordList ( const HashTable< AnyType, word, AnyHash > &  tbl)
inlineexplicit

Construct from the word keys of any HashTable, sorting immediately.

This also handles a wordHashSet, which is derived from a HashTable. The result is similar to a HashTable::sortedToc.

Definition at line 75 of file hashedWordListI.H.

References HashTable< T, Key, Hash >::cbegin(), HashTable< T, Key, Hash >::cend(), Foam::BitOps::count(), and Foam::sort().

Here is the call graph for this function:

◆ hashedWordList() [9/11]

hashedWordList ( const label  len,
const char **  array,
bool  unique = false 
)

Construct from number and list of words,.

optionally eliminating duplicates

Definition at line 34 of file hashedWordList.C.

◆ hashedWordList() [10/11]

hashedWordList ( const char **  array,
bool  unique = false 
)

Construct from a nullptr-terminated list of words, optionally eliminating duplicates

Definition at line 51 of file hashedWordList.C.

◆ hashedWordList() [11/11]

hashedWordList ( Istream is)
inline

Construct from Istream.

Definition at line 93 of file hashedWordListI.H.

Member Function Documentation

◆ clear()

void clear ( )
inline

Clear the list, i.e. set size to zero.

Definition at line 101 of file hashedWordListI.H.

References List< word >::clear().

Here is the call graph for this function:

◆ append()

void append ( const word name,
bool  unique = false 
)
inline

Append an element at the end of the list, optionally avoid append if it would be a duplicate entry

Definition at line 108 of file hashedWordListI.H.

References List< word >::append(), and Foam::name().

Here is the call graph for this function:

◆ found()

bool found ( const word name) const
inline

Search hashed values for the specified name.

Definition at line 141 of file hashedWordListI.H.

References Foam::name().

Referenced by hashedWordList::contains().

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

◆ lookup()

const Foam::HashTable< Foam::label > & lookup ( ) const
inline

Return the hash of words/indices for inspection.

Definition at line 119 of file hashedWordListI.H.

◆ swap()

void swap ( hashedWordList list)
inline

Swap contents.

Definition at line 147 of file hashedWordListI.H.

◆ transfer() [1/2]

void transfer ( hashedWordList list)
inline

Transfer contents of the argument into this list and annul the argument list, optionally eliminating duplicates

Definition at line 159 of file hashedWordListI.H.

References List< word >::transfer().

Here is the call graph for this function:

◆ transfer() [2/2]

void transfer ( wordList list,
bool  unique = false 
)
inline

Transfer the contents of the argument List into this list and annul the argument list, optionally eliminating duplicates

Definition at line 166 of file hashedWordListI.H.

References List< word >::transfer().

Here is the call graph for this function:

◆ rehash() [1/2]

void rehash ( ) const

Rebuild the lookup hash indices.

Definition at line 59 of file hashedWordList.C.

References UList< T >::size().

Referenced by hashedWordList::hashedWordList(), and Foam::operator>>().

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

◆ rehash() [2/2]

void rehash ( bool  unique)
inline

Rebuild the lookup hash indices, or make unique entries first.

Definition at line 173 of file hashedWordListI.H.

◆ uniq()

void uniq ( )

Adjust the list (if needed) to eliminate duplicate entries, and rehash the indices

Definition at line 73 of file hashedWordList.C.

References Foam::BitOps::count(), and List< T >::resize().

Here is the call graph for this function:

◆ sort()

void sort ( )
inline

Sort the list and rehash the indices.

Definition at line 186 of file hashedWordListI.H.

References Foam::sort().

Here is the call graph for this function:

◆ operator[]() [1/2]

const Foam::word & operator[] ( const label  index) const
inline

Return name corresponding to specified index.

Fatal for out of range values.

Definition at line 196 of file hashedWordListI.H.

◆ operator[]() [2/2]

Foam::label operator[] ( const word name) const
inline

Return index corresponding to specified name, or -1 on failure.

Definition at line 204 of file hashedWordListI.H.

References Foam::name().

Here is the call graph for this function:

◆ operator()()

bool operator() ( const word name) const
inline

Check hashed values for the specified name - same as found.

Can be used as a unary predicate.

Definition at line 210 of file hashedWordListI.H.

References Foam::name().

Here is the call graph for this function:

◆ operator=() [1/5]

void operator= ( const hashedWordList list)
inline

Copy assignment. Rehashes the indices.

Definition at line 216 of file hashedWordListI.H.

References List< word >::operator=().

Here is the call graph for this function:

◆ operator=() [2/5]

void operator= ( const wordUList list)
inline

Copy assignment from list of words. Rehashes the indices.

Definition at line 223 of file hashedWordListI.H.

References List< word >::operator=().

Here is the call graph for this function:

◆ operator=() [3/5]

void operator= ( std::initializer_list< word list)
inline

Copy assignment from initializer list. Rehashes the indices.

Definition at line 230 of file hashedWordListI.H.

References List< word >::operator=().

Here is the call graph for this function:

◆ operator=() [4/5]

void operator= ( hashedWordList &&  list)
inline

Move assignment operator.

Definition at line 237 of file hashedWordListI.H.

References List< word >::transfer().

Here is the call graph for this function:

◆ operator=() [5/5]

void operator= ( wordList &&  list)
inline

Move assignment from list of words. Rehashes the indices.

Definition at line 244 of file hashedWordListI.H.

References List< word >::transfer().

Here is the call graph for this function:

◆ contains()

bool contains ( const word name) const
inline

Deprecated(2019-01) Is the specified name found in the list?

Deprecated:
(2019-01) - use found() method

Definition at line 186 of file hashedWordList.H.

References hashedWordList::found().

Here is the call graph for this function:

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