java.lang.Object
net.i2p.kademlia.KBucketSet.DummyBucket<T>
- Type Parameters:
T- the key type of the bucket set
- All Implemented Interfaces:
KBucket<T>
- Enclosing class:
KBucketSet<T extends SimpleDataStructure>
private static class KBucketSet.DummyBucket<T extends SimpleDataStructure>extends Object implements KBucket<T>
For Collections.binarySearch. getRangeBegin == getRangeEnd.
Field Summary
FieldsConstructor Summary
ConstructorsMethod 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.
Field Details
r
private final int rRange number of the dummy bucket.
Constructor Details
DummyBucket
public DummyBucket(int range) Builds a dummy bucket for a range.- Parameters:
range- the range number
Method Details
getRangeBegin
public int getRangeBegin()Description copied from interface:KBucketLowest order high bit for difference keys. The lower-bounds distance of this bucket is 2**begin. If begin == 0, this is the closest bucket.- Specified by:
getRangeBeginin interfaceKBucket<T extends SimpleDataStructure>- Returns:
- the beginning of this bucket's range
getRangeEnd
public int getRangeEnd()Description copied from interface:KBucketHighest 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.- Specified by:
getRangeEndin interfaceKBucket<T extends SimpleDataStructure>- Returns:
- the end of this bucket's range
getKeyCount
public int getKeyCount()Description copied from interface:KBucketNumber of keys already contained in this kbucket.- Specified by:
getKeyCountin interfaceKBucket<T extends SimpleDataStructure>- Returns:
- the number of entries in this bucket
getEntries
Description copied from interface:KBucketRetrieve all routing table entries stored in the bucket.- Specified by:
getEntriesin interfaceKBucket<T extends SimpleDataStructure>- Returns:
- set of entries in this bucket
getEntries
Description copied from interface:KBucketAdd all entries in this bucket to the provided collector.- Specified by:
getEntriesin interfaceKBucket<T extends SimpleDataStructure>- Parameters:
collector- the collector to add entries to
clear
public void clear()Description copied from interface:KBucketRemove all entries from this bucket.- Specified by:
clearin interfaceKBucket<T extends SimpleDataStructure>
add
remove
Description copied from interface:KBucketRemove the key from the bucket.- Specified by:
removein interfaceKBucket<T extends SimpleDataStructure>- Parameters:
peer- the key to evict from this bucket- Returns:
- true if the key existed in the bucket before removing it, else false
setLastChanged
public void setLastChanged()Description copied from interface:KBucketUpdate the last-changed timestamp to now.- Specified by:
setLastChangedin interfaceKBucket<T extends SimpleDataStructure>
getLastChanged
public long getLastChanged()Description copied from interface:KBucketThe last-changed timestamp.- Specified by:
getLastChangedin interfaceKBucket<T extends SimpleDataStructure>- Returns:
- the last changed