Public Types | Public Member Functions | List of all members
HashSet< Key, Hash > Class Template Reference

A HashTable with keys but without contents. More...

Inheritance diagram for HashSet< Key, Hash >:
Inheritance graph
[legend]
Collaboration diagram for HashSet< Key, Hash >:
Collaboration graph
[legend]

Public Types

typedef HashTable< nil, Key, Hash >::iterator iterator
 
typedef HashTable< nil, Key, Hash >::const_iterator const_iterator
 
- Public Types inherited from HashTable< nil, Key, Hash >
typedef nil value_type
 Type of values the HashTable contains. More...
 
typedef nilreference
 Type that can be used for storing into HashTable::value_type. More...
 
typedef const nilconst_reference
 Type that can be used for storing into constant. More...
 
typedef label size_type
 The type that can represent the size of a HashTable. More...
 

Public Member Functions

 HashSet (const label size=128)
 Construct given initial size. More...
 
 HashSet (Istream &is)
 Construct from Istream. More...
 
 HashSet (const UList< Key > &)
 Construct from UList of Key. More...
 
 HashSet (const HashSet< Key, Hash > &hs)
 Construct as copy. More...
 
 HashSet (const Xfer< HashSet< Key, Hash > > &hs)
 Construct by transferring the parameter contents. More...
 
 HashSet (const Xfer< HashTable< nil, Key, Hash > > &hs)
 Construct by transferring the parameter contents. More...
 
template<class AnyType , class AnyHash >
 HashSet (const HashTable< AnyType, Key, AnyHash > &)
 Construct from the keys of another HashTable,. More...
 
bool insert (const Key &key)
 Insert a new entry. More...
 
label insert (const UList< Key > &)
 Insert keys from a UList of Key. More...
 
bool set (const Key &key)
 Same as insert (cannot overwrite nil content) More...
 
label set (const UList< Key > &lst)
 Same as insert (cannot overwrite nil content) More...
 
bool unset (const Key &key)
 Unset the specified key - same as erase. More...
 
bool operator[] (const Key &) const
 Return true if the entry exists, same as found() More...
 
bool operator== (const HashSet< Key, Hash > &) const
 Equality. Two hashtables are equal when their contents are equal. More...
 
bool operator!= (const HashSet< Key, Hash > &) const
 The opposite of the equality operation. More...
 
void operator|= (const HashSet< Key, Hash > &)
 Combine entries from HashSets. More...
 
void operator&= (const HashSet< Key, Hash > &)
 Only retain entries found in both HashSets. More...
 
void operator^= (const HashSet< Key, Hash > &)
 Only retain unique entries (xor) More...
 
void operator+= (const HashSet< Key, Hash > &rhs)
 Add entries listed in the given HashSet to this HashSet. More...
 
void operator-= (const HashSet< Key, Hash > &)
 Remove entries listed in the given HashSet from this HashSet. More...
 
- Public Member Functions inherited from HashTable< nil, Key, Hash >
bool set (const Key &, const nil &newElmt)
 Assign a new hashedEntry, overwriting existing entries. More...
 
 HashTable (const label size=128)
 Construct given initial table size. More...
 
 HashTable (Istream &, const label size=128)
 Construct from Istream. More...
 
 HashTable (const HashTable< nil, Key, Hash > &)
 Construct as copy. More...
 
 HashTable (const Xfer< HashTable< nil, Key, Hash > > &)
 Construct by transferring the parameter contents. More...
 
 ~HashTable ()
 Destructor. More...
 
label capacity () const
 The size of the underlying table. More...
 
label size () const
 Return number of elements in table. More...
 
bool empty () const
 Return true if the hash table is empty. More...
 
bool found (const Key &) const
 Return true if hashedEntry is found in table. More...
 
iterator find (const Key &)
 Find and return an iterator set at the hashedEntry. More...
 
const_iterator find (const Key &) const
 Find and return an const_iterator set at the hashedEntry. More...
 
List< Key > toc () const
 Return the table of contents. More...
 
List< Key > sortedToc () const
 Return the table of contents as a sorted list. More...
 
OstreamprintInfo (Ostream &) const
 Print information. More...
 
