|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.varienaja.util.DenseSet
public class DenseSet
A Dense Set is a set of long-values. The Set is meant to contain many consecutive longs while using as little memory as possible. The more holes there are in the list of long-values, the more memory will be consumed. The memory consumption per hole is constant and independent of the size of the hole. The advantage of a DenseSet over a BitSet, is that the DenseSet has a constant size. It can hold MAX_LONG values, and still use two longs memory. Only the holes consume memory. A Bitset containing MAX_LONG bits would take an insane amount of 2^64/8 bytes, regardless of the amount of holes. So, when the amount of holes stays low enough, the DenseSet is a better choise than a BitSet.
Field Summary | |
---|---|
protected java.util.Set<org.varienaja.util.Range> |
_ranges
|
Constructor Summary | |
---|---|
DenseSet()
|
Method Summary | |
---|---|
boolean |
add(long l)
Adds a long to the Set of longs. |
void |
clear()
Removes all Long-values from the Set |
boolean |
contains(long l)
Checks whether a certain value exists in the Set. |
boolean |
equals(java.lang.Object o)
|
long |
get(long index)
Searches for a long-value at a specific position. |
int |
hashCode()
|
java.lang.String |
prettyPrint()
Returns a string representation of the contents of the set in the format: a-b,c,d-e, ... |
boolean |
remove(long l)
/** Removes a long value from the Set of longs. |
int |
size()
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.util.Set<org.varienaja.util.Range> _ranges
Constructor Detail |
---|
public DenseSet()
Method Detail |
---|
public int size()
public boolean add(long l)
l
- The value to be added.
public boolean remove(long l)
l
- The long-value to be removed.
public void clear()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String prettyPrint()
public long get(long index)
index
- The position to look in
public boolean contains(long l)
l
- The value to check for.
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |