Class MapHashLinked<T, TKey, TEquate, THash>
An unsorted structure of unique items.
Inheritance
Implements
Namespace: Towel.DataStructures
Assembly: Towel.dll
Syntax
public class MapHashLinked<T, TKey, TEquate, THash> : object, IMap<T, TKey>, IDataStructure<T>, ISteppable<T>, System.Collections.Generic.IEnumerable<T>, DataStructure.ICountable, DataStructure.IClearable, DataStructure.IAuditable<TKey>, DataStructure.IRemovable<TKey>, ICloneable<MapHashLinked<T, TKey, TEquate, THash>>, DataStructure.IEquating<TKey, TEquate>, DataStructure.IHashing<TKey, THash> where TEquate : struct, IFunc<TKey, TKey, bool> where THash : struct, IFunc<TKey, int>
Type Parameters
Name | Description |
---|---|
T | The generic type of the structure. |
TKey | The generic key type of this map. |
TEquate | The type of function for quality checking |
THash | The type of function for hashing |
Constructors
| Improve this Doc View SourceMapHashLinked(TEquate, THash, Nullable<Int32>)
Constructs a new MapHashLinked<T, TKey, TEquate, THash>.
Declaration
public MapHashLinked(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 map. |
Properties
| Improve this Doc View SourceCount
Gets the current count of the data structure.
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 |
Item[TKey]
Gets the value of a specified key.
Declaration
public T this[TKey key] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key to get the value of. |
Property Value
Type | Description |
---|---|
T | The value of the key. |
TableSize
The current size of the hashed table.
Declaration
public int TableSize { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceTryAdd(TKey, T)
Tries to add a value to the map.
Declaration
public (bool Success, Exception? Exception) TryAdd(TKey key, T value)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the value. |
T | value | The value to be added. |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, System.Nullable<Exception>> |
|
TryAddOrUpdate<TUpdate>(TKey, T, TUpdate)
Adds or updates the value at the given key.
Declaration
public (bool Success, Exception? Exception, bool? Existed, T OldValue) TryAddOrUpdate<TUpdate>(TKey key, T value, TUpdate update = default(TUpdate))
where TUpdate : struct, IFunc<T, T>
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the value to add or update. |
T | value | The value to add if not already present. |
TUpdate | update | The function to update the value if present. |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, System.Nullable<Exception>, System.Nullable<System.Boolean>, T> |
|
Type Parameters
Name | Description |
---|---|
TUpdate | The type of function to update the value if present. |
TryGet(TKey)
Tries to get a value by key.
Declaration
public (bool Success, Exception? Exception, T Value) TryGet(TKey key)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the value to get. |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, System.Nullable<Exception>, T> |
|
TryRemove(TKey)
Tries to remove a value.
Declaration
public (bool Success, Exception? Exception) TryRemove(TKey key)
Parameters
Type | Name | Description |
---|---|---|
TKey | key |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, System.Nullable<Exception>> | True if the value was removed or false if not. |
TryRemoveOrUpdate<TRemovePredicate, TUpdate>(TKey, TRemovePredicate, TUpdate)
Tries to update a value in the map the relative key exists.
Declaration
public (bool Success, Exception? Exception, bool? Removed, T OldValue, T NewValue) TryRemoveOrUpdate<TRemovePredicate, TUpdate>(TKey key, TRemovePredicate removePredicate = default(TRemovePredicate), TUpdate update = default(TUpdate))
where TRemovePredicate : struct, IFunc<T, bool> where TUpdate : struct, IFunc<T, T>
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the value to update. |
TRemovePredicate | removePredicate | The predicate determining if the pair should be removed. |
TUpdate | update | The function to update the value relative to the key. |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, System.Nullable<Exception>, System.Nullable<System.Boolean>, T, T> |
|
Type Parameters
Name | Description |
---|---|
TRemovePredicate | The type of predicate determining if the pair should be removed. |
TUpdate | The type of function to update the value. |
TryRemoveWithoutTrim(TKey)
Tries to remove a keyed value without shrinking the hash table.
Declaration
public (bool Success, Exception? Exception) TryRemoveWithoutTrim(TKey key)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the value to remove. |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, System.Nullable<Exception>> | True if the removal was successful for false if not. |
TrySet(TKey, T)
Sets value in the map.
Declaration
public (bool Success, Exception? Exception, bool? Existed, T OldValue) TrySet(TKey key, T value)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the value. |
T | value | The value to be set. |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, System.Nullable<Exception>, System.Nullable<System.Boolean>, T> |
|
TryUpdate<TUpdate>(TKey, TUpdate)
Tries to update a value in the map the relative key exists.
Declaration
public (bool Success, Exception? Exception, T OldValue, T NewValue) TryUpdate<TUpdate>(TKey key, TUpdate update = default(TUpdate))
where TUpdate : struct, IFunc<T, T>
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the value to update. |
TUpdate | update | The function to update the value relative to the key. |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, System.Nullable<Exception>, T, T> |
|
Type Parameters
Name | Description |
---|---|
TUpdate | The type of function to update the value. |