template<typename T, typename HASH = DefaultCompare, typename ENTRY_HANDLER = HashMapKeyValuePair, typename ALLOCATOR = DefaultAllocator, Bool SYNCHRONIZED = false>
class maxon::HashSet< T, HASH, ENTRY_HANDLER, ALLOCATOR, SYNCHRONIZED >
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 ...;
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:
- Template Parameters
-
- See also
- HashMap
-
$ref sets
|
| HashSet (const ALLOCATOR &alloc, Float loadFactor=Float(SYNCHRONIZED ? 0 :0.65)) |
|
| HashSet (Float loadFactor=Float(SYNCHRONIZED ? 0 :0.65)) |
|
| HashSet (HashSet &&src) |
|
| MAXON_OPERATOR_MOVE_ASSIGNMENT (HashSet) |
|
UInt | 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) |
|
MAXON_ATTRIBUTE_FORCE_INLINE | SetBase (ARGS &&... args) |
|
SetImpl< HashSet< T, HASH, ENTRY_HANDLER, ALLOCATOR, SYNCHRONIZED > & > | ToSet () |
|
SetImpl< const HashSet< T, HASH, ENTRY_HANDLER, ALLOCATOR, SYNCHRONIZED > & > | ToSet () const |
|
MAXON_ATTRIBUTE_FORCE_INLINE | operator SetImpl< HashSet< T, HASH, ENTRY_HANDLER, ALLOCATOR, SYNCHRONIZED > & > () |
|
MAXON_ATTRIBUTE_FORCE_INLINE | operator SetImpl< const HashSet< T, HASH, ENTRY_HANDLER, ALLOCATOR, SYNCHRONIZED > & > () const |
|
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 > | Add (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 |
|
UInt | GetHashCode () const |
|
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_scalar< T >::value, T, DummyParamType & >::type > () |
|
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 |
|
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_same< typename std::decay< COMPARE >::type, EQUALITY >::value, 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) const |
|
MAXON_ATTRIBUTE_FORCE_INLINE Bool | ContainsAll (COLLECTION2 &&other) const |
|
Bool | ContainsAllImpl (COLLECTION2 &&other, OverloadRank0) const |
|
| __attribute__ ((always_inline)) explicit Protected(ARGS &&... args) |
|
|
static const T & | GetMapKey (const T &key) |
|
static const COLLECTION_KIND | KIND |
|
using | Super = MapBase< HashMap, T, UnitType, EmptyClass, HASH > |
|
using | HashType = HASH |
|
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 > |
|
using | MapType = HashMap< T, UnitType, HASH, ENTRY_HANDLER, ALLOCATOR, SYNCHRONIZED > |
|
using | Super = BaseCollection< HashMap< T, UnitType, HASH, ENTRY_HANDLER, ALLOCATOR, SYNCHRONIZED >, EmptyClass > |
|
using | KeyType = T |
|
using | ValueType = UnitType |
|
using | IsCollection = std::true_type |
|
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 (Float loadFactor=Float(SYNCHRONIZED ? 0 :0.65)) |
|
| HashMap (const ALLOCATOR &alloc, Float loadFactor=Float(SYNCHRONIZED ? 0 :0.65)) |
|
| 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 | Reset () |
|
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) |
|
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) const |
|
const Entry * | FindEntryImpl (UInt hash, const KEY &key) const |
|
Entry * | FindEntryImpl (UInt hash, const KEY &key) |
|
MAXON_ATTRIBUTE_FORCE_INLINE | MapBase (ARGS &&... args) |
|
MapImpl< HashMap< T, UnitType, HASH, ENTRY_HANDLER, ALLOCATOR, SYNCHRONIZED > & > | ToMap () |
|
MapImpl< const HashMap< T, UnitType, HASH, ENTRY_HANDLER, ALLOCATOR, SYNCHRONIZED > & > | ToMap () const |
|
MAXON_ATTRIBUTE_FORCE_INLINE | operator MapImpl< HashMap< T, UnitType, HASH, ENTRY_HANDLER, ALLOCATOR, SYNCHRONIZED > & > () |
|
MAXON_ATTRIBUTE_FORCE_INLINE | operator MapImpl< const HashMap< T, UnitType, HASH, ENTRY_HANDLER, ALLOCATOR, SYNCHRONIZED > & > () const |
|
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 > | Add (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 |
|
UInt | GetHashCode () const |
|
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_same< typename std::decay< COMPARE >::type, EQUALITY >::value, 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) const |
|
MAXON_ATTRIBUTE_FORCE_INLINE Bool | ContainsAll (COLLECTION2 &&other) const |
|
Bool | ContainsAllImpl (COLLECTION2 &&other, OverloadRank0) const |
|
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 T & | GetMapKey (const T &key) |
|
static const T & | GetMapKey (const PAIR &pair) |
|
ALLOCATOR | _allocator |
|
Bucket * | _table |
|
Int | _tableLengthM1 |
|
Bucket ** | _nonemptyBuckets |
|
Int | _nonemptyBucketCount |
|
Int | _size |
|
Int | _resizeThreshold |
|
const Float | _loadFactor |
|
static const COLLECTION_KIND | KIND |
|