Class HashSetList<T>
Wrapper data structure for hashset, that leans on a list for deterministic sort order
Inherited Members
Namespace: Unity.XR.CoreUtils.Collections
Syntax
public class HashSetList<T> : ISerializable, IDeserializationCallback, ISet<T>, ICollection<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
Name | Description |
---|---|
T | HashSetList type |
Constructors
HashSetList(Int32)
Allocates internal list and hashset.
Declaration
public HashSetList(int capacity = 0)
Parameters
Type | Name | Description |
---|---|---|
Int32 | capacity | Initial list capacity |
Properties
Count
Internal list count.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
Int32 |
Implements
Item[Int32]
Access internal list element from index.
Declaration
public T this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | Index used to access internal list. |
Property Value
Type | Description |
---|---|
T |
Methods
Add(T)
Attempt to add item to internal hashset. If it is not already in the hashset, add it to the list.
Declaration
public bool Add(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | Item of type |
Returns
Type | Description |
---|---|
Boolean | True if the item was added to both list and hashset. |
Implements
AsList()
Exposes internal list without any allocation.
Declaration
public IReadOnlyList<T> AsList()
Returns
Type | Description |
---|---|
IReadOnlyList<T> | Internal list structure. |
Clear()
Clear both internal hashset and list.
Declaration
public void Clear()
Implements
Contains(T)
Checks if internal hashset contains item.
Declaration
public bool Contains(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | Item to check. |
Returns
Type | Description |
---|---|
Boolean | Returns true if internal hashset contains item, returns false otherwise. |
Implements
CopyTo(T[], Int32)
Copies out internal list as array.
Declaration
public void CopyTo(T[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | Array to write to. |
Int32 | arrayIndex | Index to start from. |
Implements
ExceptWith(IEnumerable<T>)
Except operation with hashset. Regenerates internal list from new hashset.
Declaration
public void ExceptWith(IEnumerable<T> other)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | other | Enumerable to except with. |
Implements
GetEnumerator()
Creates enumerator for internal list.
Declaration
public List<T>.Enumerator GetEnumerator()
Returns
Type | Description |
---|---|
List.Enumerator<> | Returns internal list enumerator. |
GetObjectData(SerializationInfo, StreamingContext)
Calls internal hashset GetObjectData
and refreshes list.
Declaration
public void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
SerializationInfo | info |
|
StreamingContext | context |
|
Implements
IntersectWith(IEnumerable<T>)
IntersectWith
operation with hashset. Regenerates internal list from new hashset.
Declaration
public void IntersectWith(IEnumerable<T> other)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | other | Enumerable to intersect with. |
Implements
IsProperSubsetOf(IEnumerable<T>)
IsProperSubsetOf
operation with hashset. Regenerates internal list from new hashset.
Declaration
public bool IsProperSubsetOf(IEnumerable<T> other)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | other | Enumerable to |
Returns
Type | Description |
---|---|
Boolean | Returns true if internal hashset is a proper subset of other, returns false otherwise. |
Implements
IsProperSupersetOf(IEnumerable<T>)
IsProperSupersetOf
operation with hashset. Regenerates internal list from new hashset.
Declaration
public bool IsProperSupersetOf(IEnumerable<T> other)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | other | Enumerable to |
Returns
Type | Description |
---|---|
Boolean | Returns true if internal hashset is a proper superset of other, returns false otherwise. |
Implements
IsSubsetOf(IEnumerable<T>)
IsSubsetOf
operation with hashset. Regenerates internal list from new hashset.
Declaration
public bool IsSubsetOf(IEnumerable<T> other)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | other | Enumerable to |
Returns
Type | Description |
---|---|
Boolean | Returns true if internal hashset is a subset of other, returns false otherwise. |
Implements
IsSupersetOf(IEnumerable<T>)
IsSupersetOf
operation with hashset. Regenerates internal list from new hashset.
Declaration
public bool IsSupersetOf(IEnumerable<T> other)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | other | Enumerable to |
Returns
Type | Description |
---|---|
Boolean | Returns true if internal hashset is a superset of other, returns false. |
Implements
OnDeserialization(Object)
Deserializes sender object into internal hashset and refreshes list.
Declaration
public void OnDeserialization(object sender)
Parameters
Type | Name | Description |
---|---|---|
Object | sender | Object to be deserialized as set. |
Implements
Overlaps(IEnumerable<T>)
Overlaps
operation with hashset.
Declaration
public bool Overlaps(IEnumerable<T> other)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | other | Enumerable to |
Returns
Type | Description |
---|---|
Boolean |
Implements
Remove(T)
Attempt to remove item to internal hashset. If it is still present in the hashset, remove it from the list.
Declaration
public bool Remove(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | Item to remove. |
Returns
Type | Description |
---|---|
Boolean | True if the item was removed from both list and hashset. |
Implements
SetEquals(IEnumerable<T>)
Check if set equals other Overlaps(IEnumerable<T>) operation with hashset.
Declaration
public bool SetEquals(IEnumerable<T> other)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | other | Enumerable to Overlaps(IEnumerable<T>) with. |
Returns
Type | Description |
---|---|
Boolean | Returns true if hash iOverlaps operation is true, returns false otherwise. |
Implements
SymmetricExceptWith(IEnumerable<T>)
SymmetricExceptWith
between internal hashset and other IEnumerable
. Refresh List.
Declaration
public void SymmetricExceptWith(IEnumerable<T> other)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | other | Enumerable to |
Implements
UnionWith(IEnumerable<T>)
UnionWith
between internal hashset and other IEnumerable. Refresh List.
Declaration
public void UnionWith(IEnumerable<T> other)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | other | Enumerable to union with. |
Implements
Explicit Interface Implementations
ICollection<T>.Add(T)
Adds item to the existing internal list.
Declaration
void ICollection<T>.Add(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | Item of type |
Implements
ICollection<T>.IsReadOnly
Mandatory field. Always false.
Declaration
bool ICollection<T>.IsReadOnly { get; }
Returns
Type | Description |
---|---|
Boolean |
Implements
IEnumerable<T>.GetEnumerator()
Gets an IEnumerator<T> for the internal list.
Declaration
IEnumerator<T> IEnumerable<T>.GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<T> | Returns internal list enumerator. |
Implements
IEnumerable.GetEnumerator()
Returns a standard enumerator that iterates through the collection.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator | An IEnumerator object that can be used to iterate through the collection. |