• Articles
  • API Documentation
  • ConsistentHashing
  • HashRing<TNode>
Show / Hide Table of Contents
  • ConsistentHashing
    • HashRange
    • HashRangeCollection
    • HashRing<TNode>
    • HashRingExtensions
    • IConsistentHashRing<TNode>
    • Partition<TNode>

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 Source

IsEmpty

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.

| Improve this Doc View Source

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 Source

AddNode(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.

| Improve this Doc View Source

GetEnumerator()

Declaration
public IEnumerator<(TNode, uint)> GetEnumerator()
Returns
Type Description
System.Collections.Generic.IEnumerator<System.ValueTuple<TNode, System.UInt32>>
| Improve this Doc View Source

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.

| Improve this Doc View Source

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 Source

IEnumerable.GetEnumerator()

Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type Description
System.Collections.IEnumerator

Implements

IConsistentHashRing<TNode>
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable

Extension Methods

HashRingExtensions.AddVirtualNodes<TNode>(IConsistentHashRing<TNode>, TNode, IEnumerable<UInt32>)
HashRingExtensions.GetRangesForNode<TNode>(IConsistentHashRing<TNode>, TNode)
  • Improve this Doc
  • View Source
In This Article
  • Properties
    • IsEmpty
    • Partitions
  • Methods
    • AddNode(TNode, UInt32)
    • GetEnumerator()
    • GetNode(UInt32)
    • RemoveNode(TNode)
  • Explicit Interface Implementations
    • IEnumerable.GetEnumerator()
  • Implements
  • Extension Methods
Back to top Generated by DocFX