HashSet< T, HASH, ENTRY_HANDLER, ALLOCATOR, MODE, INITIAL_CAPACITY, LOAD_FACTOR > Class Template Reference Data Structures

#include <hashmap.h>

Inheritance diagram for HashSet< T, HASH, ENTRY_HANDLER, ALLOCATOR, MODE, INITIAL_CAPACITY, LOAD_FACTOR >:

详细描述

template<typename T, typename HASH = DefaultCompare, typename ENTRY_HANDLER = HashMapKeyValuePair, typename ALLOCATOR = DefaultAllocator, HASHMAP_MODE MODE = HASHMAP_MODE::DEFAULT, Int INITIAL_CAPACITY = 16, Int LOAD_FACTOR = (MODE == HASHMAP_MODE::SYNCHRONIZED) ? 0 : 10>
class maxon::HashSet< T, HASH, ENTRY_HANDLER, ALLOCATOR, MODE, INITIAL_CAPACITY, LOAD_FACTOR >

A HashSet is an implementation of a set based on hash codes for the elements. Internally, it is just a HashMap with no values. See HashMap for the details of hash code computation, load factors, performance etc.

This example shows the basic usage of HashSet :

HashSet<String> names; if (!names.Insert( "Alice" _s)) ... allocation failed ...;
Bool added = false ; if (!names.Insert( "Bob" _s, added)) ... allocation failed ...; if (added) ... "Bob" didn 't exist before in names ...; if (names.Contains("Cindy"_s)) ... "Cindy" is in the set ...; names.Erase("Bob"_s);

To iterate over the entries of a HashSet , use Iterator, ConstIterator or a ranged-based for loop:

for ( HashSet<String>::ConstIterator i = names.Begin(); i != names.End(); ++i) { DiagnosticOutput ( "Names contains @ " , *i); } for ( const String & n : names) { DiagnosticOutput ( "Names contains @ " , n); }
Template Parameters
T Type of elements of the set.
HASH Class to be used to compute the hash code of elements, and to compare elements for equality ( DefaultCompare by default)
ENTRY_HANDLER Use this class to select the memory layout of entries (either the default HashMapKeyValuePair or HashMapKeyHashValuePair ).
ALLOCATOR Class for memory allocation.
另请参阅
HashMap
$ref sets

Classes

struct   LambdaEntryConstructor

Public Types

using  MapType = HashMap < T, UnitType , HASH, ENTRY_HANDLER, ALLOCATOR, MODE, INITIAL_CAPACITY, LOAD_FACTOR >
using  Super = SetBase < HashSet , T, Protected < MapType >, HASH >
using  IsHashMap = std::true_type
using  IsHashSet = std::true_type
using  Iterator = typename Super::KeyIterator
using  ConstIterator = typename Super::ConstKeyIterator
-  Public Types inherited from SetBase0< HashSet< T, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 >, T, Protected< HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 > >, DefaultCompare >
using  SetType = HashSet < T, DefaultCompare , HashMapKeyValuePair , DefaultAllocator , HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT== HASHMAP_MODE::SYNCHRONIZED ) ? 0 :10 >
-  Public Types inherited from Collection< HashSet< T, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 >, T, Protected< HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 > > >
using  Super = BaseCollection < HashSet < T, DefaultCompare , HashMapKeyValuePair , DefaultAllocator , HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT== HASHMAP_MODE::SYNCHRONIZED ) ? 0 :10 >, Protected < HashMap < T, UnitType , DefaultCompare , HashMapKeyValuePair , DefaultAllocator , HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT== HASHMAP_MODE::SYNCHRONIZED ) ? 0 :10 > > >
using  ValueType = T
-  Public Types inherited from BaseCollection< HashSet< T, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 >, Protected< HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 > > >
using  IsCollection = std::true_type

公共成员函数

  HashSet (const ALLOCATOR &alloc)
  HashSet ()=default
  HashSet ( HashSet && src )
  MAXON_OPERATOR_MOVE_ASSIGNMENT ( HashSet )
HashInt   GetHashCode () const
MapType GetMap ()
const MapType GetMap () const
Bool   Contains (typename ByValueParam < T >:: type value) const
template<typename KEY , typename KEYHASH >
Bool   Contains (const KEY &key) const
void  Insert () const
ResultRef < typename Super::Entry >  Insert (const T &value, Bool &added= BoolLValue ())
ResultRef < typename Super::Entry >  Insert (T &&value, Bool &added= BoolLValue ())
ResultRef < const T >  InsertKey (const T &value, Bool &added= BoolLValue ())
ResultRef < const T >  InsertKey (T &&value, Bool &added= BoolLValue ())
template<typename KEYHASH = HASH, typename KEY , typename LAMBDA >
Result < Entry * >  InsertLambda (KEY &&key, LAMBDA &&lambda)
ResultOk < Bool Erase (const T &value)
ResultOk < void >  Erase (const Entry *entry)
ConstIterator   Begin () const
ConstIterator   End () const
Iterator   Begin ()
Iterator   End ()
Iterator   Erase (const Iterator &it)
template<typename KEYHASH = HASH, typename KEY >
Entry *  Find (const KEY &key)
template<typename KEYHASH = HASH, typename KEY >
const Entry *  Find (const KEY &key) const
ResultRef < Entry >  InsertEntry (const K &key, Bool &created= BoolLValue ())
ResultRef < Entry >  InsertEntry (K &&key, Bool &created= BoolLValue ())
template<typename KEYHASH = HASH, typename KEY >
ResultRef < Entry >  InsertEntry (KEY &&key, Bool &created= BoolLValue ())
template<typename KEYHASH = HASH, typename KEY , typename C >
Result < Entry * >  InsertCtor (KEY &&key, C &&constructor, Bool &created= BoolLValue ())
Int   GetCount () const
Int   GetOperationCountForSearch () const
ResultMem   SetCapacityHint ( Int capacity, COLLECTION_RESIZE_FLAGS resizeFlags= COLLECTION_RESIZE_FLAGS::ON_GROW_RESERVE_CAPACITY )
ResultMem   ResizeTable ( Int capacity)
void  重置 ()
void  Flush ()
template<typename SET >
Result < void >  IntersectImpl (SET &&set, OverloadRank0 )
Int   GetMemorySize () const
-  Public Member Functions inherited from SetBase< HashSet< T, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 >, T, Protected< HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 > >, DefaultCompare >
MAXON_ATTRIBUTE_FORCE_INLINE   SetBase (ARGS &&... args)
SetImpl < HashSet < T, DefaultCompare , HashMapKeyValuePair , DefaultAllocator , HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT== HASHMAP_MODE::SYNCHRONIZED ) ? 0 :10 > & >  ToSet ()
SetImpl < const HashSet < T, DefaultCompare , HashMapKeyValuePair , DefaultAllocator , HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT== HASHMAP_MODE::SYNCHRONIZED ) ? 0 :10 > & >  ToSet () const
MAXON_ATTRIBUTE_FORCE_INLINE   operator SetImpl< HashSet< T, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 > & > ()
MAXON_ATTRIBUTE_FORCE_INLINE   operator SetImpl< const HashSet< T, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 > & > () const
-  Public Member Functions inherited from SetBase0< HashSet< T, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 >, T, Protected< HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 > >, DefaultCompare >
MAXON_ATTRIBUTE_FORCE_INLINE   SetBase0 (ARGS &&... args)
MAXON_ATTRIBUTE_FORCE_INLINE ResultRef < const T >  Append (typename ByValueParam < T >:: type v)
Bool   ContainsAllImpl (COLLECTION2 &&other, OverloadRank0 ) const
MAXON_ATTRIBUTE_FORCE_INLINE Result < void >  添加 (COLLECTION2 &&other, COLLECTION_RESIZE_FLAGS resizeFlags= COLLECTION_RESIZE_FLAGS::ON_GROW_RESERVE_CAPACITY )
MAXON_ATTRIBUTE_FORCE_INLINE Result < void >  AppendAll (COLLECTION2 &&other, COLLECTION_RESIZE_FLAGS resizeFlags= COLLECTION_RESIZE_FLAGS::ON_GROW_RESERVE_CAPACITY )
MAXON_ATTRIBUTE_FORCE_INLINE Result < void >  CopyFrom (COLLECTION2 &&other, COLLECTION_RESIZE_FLAGS resizeFlags= COLLECTION_RESIZE_FLAGS::FIT_TO_SIZE )
Result < void >  SubtractImpl (COLLECTION2 &&other, OverloadRank0 )
Bool   IsEqualImpl (const COLLECTION2 &other, COMPARE &&cmp, OverloadRank0 ) const
HashInt   GetHashCode () const
-  Public Member Functions inherited from Collection< HashSet< T, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 >, T, Protected< HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 > > >
MAXON_ATTRIBUTE_FORCE_INLINE   Collection (ARGS &&... args)
ResultOk < void >  VariadicAppend ()
Result < void >  VariadicAppend (V &&value, VALUES &&... rest)
  operator ValueReceiver< const T & > ()
  operator ValueReceiver< T && > ()
  operator ValueReceiver< typename std::conditional< STD_IS_REPLACEMENT (scalar, T)
DummyParamType &  type ()
Result < Bool ForEach (FN &&callback) const
Result < Bool ForEach (FN &&callback)
H::Iterator  Find (typename ByValueParam < T >:: type v)
H::ConstIterator  Find (typename ByValueParam < T >:: type v) const
Int   FindIndex (typename ByValueParam < T >:: type v) const
MAXON_ATTRIBUTE_FORCE_INLINE Bool   Contains (typename ByValueParam < T >:: type v) const
-  Public Member Functions inherited from BaseCollection< HashSet< T, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 >, Protected< HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 > > >
MAXON_ATTRIBUTE_FORCE_INLINE   BaseCollection (ARGS &&... args)
MAXON_ATTRIBUTE_FORCE_INLINE std::enable_if< maxon::IsCollection< COLLECTION2 >::value, Bool >::type  operator== (const COLLECTION2 &other) const
MAXON_ATTRIBUTE_FORCE_INLINE std::enable_if< maxon::IsCollection< COLLECTION2 >::value, Bool >::type  operator!= (const COLLECTION2 &other) const
MAXON_ATTRIBUTE_FORCE_INLINE std::enable_if< maxon::IsCollection< COLLECTION2 >::value &&! STD_IS_REPLACEMENT (same, typename std::decay< COMPARE >::type, EQUALITY ), Bool >::type  IsEqual (const COLLECTION2 &other, COMPARE &&cmp=COMPARE()) const
MAXON_ATTRIBUTE_FORCE_INLINE Result < void >  AppendAll (COLLECTION2 &&other, COLLECTION_RESIZE_FLAGS resizeFlags= COLLECTION_RESIZE_FLAGS::ON_GROW_RESERVE_CAPACITY )
MAXON_ATTRIBUTE_FORCE_INLINE Result < void >  CopyFrom (COLLECTION2 &&other, COLLECTION_RESIZE_FLAGS resizeFlags= COLLECTION_RESIZE_FLAGS::FIT_TO_SIZE )
MAXON_ATTRIBUTE_FORCE_INLINE Result < void >  Subtract (COLLECTION2 &&other)
MAXON_ATTRIBUTE_FORCE_INLINE Result < void >  Intersect (const COLLECTION2 &other)
Bool   Intersects (const COLLECTION2 &other) const
MAXON_ATTRIBUTE_FORCE_INLINE Result < void >  CopyFromImpl (COLLECTION2 &&other, COLLECTION_RESIZE_FLAGS resizeFlags, OverloadRank0 )
Result < void >  AppendAllImpl (COLLECTION2 &&other, COLLECTION_RESIZE_FLAGS resizeFlags, Bool overwrite, OverloadRank0 )
Result < void >  IntersectImpl (COLLECTION2 &&other, OverloadRank0 )
MAXON_ATTRIBUTE_FORCE_INLINE Bool   IsEmpty () const
MAXON_ATTRIBUTE_FORCE_INLINE Bool   IsPopulated () const
String   ToString (const FormatStatement *formatStatement=nullptr) const
MAXON_ATTRIBUTE_FORCE_INLINE Bool   ContainsAll (COLLECTION2 &&other) const
Bool   ContainsAllImpl (COLLECTION2 &&other, OverloadRank0 ) const
-  Public Member Functions inherited from Protected< HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 > >
  __attribute__ ((always_inline)) explicit Protected (ARGS &&... args)

Public Attributes

friend  MapType
-  Public Attributes inherited from Collection< HashSet< T, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 >, T, Protected< HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 > > >
  VALUETYPE

私有成员函数

  MAXON_DISALLOW_COPY_AND_ASSIGN ( HashSet )

Additional Inherited Members

-  Static Public Member Functions inherited from Collection< HashSet< T, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 >, T, Protected< HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 > > >
static const T &  GetMapKey (const T &key)
-  Static Public Attributes inherited from SetBase0< HashSet< T, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 >, T, Protected< HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 > >, DefaultCompare >
static const COLLECTION_KIND   KIND
-  Protected Types inherited from HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 >
using  Bucket = typename std::conditional< MODE ==HASHMAP_MODE::DEFAULT, DefaultBucket, SimpleBucket >::type
using  Super = MapBase < HashMap , T, UnitType , EmptyClass , DefaultCompare >
using  HashType = DefaultCompare
using  IsHashMap = std::true_type
using  Iterator = IteratorTemplate< EntryIteratorBase >
using  ConstIterator = ConstIteratorTemplate< EntryIteratorBase >
using  KeyIterator = IteratorTemplate< KeyIteratorBase >
using  ConstKeyIterator = ConstIteratorTemplate< KeyIteratorBase >
using  ValueIterator = IteratorTemplate< ValueIteratorBase >
using  ConstValueIterator = ConstIteratorTemplate< ValueIteratorBase >
-  Protected Types inherited from MapBase0< HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, MODE, INITIAL_CAPACITY, LOAD_FACTOR >, T, UnitType, EmptyClass, DefaultCompare >
using  MapType = HashMap < T, UnitType , DefaultCompare , HashMapKeyValuePair , DefaultAllocator , MODE , INITIAL_CAPACITY, LOAD_FACTOR >
using  Super = BaseCollection < HashMap < T, UnitType , DefaultCompare , HashMapKeyValuePair , DefaultAllocator , MODE , INITIAL_CAPACITY, LOAD_FACTOR >, EmptyClass >
using  KeyType = T
using  ValueType = UnitType
-  Protected Types inherited from BaseCollection< HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, MODE, INITIAL_CAPACITY, LOAD_FACTOR >, EmptyClass >
using  IsCollection = std::true_type
-  Protected Member Functions inherited from HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 >
Bool   ResizeTableImpl ( Int length)
Entry *  AddEntryImpl (Entry *e, Entry *prev, Bool &created, Bool multi, void *)
Entry *  AddEntryImpl (Entry *e, Entry *prev, Bool &created, Bool multi, Char *)
  MAXON_DISALLOW_COPY_AND_ASSIGN ( HashMap )
const Char GetSignature (void *) const
const Char GetSignature ( Char *) const
  HashMap ()
  HashMap (const DefaultAllocator &alloc)
  HashMap ( HashMap &&src)
  ~HashMap ()
  MAXON_OPERATOR_MOVE_ASSIGNMENT ( HashMap )
