Class HashSetList<T>
Wrapper data structure for hashset, that leans on a list for deterministic sort order
Inherited Members
Namespace: Unity.XR.CoreUtils.Collections
Assembly: Unity.XR.CoreUtils.dll
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(int)
Allocates internal list and hashset.
Declaration
public HashSetList(int capacity = 0)
Parameters
Type | Name | Description |
---|---|---|
int | capacity | Initial list capacity |
Properties
Count
Internal list count.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int |
this[int]
Access internal list element from index.
Declaration
public T this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
int | 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 |
---|---|
bool | True if the item was added to both list and hashset. |
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()
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 |
---|---|
bool | Returns true if internal hashset contains item, returns false otherwise. |
CopyTo(T[], int)
Copies out internal list as array.
Declaration
public void CopyTo(T[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | Array to write to. |
int | arrayIndex | Index to start from. |
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. |
GetEnumerator()
Creates enumerator for internal list.
Declaration
public List<T>.Enumerator GetEnumerator()
Returns
Type | Description |
---|---|
List<T>.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 |
|
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. |
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 |
---|---|
bool | Returns true if internal hashset is a proper subset of other, returns false otherwise. |
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 |
---|---|
bool | Returns true if internal hashset is a proper superset of other, returns false otherwise. |
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 |
---|---|
bool | Returns true if internal hashset is a subset of other, returns false otherwise. |
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 |
---|---|
bool | Returns true if internal hashset is a superset of other, returns false. |
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. |
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 |
---|---|
bool |
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 |
---|---|
bool | True if the item was removed from both list and hashset. |
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 |
---|---|
bool | Returns true if hash iOverlaps operation is true, returns false otherwise. |
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 |
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. |