System::Collections::Generic::HashSet< T > Class Template Reference

Forward declaration of HashSet class. More...

#include "system/collections/hashset.h"

Classes

class  Enumerator
 

Public Types

using ThisType = System::Collections::Generic::HashSet< T >
 Self type. More...
 
using ThisPtr = SharedPtr< ThisType >
 Pointer type. More...
 
using set_t = std::unordered_set< T, EqualityComparerHashAdapter< T >, EqualityComparerAdapter< T >, ASPOSE_COLLECTION_ALLOCATOR_TYPE >
 Underlying data type. More...
 
using setIt_t = typename set_t::iterator
 Iterator type. More...
 
using ValueType = T
 Value type. More...
 
using BaseType = ICollection< T >
 Implemented interface. More...
 
using IEnumerablePtr = SharedPtr< IEnumerable< T > >
 Enumerable interface pointer. More...
 
using IEnumeratorPtr = SharedPtr< IEnumerator< T > >
 Enumerator pointer. More...
 

Public Member Functions

 HashSet ()
 Creates empty set. More...
 
 HashSet (const SharedPtr< IEnumerable< T >> &items)
 Creates hashset based on enumerable values. More...
 
IEnumeratorPtr GetEnumerator () override
 
int get_Count () const override
 
void Add (const T &item) override
 
bool TryAdd (const T &item)
 
bool Remove (const T &item) override
 
void Clear () override
 Deletes all elements in set. More...
 
bool Contains (const T &item) const override
 
set_tdata ()
 
const set_tdata () const
 
void _add_range (std::initializer_list< T > list)
 
void CopyTo (ArrayPtr< T > arr, int index) override
 
virtual int get_Count () const=0
 Keeping get_Count() from hiding. More...
 

Detailed Description

template<typename T>
class System::Collections::Generic::HashSet< T >

Forward declaration of HashSet class.

Set implementation based on hashing. Objects of this class should only be allocated using System::MakeObject() function. Never create instance of this type on stack or using operator new, as it will result in runtime errors and/or assertion faults. Always wrap this class into System::SmartPtr pointer and use this pointer to pass it to functions as argument.

Parameters
TElement type.

Member Typedef Documentation

◆ BaseType

template<typename T >
using System::Collections::Generic::HashSet< T >::BaseType = ICollection<T>

Implemented interface.

◆ IEnumerablePtr

Enumerable interface pointer.

◆ IEnumeratorPtr

Enumerator pointer.

◆ set_t

template<typename T >
using System::Collections::Generic::HashSet< T >::set_t = std::unordered_set<T, EqualityComparerHashAdapter<T>, EqualityComparerAdapter<T>, ASPOSE_COLLECTION_ALLOCATOR_TYPE>

Underlying data type.

◆ setIt_t

template<typename T >
using System::Collections::Generic::HashSet< T >::setIt_t = typename set_t::iterator

Iterator type.

◆ ThisPtr

template<typename T >
using System::Collections::Generic::HashSet< T >::ThisPtr = SharedPtr<ThisType>

Pointer type.

◆ ThisType

◆ ValueType

template<typename T >
using System::Collections::Generic::HashSet< T >::ValueType = T

Value type.

Constructor & Destructor Documentation

◆ HashSet() [1/2]

template<typename T >
System::Collections::Generic::HashSet< T >::HashSet ( )
inline

Creates empty set.

◆ HashSet() [2/2]

template<typename T >
System::Collections::Generic::HashSet< T >::HashSet ( const SharedPtr< IEnumerable< T >> &  items)
inline

Creates hashset based on enumerable values.

Member Function Documentation

◆ _add_range()

template<typename T >
void System::Collections::Generic::HashSet< T >::_add_range ( std::initializer_list< T >  list)
inline

C++ specific

Parameters
listRange to insert into container.

◆ Add()

template<typename T >
void System::Collections::Generic::HashSet< T >::Add ( const T &  item)
inlineoverride

Adds element into set.

Parameters
itemElement to add.

◆ Clear()

template<typename T >
void System::Collections::Generic::HashSet< T >::Clear ( )
inlineoverride

Deletes all elements in set.

◆ Contains()

template<typename T >
bool System::Collections::Generic::HashSet< T >::Contains ( const T &  item) const
inlineoverride

Checks if element is present in set.

Parameters
itemItem to look for.
Returns
True if item is present in set, false otherwise.

◆ CopyTo()

template<typename T >
void System::Collections::Generic::HashSet< T >::CopyTo ( ArrayPtr< T >  arr,
int  index 
)
inlineoverride

Copies hash contents into existing array elements.

Parameters
arrDestination array.
indexDestination array beginning index.

◆ data() [1/2]

template<typename T >
set_t& System::Collections::Generic::HashSet< T >::data ( )
inline

Underlying data structure accessor.

Returns
Reference to underlying data structure.

◆ data() [2/2]

template<typename T >
const set_t& System::Collections::Generic::HashSet< T >::data ( ) const
inline

Underlying data structure accessor.

Returns
Const reference to underlying data structure.

◆ get_Count() [1/2]

template<typename T >
int System::Collections::Generic::HashSet< T >::get_Count ( ) const
inlineoverride

Gets number of elements in set.

Returns
Actual number of elements.

◆ get_Count() [2/2]

template<typename T >
virtual int System::Collections::Generic::ICollection< T >::get_Count

Keeping get_Count() from hiding.

◆ GetEnumerator()

template<typename T >
IEnumeratorPtr System::Collections::Generic::HashSet< T >::GetEnumerator ( )
inlineoverride

Creates enumerator.

Returns
Newly created enumerator.

◆ Remove()

template<typename T >
bool System::Collections::Generic::HashSet< T >::Remove ( const T &  item)
inlineoverride

Removes element from set.

Parameters
itemElement to remove.
Returns
True if element was found and deleted, false otherwise.

◆ TryAdd()

template<typename T >
bool System::Collections::Generic::HashSet< T >::TryAdd ( const T &  item)
inline

Adds element into set.

Parameters
itemItem to add.
Returns
True if element was added, false if already exists.