bool insert (const Key &, const nil &newElmt)
 Insert a new hashedEntry. More...
 
bool erase (const iterator &)
 Erase a hashedEntry specified by given iterator. More...
 
bool erase (const Key &)
 Erase a hashedEntry specified by the given key. More...
 
label erase (const UList< Key > &)
 Remove entries given by the listed keys from this HashTable. More...
 
label erase (const HashTable< AnyType, Key, AnyHash > &)
 Remove entries given by the given keys from this HashTable. More...
 
void resize (const label newSize)
 Resize the hash table for efficiency. More...
 
void clear ()
 Clear all entries from table. More...
 
void clearStorage ()
 Clear the table entries and the table itself. More...
 
void shrink ()
 Shrink the allocated table to approx. twice number of elements. More...
 
void transfer (HashTable< nil, Key, Hash > &)
 Transfer the contents of the argument table into this table. More...
 
Xfer< HashTable< nil, Key, Hash > > xfer ()
 Transfer contents to the Xfer container. More...
 
niloperator[] (const Key &)
 Find and return a hashedEntry. More...
 
const niloperator[] (const Key &) const
 Find and return a hashedEntry. More...
 
niloperator() (const Key &)
 Find and return a hashedEntry, create it null if not present. More...
 
void operator= (const HashTable< nil, Key, Hash > &)
 Assignment. More...
 
bool operator== (const HashTable< nil, Key, Hash > &) const
 Equality. Hash tables are equal if the keys and values are equal. More...
 
bool operator!= (const HashTable< nil, Key, Hash > &) const
 The opposite of the equality operation. Takes linear time. More...
 
iterator begin ()
 Iterator set to the beginning of the HashTable. More...
 
const_iterator begin () const
 const_iterator set to the beginning of the HashTable More...
 
const_iterator cbegin () const
 const_iterator set to the beginning of the HashTable More...
 
- Public Member Functions inherited from HashTableCore
 HashTableCore ()
 Construct null. More...
 
 ClassName ("HashTable")
 Define template name and debug. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from HashTableCore
static label canonicalSize (const label)
 Return a canonical (power-of-two) size. More...
 
static iteratorEnd cend ()
 iteratorEnd set to beyond the end of any HashTable More...
 
static iteratorEnd end ()
 iteratorEnd set to beyond the end of any HashTable More...
 
- Static Public Attributes inherited from HashTableCore
static const label maxTableSize
 Maximum allowable table size. More...
 

Detailed Description

template<class Key = word, class Hash = string::hash>
class Foam::HashSet< Key, Hash >

A HashTable with keys but without contents.

Definition at line 59 of file HashSet.H.

Member Typedef Documentation

typedef HashTable<nil, Key, Hash>::iterator iterator

Definition at line 66 of file HashSet.H.

Definition at line 67 of file HashSet.H.

Constructor & Destructor Documentation

HashSet ( const label  size = 128)
inline

Construct given initial size.

Definition at line 73 of file HashSet.H.

Referenced by HashSet< Foam::word >::HashSet(), and HashSet< Key, Hash >::HashSet().

Here is the caller graph for this function:

HashSet ( Istream is)
inline

Construct from Istream.

Definition at line 79 of file HashSet.H.

HashSet ( const UList< Key > &  lst)

Construct from UList of Key.

Definition at line 34 of file HashSet.C.

References forAll, HashSet< Key, Hash >::HashSet(), and HashSet< Key, Hash >::insert().

Here is the call graph for this function:

HashSet ( const HashSet< Key, Hash > &  hs)
inline

Construct as copy.

Definition at line 88 of file HashSet.H.

HashSet ( const Xfer< HashSet< Key, Hash > > &  hs)
inline

Construct by transferring the parameter contents.

Definition at line 94 of file HashSet.H.

HashSet ( const Xfer< HashTable< nil, Key, Hash > > &  hs)
inline

Construct by transferring the parameter contents.

Definition at line 100 of file HashSet.H.

HashSet ( const HashTable< AnyType, Key, AnyHash > &  h)

Construct from the keys of another HashTable,.

the type of values held is arbitrary.

Definition at line 48 of file HashSet.C.

