public class KBucketSet<T extends SimpleDataStructure>
extends java.lang.Object
コンストラクタ | 説明 |
---|---|
KBucketSet(I2PAppContext context,
T us,
int max,
int b) |
Use the default trim strategy, which removes a random entry.
|
KBucketSet(I2PAppContext context,
T us,
int max,
int b,
KBucketTrimmer<T> trimmer) |
Use the supplied trim strategy.
|
修飾子とタイプ | メソッド | 説明 |
---|---|---|
boolean |
add(T peer) |
|
void |
clear() |
|
(package private) T |
generateRandomKey(KBucket<T> bucket) |
Generate a random key to go within this bucket
Package private for testing only.
|
java.util.Set<T> |
getAll() |
|
java.util.Set<T> |
getAll(java.util.Set<T> toIgnore) |
|
void |
getAll(SelectionCollector<T> collector) |
|
(package private) java.util.List<KBucket<T>> |
getBuckets() |
Returned list is a copy of the bucket list, closest first,
with the actual buckets (not a copy).
|
java.util.List<T> |
getClosest(int max) |
The keys closest to us.
|
java.util.List<T> |
getClosest(int max,
java.util.Collection<T> toIgnore) |
The keys closest to us.
|
java.util.List<T> |
getClosest(T key,
int max) |
The keys closest to the key.
|
java.util.List<T> |
getClosest(T key,
int max,
java.util.Collection<T> toIgnore) |
The keys closest to the key.
|
java.util.List<T> |
getExploreKeys(long age) |
For every bucket that hasn't been updated in this long,
or isn't close to full,
generate a random key that would be a member of that bucket.
|
(package private) int |
getRange(T key) |
The number of bits minus 1 (range number) for the xor of the key.
|
boolean |
remove(T entry) |
|
int |
size() |
The current number of entries.
|
java.lang.String |
toString() |
public KBucketSet(I2PAppContext context, T us, int max, int b)
us
- the local identity (typically a SHA1Hash or Hash)
The class must have a zero-argument constructor.max
- the Kademlia value "k", the max per bucket, k >= 4b
- the Kademlia value "b", split buckets an extra 2**(b-1) times,
b > 0, use 1 for bittorrent, Kademlia paper recommends 5public KBucketSet(I2PAppContext context, T us, int max, int b, KBucketTrimmer<T> trimmer)
public boolean add(T peer)
public int size()
public boolean remove(T entry)
public void clear()
public java.util.Set<T> getAll()
public void getAll(SelectionCollector<T> collector)
public java.util.List<T> getClosest(int max)
public java.util.List<T> getClosest(int max, java.util.Collection<T> toIgnore)
public java.util.List<T> getClosest(T key, int max)
public java.util.List<T> getClosest(T key, int max, java.util.Collection<T> toIgnore)
java.util.List<KBucket<T>> getBuckets()
int getRange(T key)
public java.util.List<T> getExploreKeys(long age)
T generateRandomKey(KBucket<T> bucket)
public java.lang.String toString()
toString
クラス内 java.lang.Object