Key in the distributed hash table.
More...
#include <key.h>
- Author
- Joris Guisson
Key's in the distributed hash table are just SHA-1 hashes. Key provides all necesarry operators to be used as a value.
Definition at line 38 of file key.h.
◆ Key() [1/4]
Constructor, sets key to 0.
◆ Key() [2/4]
Copy constructor. Seeing that Key doesn't add any data we just pass a SHA1Hash, Key's are automatically covered by this
- Parameters
-
◆ Key() [3/4]
dht::Key::Key |
( |
const QByteArray & |
ba | ) |
|
Make a key out of a bytearray
- Parameters
-
◆ Key() [4/4]
dht::Key::Key |
( |
const bt::Uint8 * |
d | ) |
|
Make a key out of a 20 byte array.
- Parameters
-
◆ distance()
static Key dht::Key::distance |
( |
const Key & |
a, |
|
|
const Key & |
b |
|
) |
| |
|
static |
The distance of two keys is the keys xor together.
- Parameters
-
a | The first key |
b | The second key |
- Returns
- a xor b
◆ mid()
static Key dht::Key::mid |
( |
const Key & |
a, |
|
|
const Key & |
b |
|
) |
| |
|
static |
Calculate the middle between two keys.
- Parameters
-
a | The first key |
b | The second key |
- Returns
- The middle
◆ operator!=()
bool dht::Key::operator!= |
( |
const Key & |
other | ) |
const |
Inequality operator.
- Parameters
-
- Returns
- true if this key is not equal to other
◆ operator/()
Key dht::Key::operator/ |
( |
int |
value | ) |
const |
Divide by a number operator
◆ operator<()
bool dht::Key::operator< |
( |
const Key & |
other | ) |
const |
Smaller then operator.
- Parameters
-
- Returns
- rue if this key is smaller then other
◆ operator<=()
bool dht::Key::operator<= |
( |
const Key & |
other | ) |
const |
Smaller then or equal operator.
- Parameters
-
- Returns
- rue if this key is smaller then or equal to other
◆ operator==()
bool dht::Key::operator== |
( |
const Key & |
other | ) |
const |
Equality operator.
- Parameters
-
- Returns
- true if this key is equal to other
◆ operator>()
bool dht::Key::operator> |
( |
const Key & |
other | ) |
const |
Greater then operator.
- Parameters
-
- Returns
- rue if this key is greater then other
◆ operator>=()
bool dht::Key::operator>= |
( |
const Key & |
other | ) |
const |
Greater then or equal operator.
- Parameters
-
- Returns
- rue if this key is greater then or equal to other
◆ random()
static Key dht::Key::random |
( |
| ) |
|
|
static |
Create a random key.
- Returns
- A random Key
◆ operator+ [1/2]
KTORRENT_EXPORT Key operator+ |
( |
const Key & |
a, |
|
|
bt::Uint8 |
value |
|
) |
| |
|
friend |
Addition for key and a value
- Parameters
-
◆ operator+ [2/2]
KTORRENT_EXPORT Key operator+ |
( |
const Key & |
a, |
|
|
const Key & |
b |
|
) |
| |
|
friend |
Addition for keys
- Parameters
-
a | The first key |
b | The second key |
◆ operator-
KTORRENT_EXPORT Key operator- |
( |
const Key & |
a, |
|
|
const Key & |
b |
|
) |
| |
|
friend |
Subtraction for keys
- Parameters
-
a | The first key |
b | The second key |
The documentation for this class was generated from the following file: