class OpenHashSet[T] extends Serializable
A simple, fast hash set optimized for non-null insertion-only use case, where keys are never removed.
The underlying implementation uses Scala compiler's specialization to generate optimized storage for four primitive types (Long, Int, Double, and Float). It is much faster than Java's standard HashSet while incurring much less memory overhead. This can serve as building blocks for higher level data structures such as an optimized HashMap.
This OpenHashSet is designed to serve as building blocks for higher level data structures such as an optimized hash map. Compared with standard hash set implementations, this class provides its various callbacks interfaces (e.g. allocateFunc, moveFunc) and interfaces to retrieve the position of a key in the underlying array.
It uses quadratic probing with a power-of-2 hash table size, which is guaranteed to explore all spaces for each key (see http://en.wikipedia.org/wiki/Quadratic_probing).
- Alphabetic
- By Inheritance
- OpenHashSet
- Serializable
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
var
_bitset: BitSet
- Attributes
- protected
-
var
_capacity: Int
- Attributes
- protected
-
var
_data: Array[T]
- Attributes
- protected
-
var
_growThreshold: Int
- Attributes
- protected
-
var
_mask: Int
- Attributes
- protected
-
var
_size: Int
- Attributes
- protected
-
def
add(k: T): Unit
Add an element to the set.
Add an element to the set. If the set is over capacity after the insertion, grow the set and rehash all elements.
-
def
addWithoutResize(k: T): Int
Add an element to the set.
Add an element to the set. This one differs from add in that it doesn't trigger rehashing. The caller is responsible for calling rehashIfNeeded.
Use (retval & POSITION_MASK) to get the actual position, and (retval & NONEXISTENCE_MASK) == 0 for prior existence.
- returns
The position where the key is placed, plus the highest order bit is set if the key does not exists previously.
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
capacity: Int
The capacity of the set (i.e.
The capacity of the set (i.e. size of the underlying array).
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
contains(k: T): Boolean
Return true if this set contains the specified element.
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
- def getBitSet: BitSet
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
getPos(k: T): Int
Return the position of the element in the underlying array, or INVALID_POS if it is not found.
-
def
getValue(pos: Int): T
Return the value at the specified position.
-
def
getValueSafe(pos: Int): T
Return the value at the specified position.
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
val
hasher: Hasher[T]
- Attributes
- protected
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def iterator: Iterator[T]
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
nextPos(fromPos: Int): Int
Return the next position with an element stored, starting from the given position inclusively.
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
rehashIfNeeded(k: T, allocateFunc: (Int) ⇒ Unit, moveFunc: (Int, Int) ⇒ Unit): Unit
Rehash the set if it is overloaded.
Rehash the set if it is overloaded.
- k
A parameter unused in the function, but to force the Scala compiler to specialize this method.
- allocateFunc
Callback invoked when we are allocating a new, larger array.
- moveFunc
Callback invoked when we move the key from one position (in the old data array) to a new position (in the new data array).
-
def
size: Int
Number of elements in the set.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
- def union(other: OpenHashSet[T]): OpenHashSet[T]
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()