## net.i2p.router.networkdb.kademlia
Class KBucketSet

    java.lang.Object
      net.i2p.router.networkdb.kademlia.KBucketSet

     class KBucketSet

extends java.lang.Object

In memory storage of buckets sorted by the XOR metric from the local router's identity, with bucket N containing routers BASE^N through BASE^N+1 away, up through 2^256 bits away (since we use SHA256).

Field Summary
`static int` `BASE`
`static int` `BUCKET_SIZE`
`static int` `KEYSIZE_BITS`
`static int` `NUM_BUCKETS`

Constructor Summary
`KBucketSet(I2PAppContext context, Hash us)`

Method Summary
`boolean` `add(Hash peer)` Return true if the peer is new to the bucket it goes in, or false if it was already in it
`protected KBucket` `createBucket(int start, int end)`
`protected void` `createBuckets()`
`void` `displayBuckets()`
`java.util.Set` `getAll()`
`void` `getAll(SelectionCollector collector)`
`java.util.Set` `getAll(java.util.Set toIgnore)`
`KBucket` `getBucket(int bucket)`
`static void` `main(java.lang.String[] args)`
`int` `pickBucket(Hash key)`
`boolean` `remove(Hash entry)`
`int` `size()` Not an exact count (due to concurrency issues) but generally correct
`java.lang.String` `toString()`
`(package private) static java.lang.String` `toString(byte[] b)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### BASE

    public static final int BASE

See Also:
  Constant Field Values

### KEYSIZE_BITS

    public static final int KEYSIZE_BITS

See Also:
  Constant Field Values

### NUM_BUCKETS

    public static final int NUM_BUCKETS

See Also:
  Constant Field Values

### BUCKET_SIZE

    public static final int BUCKET_SIZE

See Also:
  Constant Field Values

Constructor Detail

### KBucketSet

    public KBucketSet(I2PAppContext context,
                      Hash us)

Method Detail

### add

    public boolean add(Hash peer)

  Return true if the peer is new to the bucket it goes in, or false if it was already in it

### size

    public int size()

  Not an exact count (due to concurrency issues) but generally correct

### remove

    public boolean remove(Hash entry)

### getAll

    public java.util.Set getAll()

### getAll

    public java.util.Set getAll(java.util.Set toIgnore)

### getAll

    public void getAll(SelectionCollector collector)

### pickBucket

    public int pickBucket(Hash key)

### getBucket

    public KBucket getBucket(int bucket)

### createBuckets

    protected void createBuckets()

### createBucket

    protected KBucket createBucket(int start,
                                   int end)

### displayBuckets

    public void displayBuckets()

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### toString

    static final java.lang.String toString(byte[] b)

### main

    public static void main(java.lang.String[] args)