C# Класс Kademlia.ID

Наследование: IComparable
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
CompareTo ( object obj ) : int

Compare ourselves to an object

DifferingBit ( ID other ) : int

Determines the least significant bit at which the given ID differs from this one, from 0 through 8 * ID_LENGTH - 1. PRECONDITION: IDs do not match.

Equals ( object obj ) : bool

Method used to verify if two objects are equals.

FromString ( string hash ) : ID

Method that generates an ID starting from a generic string. This is not hashing.

GetHashCode ( ) : int

Method used to get the hash code according to the algorithm: http://stackoverflow.com/questions/16340/how-do-i-generate-a-hashcode-from-a-byte-array-in-c/425184#425184

Hash ( string key ) : ID

Hash a string to produce an ID

HostID ( ) : ID

Get an ID that will be the same between different calls on the same machine by the same app run by the same user. If that ID is taken, returns a random ID.

ID ( byte data ) : System

Make a new ID from a byte array.

ID ( string new_id ) : System

Make a new ID starting from a string. Pay attention, the string is not hashed, it is simply translated to an ID object.

RandomID ( ) : ID

Produce a random ID.

RandomizeBeyond ( int bit ) : ID

Return a copy of ourselves that differs from us at the given bit and is random beyond that.

ToPathString ( ) : string

Returns this ID represented as a path-safe string.

ToString ( ) : string

Turn this ID into a string.

operator ( ) : ID

XOR operator. This is our distance metric in the DHT.

operator ( ) : bool

We need to compare these when measuring distance

Приватные методы

Метод Описание
FlipBit ( byte data, int bit ) : void

Flips the given bit in the byte array. Byte array must be ID_LENGTH long.

IDInit ( byte data ) : void

This method initialize an id starting from a byte array.

Описание методов

CompareTo() публичный Метод

Compare ourselves to an object
public CompareTo ( object obj ) : int
obj object An obect to compare to
Результат int

DifferingBit() публичный Метод

Determines the least significant bit at which the given ID differs from this one, from 0 through 8 * ID_LENGTH - 1. PRECONDITION: IDs do not match.
public DifferingBit ( ID other ) : int
other ID The ID to compare to
Результат int

Equals() публичный Метод

Method used to verify if two objects are equals.
public Equals ( object obj ) : bool
obj object The object to compare to
Результат bool

FromString() публичный статический Метод

Method that generates an ID starting from a generic string. This is not hashing.
public static FromString ( string hash ) : ID
hash string The hash string originating an ID
Результат ID

GetHashCode() публичный Метод

Method used to get the hash code according to the algorithm: http://stackoverflow.com/questions/16340/how-do-i-generate-a-hashcode-from-a-byte-array-in-c/425184#425184
public GetHashCode ( ) : int
Результат int

Hash() публичный статический Метод

Hash a string to produce an ID
public static Hash ( string key ) : ID
key string Key string to convert
Результат ID

HostID() публичный статический Метод

Get an ID that will be the same between different calls on the same machine by the same app run by the same user. If that ID is taken, returns a random ID.
public static HostID ( ) : ID
Результат ID

ID() публичный Метод

Make a new ID from a byte array.
public ID ( byte data ) : System
data byte An array of exactly 20 bytes.
Результат System

ID() публичный Метод

Make a new ID starting from a string. Pay attention, the string is not hashed, it is simply translated to an ID object.
public ID ( string new_id ) : System
new_id string The string to translate
Результат System

RandomID() публичный статический Метод

Produce a random ID.
public static RandomID ( ) : ID
Результат ID

RandomizeBeyond() публичный Метод

Return a copy of ourselves that differs from us at the given bit and is random beyond that.
public RandomizeBeyond ( int bit ) : ID
bit int the bit to start to launch random bits
Результат ID

ToPathString() публичный Метод

Returns this ID represented as a path-safe string.
public ToPathString ( ) : string
Результат string

ToString() публичный Метод

Turn this ID into a string.
public ToString ( ) : string
Результат string

operator() публичный статический Метод

XOR operator. This is our distance metric in the DHT.
public static operator ( ) : ID
Результат ID

operator() публичный статический Метод

We need to compare these when measuring distance
public static operator ( ) : bool
Результат bool