References HashTable< T, Key, Hash >::cbegin(), HashTableCore::cend(), and HashSet< Key, Hash >::insert().

Here is the call graph for this function:

Member Function Documentation

bool insert ( const Key &  key)
inline

Insert a new entry.

Definition at line 116 of file HashSet.H.

Referenced by autoLayerDriver::addLayers(), polyTopoChange::addPoint(), polyMeshGeometry::affectedCells(), decompositionMethod::calcCellCells(), cellToFaceStencil::calcFaceStencil(), primitiveMesh::cellEdges(), cellFeatures::cellFeatures(), primitiveMesh::cellPoints(), primitiveMeshGeometry::checkCellDeterminant(), polyMeshGeometry::checkCellDeterminant(), primitiveMesh::checkCellsZipUp(), primitiveMesh::checkCellVolumes(), primitiveMesh::checkClosedCells(), primitiveMesh::checkCommonOrder(), primitiveMesh::checkConcaveCells(), zone::checkDefinition(), polyBoundaryMesh::checkDefinition(), primitiveMesh::checkDuplicateFaces(), primitiveMesh::checkEdgeLength(), primitiveMeshGeometry::checkFaceAngles(), polyMeshGeometry::checkFaceAngles(), primitiveMesh::checkFaceAngles(), primitiveMeshGeometry::checkFaceArea(), polyMeshGeometry::checkFaceArea(), primitiveMesh::checkFaceAreas(), primitiveMeshGeometry::checkFaceDotProduct(), polyMeshGeometry::checkFaceFlatness(), primitiveMesh::checkFaceFlatness(), primitiveMesh::checkFaceOrthogonality(), primitiveMeshGeometry::checkFacePyramids(), polyMeshGeometry::checkFacePyramids(), primitiveMesh::checkFacePyramids(), primitiveMeshGeometry::checkFaceSkewness(), polyMeshGeometry::checkFaceSkewness(), primitiveMesh::checkFaceSkewness(), polyMeshTetDecomposition::checkFaceTets(), polyMeshGeometry::checkFaceTets(), primitiveMeshGeometry::checkFaceTwist(), polyMeshGeometry::checkFaceTwist(), primitiveMesh::checkFaceVertices(), primitiveMeshGeometry::checkFaceWeights(), polyMeshGeometry::checkFaceWeights(), edgeCollapser::checkMeshQuality(), PatchTools::checkOrientation(), PrimitivePatch< Face, FaceList, PointField, PointType >::checkPointManifold(), primitiveMesh::checkPointNearness(), primitiveMesh::checkPoints(), PrimitivePatch< Face, FaceList, PointField, PointType >::checkTopology(), polyMeshGeometry::checkTriangleTwist(), primitiveMesh::checkUpperTriangular(), polyMeshGeometry::checkVolRatio(), meshRefinement::createBaffles(), geomCellLooper::cut(), structuredDecomp::decompose(), dynamicRefineFvMesh::dynamicRefineFvMesh(), polyBoundaryMesh::findIndices(), indexedOctree< Type >::findLine(), dynamicIndexedOctree< Type >::findNearest(), combineFaces::getMergeSets(), Foam::vtkPV4Readers::getSelected(), Foam::vtkPV3Readers::getSelected(), surfaceSets::getSurfaceSets(), triSurfaceTools::getVertexVertices(), HashSet< Key, Hash >::HashSet(), HashSet< Foam::word >::insert(), HashSet< Key, Hash >::insert(), cellToCellStencil::insertFaceCells(), cellToFaceStencil::insertFaceCells(), polyTopoChange::modifyPoint(), NamedEnum< Enum, nEnum >::names(), HashSet< Key, Hash >::operator^=(), HashSet< Key, Hash >::operator|=(), InflationInjection< CloudType >::parcelsToInject(), Foam::parseNASCoord(), ParticleErosion< CloudType >::ParticleErosion(), PatchPostProcessing< CloudType >::PatchPostProcessing(), polyBoundaryMesh::patchSet(), Foam::polyMeshZipUpCells(), probes::prepare(), NASsurfaceFormat< Face >::read(), wallShearStress::read(), structuredRenumber::renumber(), faceAreaWeightAMI< SourcePatch, TargetPatch >::restartUncoveredSourceFace(), motionSmootherAlgo::scaleMesh(), mapDistribute::schedule(), HashSet< Foam::word >::set(), cellSetOption::setCellSet(), removePoints::setRefinement(), surfaceIntersection::surfaceIntersection(), pointSet::sync(), and topoSet::updateLabels().

Foam::label insert ( const UList< Key > &  lst)

Insert keys from a UList of Key.

Return the number of new elements inserted

Definition at line 70 of file HashSet.C.

References forAll, and HashSet< Key, Hash >::insert().

Here is the call graph for this function:

bool set ( const Key &  key)
inline

Same as insert (cannot overwrite nil content)

Definition at line 126 of file HashSet.H.

label set ( const UList< Key > &  lst)
inline

Same as insert (cannot overwrite nil content)

Definition at line 132 of file HashSet.H.

bool unset ( const Key &  key)
inline

Unset the specified key - same as erase.

Definition at line 138 of file HashSet.H.

bool operator[] ( const Key &  key) const
inline

Return true if the entry exists, same as found()

Definition at line 88 of file HashSet.C.

References HashTable< nil, Key, Hash >::found().

Referenced by HashSet< Foam::word >::unset().

Here is the call graph for this function:

Here is the caller graph for this function:

bool operator== ( const HashSet< Key, Hash > &  rhs) const

Equality. Two hashtables are equal when their contents are equal.

Independent of table size or order.

Definition at line 95 of file HashSet.C.

References HashTable< nil, Key, Hash >::cbegin(), HashTableCore::cend(), and HashTable< nil, Key, Hash >::found().

Referenced by HashSet< Key, Hash >::operator!=(), and HashSet< Foam::word >::unset().

Here is the call graph for this function:

Here is the caller graph for this function:

bool operator!= ( const HashSet< Key, Hash > &  rhs) const

The opposite of the equality operation.

Definition at line 120 of file HashSet.C.

References HashSet< Key, Hash >::operator==().

Referenced by HashSet< Foam::word >::unset().

Here is the call graph for this function:

Here is the caller graph for this function:

void operator|= ( const HashSet< Key, Hash > &  rhs)

Combine entries from HashSets.

Definition at line 127 of file HashSet.C.

References HashTable< nil, Key, Hash >::cbegin(), HashTableCore::cend(), and HashSet< Key, Hash >::insert().

Referenced by HashSet< Foam::word >::operator+=(), and HashSet< Foam::word >::unset().

Here is the call graph for this function:

Here is the caller graph for this function:

void operator&= ( const HashSet< Key, Hash > &  rhs)

Only retain entries found in both HashSets.

Definition at line 138 of file HashSet.C.

References HashTable< nil, Key, Hash >::begin(), HashTableCore::end(), HashTable< nil, Key, Hash >::erase(), and HashTable< nil, Key, Hash >::found().

Referenced by HashSet< Foam::word >::unset().

Here is the call graph for this function:

Here is the caller graph for this function:

void operator^= ( const HashSet< Key, Hash > &  rhs)

Only retain unique entries (xor)

Definition at line 152 of file HashSet.C.

References HashTable< nil, Key, Hash >::cbegin(), HashTableCore::cend(), HashTable< nil, Key, Hash >::erase(), HashTable< nil, Key, Hash >::found(), and HashSet< Key, Hash >::insert().

Referenced by HashSet< Foam::word >::unset().

Here is the call graph for this function:

Here is the caller graph for this function:

void operator+= ( const HashSet< Key, Hash > &  rhs)
inline

Add entries listed in the given HashSet to this HashSet.

Definition at line 167 of file HashSet.H.

void operator-= ( const HashSet< Key, Hash > &  rhs)

Remove entries listed in the given HashSet from this HashSet.

Definition at line 171 of file HashSet.C.

References HashTable< nil, Key, Hash >::cbegin(), HashTableCore::cend(), and HashTable< nil, Key, Hash >::erase().

Referenced by HashSet< Foam::word >::operator+=().

Here is the call graph for this function:

Here is the caller graph for this function:


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