public class SentinelIntSet extends Object
hash(int)
if the values might be poor
hash keys; Lucene docids should be fine.
The internal fields are exposed publicly to enable more efficient use at the expense of better O-O principles.
To iterate over the integers held in this set, simply use code like this:
SentinelIntSet set = ... for (int v : set.keys) { if (v == set.emptyVal) continue; //use v... }
Modifier and Type | Field and Description |
---|---|
int |
count |
int |
emptyVal |
int[] |
keys
A power-of-2 over-sized array holding the integers in the set along with empty values.
|
int |
rehashCount
the count at which a rehash should be done
|
Constructor and Description |
---|
SentinelIntSet(int size,
int emptyVal) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
exists(int key)
Does this set contain the specified integer?
|
int |
find(int key)
(internal) Returns the slot for this key, or -slot-1 if not found
|
int |
getSlot(int key)
(internal) Returns the slot for this key
|
int |
hash(int key)
(internal) Return the hash for the key.
|
int |
put(int key)
Puts this integer (key) in the set, and returns the slot index it was added to.
|
long |
ramBytesUsed()
Return the memory footprint of this class in bytes.
|
void |
rehash()
(internal) Rehashes by doubling
int[] key and filling with the old values. |
int |
size()
The number of integers in this set.
|
public int[] keys
public int count
public final int emptyVal
public int rehashCount
public SentinelIntSet(int size, int emptyVal)
size
- The minimum number of elements this set should be able to hold without rehashing
(i.e. the slots are guaranteed not to change)emptyVal
- The integer value to use for EMPTYpublic void clear()
public int hash(int key)
public int size()
public int getSlot(int key)
public int find(int key)
public boolean exists(int key)
public int put(int key)
public void rehash()
int[] key
and filling with the old values.public long ramBytesUsed()
Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.