ResultMem   SetCapacityHint ( Int capacity, COLLECTION_RESIZE_FLAGS resizeFlags= COLLECTION_RESIZE_FLAGS::ON_GROW_RESERVE_CAPACITY )
ResultMem   ResizeTable ( Int capacity)
void  重置 ()
void  Flush ()
Int   GetCount () const
Int   GetTableSize () const
Int   GetMemorySize () const
Int   GetNonEmptyBucketCount () const
Entry *  GetNonEmptyBucket ( Int i)
const Entry *  GetNonEmptyBucket ( Int i) const
Int   GetOperationCountForSearch () const
SFINAEHelper < Bool , typename MAP::IsHashMap >::type  IsEqualImpl (const MAP &other, COMPARE &&cmp, OverloadRank1 ) const
Entry *  Find (const KEY &key)
const Entry *  Find (const KEY &key) const
UnitType FindValue (const KEY &key)
const UnitType FindValue (const KEY &key) const
Result < Entry * >  InsertCtor ( KEY &&key, C &&constructor, Bool &created= BoolLValue ())
ResultRef < Entry >  InsertEntry (const T &key, Bool &created= BoolLValue ())
ResultRef < Entry >  InsertEntry (T &&key, Bool &created= BoolLValue ())
ResultRef < Entry >  InsertEntry ( KEY &&key, Bool &created= BoolLValue ())
ResultRef < UnitType InsertKey (const T &key, Bool &created= BoolLValue ())
ResultRef < UnitType InsertKey (T &&key, Bool &created= BoolLValue ())
ResultRef < UnitType InsertKey ( KEY &&key, Bool &created= BoolLValue ())
Result < Entry * >  InsertLambda ( KEY &&key, LAMBDA &&lambda)
ResultRef < Entry >  Insert ( KEY &&key, const UnitType &value, Bool &created= BoolLValue ())
ResultRef < Entry >  Insert ( KEY &&key, UnitType &&value, Bool &created= BoolLValue ())
ResultRef < Entry >  InsertMultiEntry ( KEY &&key)
ResultMem   InsertMultiEntry (Entry *e, UInt hash)
ResultOk < void >  Erase (const Entry *entry, Bool deleteEntry=true)
ResultOk < void >  Erase (Entry *entry, Bool deleteEntry=true)
ResultOk < void >  Erase (const Entry &entry, Bool deleteEntry=true)
ResultOk < void >  Erase (Entry &entry, Bool deleteEntry=true)
ResultOk < Bool Erase (const KEY &key)
IteratorTemplate< SUPER >  Erase (const IteratorTemplate< SUPER > &it, Bool deleteEntry=true)
void  DeleteEntry (const Entry *e)
Result < void >  IntersectImpl ( SET &&set, OverloadRank0 )
Result < void >  CopyFromImpl (HASHMAP &&other, COLLECTION_RESIZE_FLAGS resizeFlags, OverloadRank1 )
SFINAEHelper < Result < void >, typename std::remove_reference< S >::type::MapType >::type  AppendAllImpl ( S &&src, COLLECTION_RESIZE_FLAGS resizeFlags, Bool overwrite, OverloadRank1 )
MultiEntryIterator< false >  FindAll (const T &key)
MultiEntryIterator< true >  FindAll (const T &key) const
KeyIterator   GetKeys ()
ConstKeyIterator   GetKeys () const
ValueIterator   GetValues ()
ConstValueIterator   GetValues () const
Iterator   Begin ()
ConstIterator   Begin () const
Iterator   End ()
ConstIterator   End () const
Iterator   GetIterator (const Entry *e)
ConstIterator   GetIterator (const Entry *e) const
SFINAEHelper < String , UnitType >::type  ToString (const FormatStatement *formatStatement=nullptr) const
const Entry *  FindEntryImpl ( UInt hash, const KEY &key) const
Entry *  FindEntryImpl ( UInt hash, const KEY &key)
-  Protected Member Functions inherited from MapBase< HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, MODE, INITIAL_CAPACITY, LOAD_FACTOR >, T, UnitType, EmptyClass, DefaultCompare >
MAXON_ATTRIBUTE_FORCE_INLINE   MapBase (ARGS &&... args)
MapImpl < HashMap < T, UnitType , DefaultCompare , HashMapKeyValuePair , DefaultAllocator , MODE , INITIAL_CAPACITY, LOAD_FACTOR > & >  ToMap ()
MapImpl < const HashMap < T, UnitType , DefaultCompare , HashMapKeyValuePair , DefaultAllocator , MODE , INITIAL_CAPACITY, LOAD_FACTOR > & >  ToMap () const
MAXON_ATTRIBUTE_FORCE_INLINE   operator MapImpl< HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, MODE, INITIAL_CAPACITY, LOAD_FACTOR > & > ()
MAXON_ATTRIBUTE_FORCE_INLINE   operator MapImpl< const HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, MODE, INITIAL_CAPACITY, LOAD_FACTOR > & > () const
-  Protected Member Functions inherited from MapBase0< HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, MODE, INITIAL_CAPACITY, LOAD_FACTOR >, T, UnitType, EmptyClass, DefaultCompare >
MAXON_ATTRIBUTE_FORCE_INLINE   MapBase0 (ARGS &&... args)
MAXON_ATTRIBUTE_FORCE_INLINE Bool   Contains (typename ByValueParam < T >::type key) const
MAXON_ATTRIBUTE_FORCE_INLINE SFINAEHelper < Bool , typename PAIR::KeyType >::type  Contains (const PAIR &pair) const
ResultRef < UnitType Append (const T &key)
SFINAEHelper < ResultRef < UnitType >, typename PAIR::KeyType >::type  Append (const PAIR &pair)
Result < void >  添加 (COLLECTION2 &&other, COLLECTION_RESIZE_FLAGS resizeFlags= COLLECTION_RESIZE_FLAGS::ON_GROW_RESERVE_CAPACITY )
Result < void >  AppendAll (COLLECTION2 &&other, COLLECTION_RESIZE_FLAGS resizeFlags= COLLECTION_RESIZE_FLAGS::ON_GROW_RESERVE_CAPACITY )
Result < void >  AppendAllInverse (COLLECTION2 &&other)
Bool   ContainsAllImpl (COLLECTION2 &&other, OverloadRank0 ) const
Result < void >  SubtractImpl (COLLECTION2 &&other, OverloadRank0 )
Bool   IsEqualImpl (const COLLECTION2 &other, COMPARE &&cmp, OverloadRank0 ) const
HashInt   GetHashCode () const
-  Protected Member Functions inherited from BaseCollection< HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, MODE, INITIAL_CAPACITY, LOAD_FACTOR >, EmptyClass >
MAXON_ATTRIBUTE_FORCE_INLINE   BaseCollection (ARGS &&... args)
MAXON_ATTRIBUTE_FORCE_INLINE std::enable_if< maxon::IsCollection< COLLECTION2 >::value, Bool >::type  operator== (const COLLECTION2 &other) const
MAXON_ATTRIBUTE_FORCE_INLINE std::enable_if< maxon::IsCollection< COLLECTION2 >::value, Bool >::type  operator!= (const COLLECTION2 &other) const
MAXON_ATTRIBUTE_FORCE_INLINE std::enable_if< maxon::IsCollection< COLLECTION2 >::value &&! STD_IS_REPLACEMENT (same, typename std::decay< COMPARE >::type, EQUALITY ), Bool >::type  IsEqual (const COLLECTION2 &other, COMPARE &&cmp=COMPARE()) const
MAXON_ATTRIBUTE_FORCE_INLINE Result < void >  AppendAll (COLLECTION2 &&other, COLLECTION_RESIZE_FLAGS resizeFlags= COLLECTION_RESIZE_FLAGS::ON_GROW_RESERVE_CAPACITY )
MAXON_ATTRIBUTE_FORCE_INLINE Result < void >  CopyFrom (COLLECTION2 &&other, COLLECTION_RESIZE_FLAGS resizeFlags= COLLECTION_RESIZE_FLAGS::FIT_TO_SIZE )
MAXON_ATTRIBUTE_FORCE_INLINE Result < void >  Subtract (COLLECTION2 &&other)
MAXON_ATTRIBUTE_FORCE_INLINE Result < void >  Intersect (const COLLECTION2 &other)
Bool   Intersects (const COLLECTION2 &other) const
MAXON_ATTRIBUTE_FORCE_INLINE Result < void >  CopyFromImpl (COLLECTION2 &&other, COLLECTION_RESIZE_FLAGS resizeFlags, OverloadRank0 )
Result < void >  AppendAllImpl (COLLECTION2 &&other, COLLECTION_RESIZE_FLAGS resizeFlags, Bool overwrite, OverloadRank0 )
Result < void >  IntersectImpl (COLLECTION2 &&other, OverloadRank0 )
MAXON_ATTRIBUTE_FORCE_INLINE Bool   IsEmpty () const
MAXON_ATTRIBUTE_FORCE_INLINE Bool   IsPopulated () const
String   ToString (const FormatStatement *formatStatement=nullptr) const
MAXON_ATTRIBUTE_FORCE_INLINE Bool   ContainsAll (COLLECTION2 &&other) const
Bool   ContainsAllImpl (COLLECTION2 &&other, OverloadRank0 ) const
-  Static Protected Member Functions inherited from HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 >
static Entry *  LoadRelaxed ( AtomicPtr < Entry > &e)
static Entry *  LoadRelaxed (Entry *e)
static Entry *  LoadAcquire ( AtomicPtr < Entry > &e)
static Entry *  LoadAcquire (Entry *e)
static void  StoreRelaxed ( AtomicPtr < Entry > &e, Entry *newValue)
static void  StoreRelaxed (Entry *&e, Entry *newValue)
static Bool   TryCompareAndSwap ( AtomicPtr < Entry > &e, Entry *newValue, Entry *compare)
static Bool   TryCompareAndSwap (Entry *&e, Entry *newValue, Entry *compare)
static const Entry *  GetEntry (const UnitType *value)
static Entry *  GetEntry (typename std::remove_const< UnitType >::type *value)
-  Static Protected Member Functions inherited from MapBase0< HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, MODE, INITIAL_CAPACITY, LOAD_FACTOR >, T, UnitType, EmptyClass, DefaultCompare >
static const T &  GetMapKey (const T &key)
static const T &  GetMapKey (const PAIR &pair)
-  Protected Attributes inherited from HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, HASHMAP_MODE::DEFAULT, 16,(HASHMAP_MODE::DEFAULT==HASHMAP_MODE::SYNCHRONIZED) ? 0 :10 >
DefaultAllocator   _allocator
Bucket _table
Int   _tableLengthM1
Bucket **  _nonemptyBuckets
Int   _nonemptyBucketCount
Int   _size
Int   _resizeThreshold
const Float   _obsoleteLoadFactor
-  Static Protected Attributes inherited from MapBase0< HashMap< T, UnitType, DefaultCompare, HashMapKeyValuePair, DefaultAllocator, MODE, INITIAL_CAPACITY, LOAD_FACTOR >, T, UnitType, EmptyClass, DefaultCompare >
static const COLLECTION_KIND   KIND

Member Typedef Documentation

◆  MapType

using MapType = HashMap <T, UnitType , HASH, ENTRY_HANDLER, ALLOCATOR, MODE, INITIAL_CAPACITY, LOAD_FACTOR>

◆  Super

using Super = SetBase < HashSet , T, Protected < MapType >, HASH>

◆  IsHashMap

using IsHashMap = std::true_type

◆  IsHashSet

using IsHashSet = std::true_type

◆  Iterator

using Iterator = typename Super::KeyIterator

◆  ConstIterator

using ConstIterator = typename Super::ConstKeyIterator

构造函数 & 析构函数文档编制

◆  HashSet() [1/3]

HashSet ( const ALLOCATOR &  alloc )
explicit

Initializes the underlying allocator and constructs a new HashSet with an optional load factor. This will not allocate any memory. Memory allocation can be done explicitly by SetCapacityHint() , or it will be done implicitly when needed.

参数
[in] alloc Used to initialize the underlying allocator by its copy constructor.

◆  HashSet() [2/3]

HashSet ( )
default

Constructs a new HashSet with an optional load factor. This will not allocate any memory. Memory allocation can be done explicitly by SetCapacityHint() , or it will be done implicitly when needed.

◆  HashSet() [3/3]

HashSet ( HashSet < T, HASH, ENTRY_HANDLER, ALLOCATOR, MODE, INITIAL_CAPACITY, LOAD_FACTOR > &&  src )

