Packages

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).

Linear Supertypes
Serializable, Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. OpenHashSet
  2. Serializable
  3. Serializable
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new OpenHashSet()(implicit arg0: ClassTag[T])
  2. new OpenHashSet(initialCapacity: Int)(implicit arg0: ClassTag[T])
  3. new OpenHashSet(initialCapacity: Int, loadFactor: Double)(implicit arg0: ClassTag[T])

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. var _bitset: BitSet
    Attributes
    protected
  5. var _capacity: Int
    Attributes
    protected
  6. var _data: Array[T]
    Attributes
    protected
  7. var _growThreshold: Int
    Attributes
    protected
  8. var _mask: Int
    Attributes
    protected
  9. var _size: Int
    Attributes
    protected
  10. 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.

  11. 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.

  12. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  13. def capacity: Int

    The capacity of the set (i.e.

    The capacity of the set (i.e. size of the underlying array).

  14. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  15. def contains(k: T): Boolean

    Return true if this set contains the specified element.

  16. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  17. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  18. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  19. def getBitSet: BitSet
  20. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  21. def getPos(k: T): Int

    Return the position of the element in the underlying array, or INVALID_POS if it is not found.

  22. def getValue(pos: Int): T

    Return the value at the specified position.

  23. def getValueSafe(pos: Int): T

    Return the value at the specified position.

  24. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  25. val hasher: Hasher[T]
    Attributes
    protected
  26. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  27. def iterator: Iterator[T]
  28. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  29. def nextPos(fromPos: Int): Int

    Return the next position with an element stored, starting from the given position inclusively.

  30. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  31. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  32. 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).

  33. def size: Int

    Number of elements in the set.

  34. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  35. def toString(): String
    Definition Classes
    AnyRef → Any
  36. def union(other: OpenHashSet[T]): OpenHashSet[T]
  37. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  38. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  39. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from Serializable

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped