Class SetHashLinked<T, TEquate, THash>
An unsorted structure of unique items implemented as a hashed table of linked lists.
Inheritance
Implements
Namespace: Towel.DataStructures
Assembly: Towel.dll
Syntax
public class SetHashLinked<T, TEquate, THash> : object, ISet<T>, IDataStructure<T>, ISteppable<T>, System.Collections.Generic.IEnumerable<T>, DataStructure.IAuditable<T>, DataStructure.IAddable<T>, DataStructure.IRemovable<T>, DataStructure.ICountable, DataStructure.IClearable, ICloneable<SetHashLinked<T, TEquate, THash>>, DataStructure.IEquating<T, TEquate>, DataStructure.IHashing<T, THash> where TEquate : struct, IFunc<T, T, bool> where THash : struct, IFunc<T, int>
Type Parameters
Name | Description |
---|---|
T | The type of values stored in this data structure. |
TEquate | The type of function for quality checking |
THash | The type of function for hashing |
Constructors
| Improve this Doc View SourceSetHashLinked(TEquate, THash, Nullable<Int32>)
Constructs a hashed set.
Declaration
public SetHashLinked(TEquate equate = default(TEquate), THash hash = default(THash), int? expectedCount = null)
Parameters
Type | Name | Description |
---|---|---|
TEquate | equate | The function for quality checking |
THash | hash | The function for hashing |
System.Nullable<System.Int32> | expectedCount | The expected count of the set. |
Properties
| Improve this Doc View SourceCount
The current number of values in the set.
Runtime: O(1)
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Equate
Gets the value of the type that is checking T
values for equality.
Declaration
public TEquate Equate { get; }
Property Value
Type | Description |
---|---|
TEquate |
Hash
Gets the value of the type that is hashing T
values.
Declaration
public THash Hash { get; }
Property Value
Type | Description |
---|---|
THash |
TableSize
The current size of the hashed table.
Runtime: O(1)
Declaration
public int TableSize { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceTryAdd(T)
Tries to add a value to a data structure.
Declaration
public (bool Success, Exception? Exception) TryAdd(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to add to the data structure. |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, System.Nullable<Exception>> | True if the value was added or false if not. |
TryRemove(T)
Tries to remove a value.
Declaration
public (bool Success, Exception? Exception) TryRemove(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to remove. |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, System.Nullable<Exception>> | True if the value was removed or false if not. |
TryRemoveWithoutTrim(T)
Tries to remove a value from the set without shrinking the hash table.
Declaration
public (bool Success, Exception? Exception) TryRemoveWithoutTrim(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to remove. |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, System.Nullable<Exception>> | True if the remove was successful or false if not. |