成员函数文档编制

◆  MAXON_DISALLOW_COPY_AND_ASSIGN()

MAXON_DISALLOW_COPY_AND_ASSIGN ( HashSet < T, HASH, ENTRY_HANDLER, ALLOCATOR, MODE, INITIAL_CAPACITY, LOAD_FACTOR >  )
private

◆  MAXON_OPERATOR_MOVE_ASSIGNMENT()

MAXON_OPERATOR_MOVE_ASSIGNMENT ( HashSet < T, HASH, ENTRY_HANDLER, ALLOCATOR, MODE, INITIAL_CAPACITY, LOAD_FACTOR >  )

◆  GetHashCode()

HashInt GetHashCode ( ) const

◆  GetMap() [1/2]

MapType & GetMap ( )

◆  GetMap() [2/2]

const MapType & GetMap ( ) const

◆  Contains() [1/2]

Bool Contains ( typename ByValueParam < T >:: type   value ) const

Checks if this set contains value .

参数
[in] value The value to check.
返回
True if this set contains value .

◆  Contains() [2/2]

Bool Contains ( const KEY &  key ) const

Checks if this set contains key . The type KEY of the given key need not be the same as V, but then you have to provide an additional class KEYHASH to compute the hash code of the specified key (function KEYHASH::GetHashCode(const KEY&)), and to compare a key of type KEY with a key of type V for equality (function KEYHASH::IsEqual(const KEY&, const V&)) unless the default HASH class is already able to do so.

Template Parameters
KEYHASH Hash class to compute the hash code of key, and to compare key with the map's keys. Default is HASH.
KEY Type of key.
参数
[in] key The value to check.
返回
True if this set contains value .

◆  Insert() [1/3]

void Insert ( ) const

◆  Insert() [2/3]

ResultRef <typename Super::Entry> Insert ( const T &  value ,
Bool added = BoolLValue()  
)

Adds value to this set. If value is already contained in this set, nothing happens, and added 被设为 false .

参数
[in] value Value to add to this set.
[out] added This will be set to true if the element didn't exist before in the set and it could be added successfully, otherwise it will be set to false.
返回
Element reference or OutOfMemoryError if the allocation failed.

◆  Insert() [3/3]

ResultRef <typename Super::Entry> Insert ( T &&  value ,
Bool added = BoolLValue()  
)

Adds value to this set. If value is already contained in this set, nothing happens, and added 被设为 false .

参数
[in] value Value to add to this set. When a new element has to be added, value will be moved into the new element.
[out] added This will be set to true if the element didn't exist before in the set and it could be added successfully, otherwise it will be set to false.
返回
Element reference or OutOfMemoryError if the allocation failed.

