org.archive.util.fingerprint
Class MemLongFPSet

java.lang.Object
  extended by org.archive.util.AbstractLongFPSet
      extended by org.archive.util.fingerprint.MemLongFPSet
All Implemented Interfaces:
java.io.Serializable, LongFPSet
Direct Known Subclasses:
LongFPSetCache

public class MemLongFPSet
extends AbstractLongFPSet
implements LongFPSet, java.io.Serializable

Open-addressing in-memory hash set for holding primitive long fingerprints.

Author:
Gordon Mohr
See Also:
Serialized Form

Field Summary
protected  byte[] slots
           
protected  long[] values
           
 
Fields inherited from class org.archive.util.AbstractLongFPSet
capacityPowerOfTwo, count, EMPTY, loadFactor
 
Constructor Summary
MemLongFPSet()
           
MemLongFPSet(int capacityPowerOfTwo, float loadFactor)
           
 
Method Summary
protected  void clearAt(long index)
           
protected  long getAt(long i)
          Get the stored value at the given slot.
protected  int getSlotState(long i)
          Check the state of a slot in the storage.
protected  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  void relocate(long val, long oldIndex, long newIndex)
           
protected  void setAt(long i, long val)
          Set the stored value at the given slot.
 
Methods inherited from class org.archive.util.AbstractLongFPSet
add, contains, count, remove, removeAt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.archive.util.fingerprint.LongFPSet
add, contains, count, remove
 

Field Detail

slots

protected byte[] slots

values

protected long[] values
Constructor Detail

MemLongFPSet

public MemLongFPSet()

MemLongFPSet

public MemLongFPSet(int capacityPowerOfTwo,
                    float loadFactor)
Parameters:
capacityPowerOfTwo - The capacity as the exponent of a power of 2. e.g if the capacity is 4 this means 2^^4 entries.
loadFactor - The load factor as a fraction. This gives the amount of free space to keep in the Set.
Method Detail

setAt

protected void setAt(long i,
                     long val)
Description copied from class: AbstractLongFPSet
Set the stored value at the given slot.

Specified by:
setAt in class AbstractLongFPSet
Parameters:
i - the slot index
val - the value to set

getAt

protected long getAt(long i)
Description copied from class: AbstractLongFPSet
Get the stored value at the given slot.

Specified by:
getAt in class AbstractLongFPSet
Parameters:
i - the slot index
Returns:
The stored value at the given slot.

makeSpace

protected void makeSpace()
Description copied from class: AbstractLongFPSet
Make additional space to keep the load under the target loadFactor level. Subclasses may grow or discard entries to satisfy.

Specified by:
makeSpace in class AbstractLongFPSet

relocate

protected void relocate(long val,
                        long oldIndex,
                        long newIndex)
Specified by:
relocate in class AbstractLongFPSet

getSlotState

protected int getSlotState(long i)
Description copied from class: AbstractLongFPSet
Check the state of a slot in the storage.

Specified by:
getSlotState in class AbstractLongFPSet
Parameters:
i - the index of the slot to check
Returns:
-1 if slot is filled; nonegative if full.

clearAt

protected void clearAt(long index)
Specified by:
clearAt in class AbstractLongFPSet

quickContains

public boolean quickContains(long fp)
Description copied from class: AbstractLongFPSet
Low-cost, non-definitive (except when true) contains test. Default answer of false is acceptable.

Specified by:
quickContains in interface LongFPSet
Overrides:
quickContains in class AbstractLongFPSet
Parameters:
fp - the fingerprint to check for
Returns:
true if contains the fingerprint
See Also:
LongFPSet.quickContains(long)


Copyright © 2003-2011 Internet Archive. All Rights Reserved.