Package net.i2p.kademlia
Class RandomTrimmer<T extends SimpleDataStructure>
- java.lang.Object
-
- net.i2p.kademlia.RandomTrimmer<T>
-
- All Implemented Interfaces:
KBucketTrimmer<T>
- Direct Known Subclasses:
RandomIfOldTrimmer
public class RandomTrimmer<T extends SimpleDataStructure> extends Object implements KBucketTrimmer<T>
Removes a random element. Not resistant to flooding.- Since:
- 0.9.2 in i2psnark, moved to core in 0.9.10
-
-
Field Summary
Fields Modifier and Type Field Description protected I2PAppContext
_ctx
-
Constructor Summary
Constructors Constructor Description RandomTrimmer(I2PAppContext ctx, int max)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
trim(KBucket<T> kbucket, T toAdd)
Called from add() just before adding the entry.
-
-
-
Field Detail
-
_ctx
protected final I2PAppContext _ctx
-
-
Constructor Detail
-
RandomTrimmer
public RandomTrimmer(I2PAppContext ctx, int max)
-
-
Method Detail
-
trim
public boolean trim(KBucket<T> kbucket, T toAdd)
Description copied from interface:KBucketTrimmer
Called from add() just before adding the entry. You may call getEntries() and/or remove() from here. Do NOT call add(). To always discard a newer entry, always return false.- Specified by:
trim
in interfaceKBucketTrimmer<T extends SimpleDataStructure>
- Parameters:
kbucket
- the kbucket that is now too big- Returns:
- true to actually add the entry.
-
-