◆  InsertKey() [1/2]

ResultRef <const T> InsertKey ( const T &  value ,
Bool added = BoolLValue()  
)

Adds value to this set. If value is already contained in this set, nothing happens, and added 被设为 false .

参数
[in] value Value to add to this set.
[out] added This will be set to true if the element didn't exist before in the set and it could be added successfully, otherwise it will be set to false.
返回
Pointer to the value in the set, or nullptr if the element had to be added, but the allocation failed.

◆  InsertKey() [2/2]

ResultRef <const T> InsertKey ( T &&  value ,
Bool added = BoolLValue()  
)

Adds value to this set. If value is already contained in this set, nothing happens, and added 被设为 false .

参数
[in] value Value to add to this set. When a new element has to be added, value will be moved into the new element.
[out] added This will be set to true if the element didn't exist before in the set and it could be added successfully, otherwise it will be set to false.
返回
Pointer to the value in the set, or nullptr if the element had to be added, but the allocation failed.

◆  InsertLambda()

Result <Entry*> InsertLambda ( KEY &&  key ,
LAMBDA &&  lambda  
)

Adds an entry corresponding to the given key if such an entry doesn't exist yet. If a new entry has to be created, the passed lambda function is invoked with the key as first argument and the value (of type T&) of the newly created entry as second argument. The lambda then has to initialize the value correctly. The lambda function has to return Result<void> .

The type KEY of the given key need not be the same as T, but then you have to provide an additional class KEYHASH to compute the hash code of the specified key (function KEYHASH::GetHashCode(const KEY&)), and to compare a key of type KEY with a key of type T for equality (function KEYHASH::IsEqual(const KEY&, const T&)) unless the default HASH class is already able to do so.

Template Parameters
KEYHASH Hash class to compute the hash code of key, and to compare key with the map's keys. Default is HASH.
KEY Type of key.
LAMBDA Type of the function.
参数
[in] key Key of the entry to find or create.
[in] lambda The function which will be invoked as return lambda(key, value); to initialize the value of a newly created entry.
返回
Entry for the given key, or nullptr if the entry didn't exist and allocation of a new entry failed.

◆  Erase() [1/3]

ResultOk < Bool > Erase ( const T &  value )

移除 value from this set. If value isn't contained in this set, nothing happens.

参数
[in] value Value to remove from this set.
返回
True if an entry was found and removed for #value, otherwise false.

◆  Erase() [2/3]

ResultOk <void> Erase ( const Entry *  entry )

◆  Begin() [1/2]

ConstIterator Begin ( ) const

◆  End() [1/2]

ConstIterator End ( ) const

◆  Begin() [2/2]

Iterator Begin ( )

◆  End() [2/2]

Iterator End ( )

◆  Erase() [3/3]

Iterator Erase ( const Iterator it )

◆  Find() [1/2]

Entry* Find ( typename KEYHASH  = HASH ,
typename KEY   
)

Finds the entry with the given key in this map. The type KEY of the given key need not be the same as K, but then you have to provide an additional class KEYHASH to compute the hash code of the specified key (function KEYHASH::GetHashCode(const KEY&)), and to compare a key of type KEY with a key of type K for equality (function KEYHASH::IsEqual(const KEY&, const K&)) unless the default HASH class is already able to do so.

Template Parameters
KEYHASH Hash class to compute the hash code of key, and to compare key with the map's keys. Default is HASH.
KEY Type of key.
参数
[in] key Key to search for.
返回
Entry having the given key, or nullptr if no such entry exists in this map.

◆  Find() [2/2]

const Entry* Find ( typename KEYHASH  = HASH ,
typename KEY   
)

Finds the entry with the given key in this map. The type KEY of the given key need not be the same as K, but then you have to provide an additional class KEYHASH to compute the hash code of the specified key (function KEYHASH::GetHashCode(const KEY&)), and to compare a key of type KEY with a key of type K for equality (function KEYHASH::IsEqual(const KEY&, const K&)) unless the default HASH class is already able to do so.

Template Parameters
KEYHASH Hash class to compute the hash code of key, and to compare key with the map's keys. Default is HASH.
KEY Type of key.
参数
[in] key Key to search for.
返回
Entry having the given key, or nullptr if no such entry exists in this map.

◆  InsertEntry() [1/3]

ResultRef <Entry> InsertEntry

Finds the entry with the given key, or creates such an entry if it doesn't exist yet. The value of a new entry has to be initialized afterwards (but its default constructor has already been invoked).

参数
[in] key Key of the entry to find or create.
[out] created This will be set to true if a new entry has been created successfully, otherwise it will be set to false.
返回
Entry for the given key, or nullptr if the entry didn't exist and allocation of a new entry failed.

◆  InsertEntry() [2/3]

ResultRef <Entry> InsertEntry

Finds the entry with the given key, or creates such an entry if it doesn't exist yet. The value of a new entry has to be initialized afterwards (but its default constructor has already been invoked).

参数
[in] key Key of the entry to find or create. If a new entry is created, its key will be constructed by move-semantics if possible.
[out] created This will be set to true if a new entry has been created successfully, otherwise it will be set to false.
返回
Entry for the given key, or nullptr if the entry didn't exist and allocation of a new entry failed.

