Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.archive.util.fingerprint
Class ArrayLongFPCache

    java.lang.Object
      org.archive.util.fingerprint.ArrayLongFPCache

All Implemented Interfaces:
  LongFPSet

    public class ArrayLongFPCache

extends java.lang.Object
implements LongFPSet

Simple long fingerprint cache using a backing array; any long maps to one of 'smear' slots. Longs inserted should be randomly distributed,

Author:
  gojomo

Field Summary
`(package private) long[]` | `cache`
`(package private) int` | `count`
`static int` | `DEFAULT_CAPACITY`
`static int` | `DEFAULT_SMEAR`
`(package private) int` | `smear`

Constructor Summary
`ArrayLongFPCache()`

Method Summary
`boolean` | `add(long l)` Add a fingerprint to the set.
`int` | `cacheLength()`
`boolean` | `contains(long l)` Does this set contain a given fingerprint.
`long` | `count()` get the number of elements in the Set
`boolean` | `quickContains(long fp)` Do a contains() check that doesn't require laggy activity (eg disk IO).
`boolean` | `remove(long l)` Remove a fingerprint from the set, if it is there
`void` | `setCapacity(int newCapacity)`

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

Field Detail

### DEFAULT_CAPACITY

    public static final int DEFAULT_CAPACITY

See Also:
  Constant Field Values

### DEFAULT_SMEAR

    public static final int DEFAULT_SMEAR

See Also:
  Constant Field Values

### cache

    long[] cache

### smear

    int smear

### count

    int count

Constructor Detail

### ArrayLongFPCache

    public ArrayLongFPCache()

Method Detail

### setCapacity

    public void setCapacity(int newCapacity)

### add

    public boolean add(long l)

  Description copied from interface: `LongFPSet`
  Add a fingerprint to the set. Note that subclasses can implement different policies on how to add - some might grow the available space, others might implement some type of LRU caching. In particular, you cannot on the `LongFPSet.count()` method returning 1 greater than before the addition.

  Specified by:
    `add` in interface `LongFPSet`
  Parameters:
    `l` - the fingerprint to add
  Returns:
    `true` if set has changed with this addition

### contains

    public boolean contains(long l)

  Description copied from interface: `LongFPSet`
  Does this set contain a given fingerprint.

  Specified by:
    `contains` in interface `LongFPSet`
  Parameters:
    `l` - the fingerprint to check for
  Returns:
    `true` if the fingerprint is in the set

### remove

    public boolean remove(long l)

  Description copied from interface: `LongFPSet`
  Remove a fingerprint from the set, if it is there

  Specified by:
    `remove` in interface `LongFPSet`
  Parameters:
    `l` - the fingerprint to remove
  Returns:
    `true` if we removed the fingerprint

### count

    public long count()

  Description copied from interface: `LongFPSet`
  get the number of elements in the Set

  Specified by:
    `count` in interface `LongFPSet`
  Returns:
    the number of elements in the Set

### quickContains

    public boolean quickContains(long fp)

  Description copied from interface: `LongFPSet`
  Do a contains() check that doesn't require laggy activity (eg disk IO). If this returns true, fp is definitely contained; if this returns false, fp *MAY* still be contained -- must use full-cost contains() to be sure.

  Specified by:
    `quickContains` in interface `LongFPSet`
  Parameters:
    `fp` - the fingerprint to check for
  Returns:
    `true` if contains the fingerprint

### cacheLength

    public int cacheLength()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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