C# Class Kademlia.ID

Inheritance: IComparable
Afficher le fichier Open project: zencoders/sambatyon Class Usage Examples

Méthodes publiques

Méthode Description
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

Private Methods

Méthode Description
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.

Method Details

CompareTo() public méthode

Compare ourselves to an object
public CompareTo ( object obj ) : int
obj object An obect to compare to
Résultat int

DifferingBit() public méthode

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
Résultat int

Equals() public méthode

Method used to verify if two objects are equals.
public Equals ( object obj ) : bool
obj object The object to compare to
Résultat bool

FromString() public static méthode

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
Résultat ID

GetHashCode() public méthode

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
Résultat int

Hash() public static méthode

Hash a string to produce an ID
public static Hash ( string key ) : ID
key string Key string to convert
Résultat ID

HostID() public static méthode

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
Résultat ID

ID() public méthode

Make a new ID from a byte array.
public ID ( byte data ) : System
data byte An array of exactly 20 bytes.
Résultat System

ID() public méthode

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
Résultat System

RandomID() public static méthode

Produce a random ID.
public static RandomID ( ) : ID
Résultat ID

RandomizeBeyond() public méthode

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
Résultat ID

ToPathString() public méthode

Returns this ID represented as a path-safe string.
public ToPathString ( ) : string
Résultat string

ToString() public méthode

Turn this ID into a string.
public ToString ( ) : string
Résultat string

operator() public static méthode

XOR operator. This is our distance metric in the DHT.
public static operator ( ) : ID
Résultat ID

operator() public static méthode

We need to compare these when measuring distance
public static operator ( ) : bool
Résultat bool