◆  InsertEntry() [3/3]

ResultRef <Entry> InsertEntry ( typename KEYHASH  = HASH ,
typename KEY   
)

Finds the entry with the given key, or creates such an entry if it doesn't exist yet. The value of a new entry has to be initialized afterwards (but its default constructor has already been invoked). The type KEY of the given key need not be the same as K, but then you have to provide an additional class KEYHASH to compute the hash code of the specified key (function KEYHASH::GetHashCode(const KEY&)), and to compare a key of type KEY with a key of type K for equality (function KEYHASH::IsEqual(const KEY&, const K&)) unless the default HASH class is already able to do so.

Template Parameters
KEYHASH Hash class to compute the hash code of key, and to compare key with the map's keys. Default is HASH.
KEY Type of key.
参数
[in] key Key of the entry to find or create.
[out] created This will be set to true if a new entry has been created successfully, otherwise it will be set to false.
返回
Entry for the given key, or nullptr if the entry didn't exist and allocation of a new entry failed.

◆  InsertCtor()

Result <Entry*> InsertCtor ( typename KEYHASH  = HASH ,
typename KEY  ,
typename C   
)

Finds the entry with the given key, or creates such an entry if it doesn't exist yet. If a new entry has to be created, it is constructed with the help of the object passed to the constructor parameter: Its class C has to provide a function Int C::GetHashMapEntrySize(const K& key) to compute the size of a new entry for key and a function Result<void> C::ConstructHashMapEntry(void* ptr, UInt hash, const K& key) which uses the memory in ptr to construct a new entry for the key. If the constructor does not initialize the value of the new entry, this has to be done afterwards.

The type KEY of the given key need not be the same as K, but then you have to provide an additional class KEYHASH to compute the hash code of the specified key (function KEYHASH::GetHashCode(const KEY&)), and to compare a key of type KEY with a key of type K for equality (function KEYHASH::IsEqual(const KEY&, const K&)) unless the default HASH class is already able to do so.

Template Parameters
KEYHASH Hash class to compute the hash code of key, and to compare key with the map's keys. Default is HASH.
KEY Type of key.
C Type of the constructor argument.
参数
[in] key Key of the entry to find or create.
[in] constructor The functions constructor.GetHashMapEntrySize(ptr, hash, key) and constructor.ConstructHashMapEntry(ptr, hash, key) will be used to construct a new entry from the memory in ptr.
[out] created This will be set to true if a new entry has been created successfully, otherwise it will be set to false.
返回
Entry for the given key, or nullptr if the entry didn't exist and allocation of a new entry failed.

◆  GetCount()

Int GetCount

Returns the number of entries in this map.

返回
Number of entries.

◆  GetOperationCountForSearch()

Int GetOperationCountForSearch

Returns an estimate of the number of operations needed to locate a given key in this map. This is used when two collections are compared: The iteration goes over the collection which would require more operations for search, and each entry is searched in the other collection.

返回
Estimate for the number of operations.

◆  SetCapacityHint()

ResultMem SetCapacityHint

Ensures that the bucket table is large enough to hold at least capacity entries, taking into account the load factor (see explanation of the class HashMap itself).

参数
[in] capacity The number of entries which can be stored without the need for re-hashing.
[in] resizeFlags Not used by HashMap .
返回
True if memory allocations succeeded.

◆  ResizeTable()

ResultMem ResizeTable

Resizes the bucket table of the HashMap . Usually, with a positive load factor, this is done automatically when needed. You can force a resize if you know that a large number of entries will be added, this will eliminate some intermediate resizings. For a non-positive load factor, you have to manually resize the table if advisable. This function can also be used to reduce the table size (it gets never reduced automatically).

参数
[in] capacity The number of entries which can be stored without the need for re-hashing.
返回
True if memory allocations succeeded. If not, the HashMap will still be in a valid state, but still with the previous table size.

◆  Reset()

void Reset

Resets the map. This destructs all entries and frees any memory held by the map, so the map will be in a state as if it had been newly constructed.

另请参阅
Flush()

◆  Flush()

void Flush

Flushes the map. This destructs and frees all entries, but does not free the bucket table.

另请参阅
Reset()

◆  IntersectImpl()

Result <void> IntersectImpl ( typename SET  )

Removes all entries from this map whose keys are not contained in set. A key is in set if set.Contains(key) returns true, or if that is not a valid expression, if set(key) returns true. I.e., you can use a lambda expression as set .

参数
[in] set A set with which this map gets intersected. Can be a lambda expression.
Template Parameters
SET Type of set .

◆  GetMemorySize()

Int GetMemorySize

Calculates the memory usage for this map. Keys and Values must have a public member GetMemorySize that return the element size.

返回
Memory size in bytes.

Member Data Documentation

◆  MapType

friend MapType
DiagnosticOutput
#define DiagnosticOutput(formatString,...)
定义: debugdiagnostics.h:166
String
定义: c4d_string.h:38
maxon::HashSet::ConstIterator
typename Super::ConstKeyIterator ConstIterator
定义: hashmap.h:2824
Bool
maxon::Bool Bool
定义: ge_sys_math.h:53