- Type Parameters:
T- type of SimpleDataStructure objects stored in the bucket
- All Known Implementing Classes:
KBucketImpl, KBucketSet.DummyBucket
public interface KBucket<T extends SimpleDataStructure>
Group, without inherent ordering, a set of keys a certain distance away from a local key, using XOR as the distance metric
Refactored from net.i2p.router.networkdb.kademlia.
Method Summary
All MethodsModifier and TypeMethodDescriptionbooleanAdd the peer to the bucket.voidclear()Remove all entries from this bucket.Retrieve all routing table entries stored in the bucket.voidgetEntries(SelectionCollector<T> collector) Add all entries in this bucket to the provided collector.intNumber of keys already contained in this kbucket.longThe last-changed timestamp.intLowest order high bit for difference keys.intHighest high bit for the difference keys.booleanRemove the key from the bucket.voidUpdate the last-changed timestamp to now.
Method Details
getRangeBegin
int getRangeBegin()Lowest order high bit for difference keys. The lower-bounds distance of this bucket is 2**begin. If begin == 0, this is the closest bucket.- Returns:
- the beginning of this bucket's range
getRangeEnd
int getRangeEnd()Highest high bit for the difference keys. The upper-bounds distance of this bucket is (2**(end+1)) - 1. If begin == end, the bucket cannot be split further. If end == (numbits - 1), this is the furthest bucket.- Returns:
- the end of this bucket's range
getKeyCount
int getKeyCount()Number of keys already contained in this kbucket.- Returns:
- the number of entries in this bucket
add
Add the peer to the bucket.- Parameters:
key- the key to store; a full bucket may still accept it if the trimmer makes room- Returns:
- true if added
remove
Remove the key from the bucket.- Parameters:
key- the key to evict from this bucket- Returns:
- true if the key existed in the bucket before removing it, else false
setLastChanged
void setLastChanged()Update the last-changed timestamp to now.getLastChanged
long getLastChanged()The last-changed timestamp.- Returns:
- the last changed
getEntries
getEntries
Add all entries in this bucket to the provided collector.- Parameters:
collector- the collector to add entries to
clear
void clear()Remove all entries from this bucket.