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 Details

    • r

      private final int r
      Range 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: KBucket
      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.
      Specified by:
      getRangeBegin in interface KBucket<T extends SimpleDataStructure>
      Returns:
      the beginning of this bucket's range
    • getRangeEnd

      public int getRangeEnd()
      Description copied from interface: KBucket
      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.
      Specified by:
      getRangeEnd in interface KBucket<T extends SimpleDataStructure>
      Returns:
      the end of this bucket's range
    • getKeyCount

      public int getKeyCount()
      Description copied from interface: KBucket
      Number of keys already contained in this kbucket.
      Specified by:
      getKeyCount in interface KBucket<T extends SimpleDataStructure>
      Returns:
      the number of entries in this bucket
    • getEntries

      public Set<T> getEntries()
      Description copied from interface: KBucket
      Retrieve all routing table entries stored in the bucket.
      Specified by:
      getEntries in interface KBucket<T extends SimpleDataStructure>
      Returns:
      set of entries in this bucket
    • getEntries

      public void getEntries(SelectionCollector<T> collector)
      Description copied from interface: KBucket
      Add all entries in this bucket to the provided collector.
      Specified by:
      getEntries in interface KBucket<T extends SimpleDataStructure>
      Parameters:
      collector - the collector to add entries to
    • clear

      public void clear()
      Description copied from interface: KBucket
      Remove all entries from this bucket.
      Specified by:
      clear in interface KBucket<T extends SimpleDataStructure>
    • add

      public boolean add(T peer)
      Description copied from interface: KBucket
      Add the peer to the bucket.
      Specified by:
      add in interface KBucket<T extends SimpleDataStructure>
      Parameters:
      peer - the key to store; a full bucket may still accept it if the trimmer makes room
      Returns:
      true if added
    • remove

      public boolean remove(T peer)
      Description copied from interface: KBucket
      Remove the key from the bucket.
      Specified by:
      remove in interface KBucket<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: KBucket
      Update the last-changed timestamp to now.
      Specified by:
      setLastChanged in interface KBucket<T extends SimpleDataStructure>
    • getLastChanged

      public long getLastChanged()
      Description copied from interface: KBucket
      The last-changed timestamp.
      Specified by:
      getLastChanged in interface KBucket<T extends SimpleDataStructure>
      Returns:
      the last changed