Class HashRing<TNode>
Represents a consistent hash ring.
Inheritance
System.Object
HashRing<TNode>
Implements
IConsistentHashRing<TNode>
System.Collections.Generic.IEnumerable<System.ValueTuple<TNode, System.UInt32>>
System.Collections.IEnumerable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: ConsistentHashing
Assembly: ConsistentHashing.dll
Syntax
public class HashRing<TNode> : IConsistentHashRing<TNode>, IEnumerable<(TNode, uint)>, IEnumerable where TNode : IComparable<TNode>
Type Parameters
Name | Description |
---|---|
TNode | The type of node to store in the ring. |
Properties
| Improve this Doc View SourceIsEmpty
Gets whether the consistent hash ring is empty or not.
Declaration
public bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the ring is empty and false otherwise. |
Partitions
Gets all partitions where a partition is a hash range and the owner node.
Declaration
public IEnumerable<Partition<TNode>> Partitions { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Partition<TNode>> | An enumeration of all the partitions defined by the hash ring. |
Methods
| Improve this Doc View SourceAddNode(TNode, UInt32)
Adds the specified node to the hash ring at the specified point.
Declaration
public void AddNode(TNode node, uint point)
Parameters
Type | Name | Description |
---|---|---|
TNode | node | The node to add. |
System.UInt32 | point | The point at which to add the node to. |
GetEnumerator()
Declaration
public IEnumerator<(TNode, uint)> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<System.ValueTuple<TNode, System.UInt32>> |
GetNode(UInt32)
Gets the node that owns the hash.
Declaration
public TNode GetNode(uint hash)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | hash | The hash. |
Returns
Type | Description |
---|---|
TNode | The node that owns the hash. |
RemoveNode(TNode)
Removes all instances of the node from the hash ring.
Declaration
public void RemoveNode(TNode node)
Parameters
Type | Name | Description |
---|---|---|
TNode | node | The node to remove. |
Explicit Interface Implementations
| Improve this Doc View SourceIEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |
Implements
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable