|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.archive.util.AbstractLongFPSet
public abstract class AbstractLongFPSet
Shell of functionality for a Set of primitive long fingerprints, held in an array of possibly-empty slots. The implementation of that holding array is delegated to subclasses.
Capacity is always a power of 2.
Fingerprints are already assumed to be well-distributed, so the hashed position for a value is just its high-order bits.
Field Summary | |
---|---|
protected int |
capacityPowerOfTwo
the capacity of this set, specified as the exponent of a power of 2 |
protected long |
count
The current number of elements in the set |
protected static byte |
EMPTY
A constant used to indicate that a slot in the set storage is empty. |
protected float |
loadFactor
The load factor, as a fraction. |
Constructor Summary | |
---|---|
AbstractLongFPSet()
To support serialization TODO: verify needed? |
|
AbstractLongFPSet(int capacityPowerOfTwo,
float loadFactor)
Create a new AbstractLongFPSet with a given capacity and load Factor |
Method Summary | |
---|---|
boolean |
add(long val)
Add the given value to this set |
protected abstract void |
clearAt(long index)
|
boolean |
contains(long val)
Does this set contain the given value? |
long |
count()
Return the number of entries in this set. |
protected abstract long |
getAt(long i)
Get the stored value at the given slot. |
protected abstract int |
getSlotState(long i)
Check the state of a slot in the storage. |
protected abstract void |
makeSpace()
Make additional space to keep the load under the target loadFactor level. |
boolean |
quickContains(long fp)
Low-cost, non-definitive (except when true) contains test. |
protected abstract void |
relocate(long value,
long fromIndex,
long toIndex)
|
boolean |
remove(long l)
Remove a fingerprint from the set, if it is there |
protected void |
removeAt(long index)
Remove the value at the given index, relocating its successors as necessary. |
protected abstract void |
setAt(long i,
long l)
Set the stored value at the given slot. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static byte EMPTY
protected int capacityPowerOfTwo
protected float loadFactor
protected long count
Constructor Detail |
---|
public AbstractLongFPSet()
public AbstractLongFPSet(int capacityPowerOfTwo, float loadFactor)
capacityPowerOfTwo
- The capacity as the exponent of a power of 2.
e.g if the capacity is 4
this means 2^^4
entriesloadFactor
- The load factor as a fraction. This gives the amount
of free space to keep in the Set.Method Detail |
---|
public boolean contains(long val)
contains
in interface LongFPSet
val
- the fingerprint to check for
true
if the fingerprint is in the setLongFPSet.contains(long)
protected abstract int getSlotState(long i)
i
- the index of the slot to check
public long count()
count
in interface LongFPSet
LongFPSet.count()
public boolean add(long val)
add
in interface LongFPSet
val
- the fingerprint to add
true
if set has changed with this additionLongFPSet.add(long)
protected abstract void makeSpace()
protected abstract void setAt(long i, long l)
i
- the slot indexl
- the value to setprotected abstract long getAt(long i)
i
- the slot index
public boolean remove(long l)
LongFPSet
remove
in interface LongFPSet
l
- the fingerprint to remove
true
if we removed the fingerprintprotected void removeAt(long index)
index
- protected abstract void clearAt(long index)
protected abstract void relocate(long value, long fromIndex, long toIndex)
public boolean quickContains(long fp)
quickContains
in interface LongFPSet
fp
- the fingerprint to check for
true
if contains the fingerprintLongFPSet.quickContains(long)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |