Show / Hide Table of Contents

Class MapHashLinked<T, TKey, TEquate, THash>

An unsorted structure of unique items.

Inheritance
System.Object
MapHashLinked<T, TKey, TEquate, THash>
Implements
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>
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 TKey values.

THash

The type of function for hashing TKey values.

Constructors

| Improve this Doc View Source

MapHashLinked(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 TKey values.

THash hash

The function for hashing TKey values.

System.Nullable<System.Int32> expectedCount

The expected count of the map.

Properties

| Improve this Doc View Source

Count

Gets the current count of the data structure.

Declaration
public int Count { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Equate

Gets the value of the type that is checking T values for equality.

Declaration
public TEquate Equate { get; }
Property Value
Type Description
TEquate
| Improve this Doc View Source

Hash

Gets the value of the type that is hashing T values.

Declaration
public THash Hash { get; }
Property Value
Type Description
THash
| Improve this Doc View Source

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.

| Improve this Doc View Source

TableSize

The current size of the hashed table.

Declaration
public int TableSize { get; }
Property Value
Type Description
System.Int32

Methods

| Improve this Doc View Source

TryAdd(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>>
  • Success: true if the key+value was added or false if not
  • ? Exception: the exception that occured if the add failed
| Improve this Doc View Source

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>
  • Success: true if the value was added or updated or false if not.
  • ? Exception: the exception that occured if the add or update failed.
  • ? Existed: if the key existed prior to the add or update
  • T? OldValue: the old value if the key existed prior to the add or update
Type Parameters
Name Description
TUpdate

The type of function to update the value if present.

| Improve this Doc View Source

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>
  • Success: true if the key was found or false if not.
  • ? Exception: the exception that occured if the get failed.
  • T? Value: the value if the key was found or default if not.
| Improve this Doc View Source

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.

| Improve this Doc View Source

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>
  • Success: true if the key was found or false if not
  • ? Exception: the exception that occured if the add failed
  • T? OldValue: the non-updated value if the key was found or default if not
  • T? NewValue: the updated value if the key was found or default if not
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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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>
  • Success: true if the key+value was set or false if not.
  • ? Exception: the exception that occured if the set failed.
  • ? Existed: if the key existed prior to being set
  • T? OldValue: the previous value if the key existed prior to being set
| Improve this Doc View Source

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>
  • Success: true if the key was found or false if not
  • ? Exception: the exception that occured if the add failed
  • T? OldValue: the non-updated value if the key was found or default if not
  • T? NewValue: the updated value if the key was found or default if not
Type Parameters
Name Description
TUpdate

The type of function to update the value.

Implements

IMap<T, TKey>
IDataStructure<T>
ISteppable<T>
System.Collections.Generic.IEnumerable<>
DataStructure.ICountable
DataStructure.IClearable
DataStructure.IAuditable<T>
DataStructure.IRemovable<T>
ICloneable<T>
DataStructure.IEquating<T, TEquate>
DataStructure.IHashing<T, THash>
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX