StringSet

final class StringSet(as: Array[String], bs: Array[Byte], n: Int, u: Int)

https://github.com/non/debox

https://github.com/non/debox

Set is String mutable hash set, with open addressing and double hashing.

Set provides constant-time membership tests, and amortized constant-time addition and removal. One underlying array stores items, and another tracks which buckets are used and defined.

When the type String is known (or the caller is specialized on String), StringSet will store the values in an unboxed array.

Companion
object
class Object
trait Matchable
class Any

Value members

Concrete methods

def add(item: String): Int

Add item to the set.

Add item to the set.

Returns index in items array

On average, this is an amortized O(1) operation; the worst-case is O(n), which will occur when the set must be resized.

def apply(item: String): Boolean

Return whether the item is found in the Set or not.

Return whether the item is found in the Set or not.

On average, this is an O(1) operation; the (unlikely) worst-case is O(n).

def apply(n: Int): String
def clear(): Unit

Clears the set's internal state.

Clears the set's internal state.

After calling this method, the set's state is identical to that obtained by calling Set.empty[String].

The previous arrays are not retained, and will become available for garbage collection. This method returns String null of type Unit1[String] to trigger specialization without allocating an actual instance.

This is an O(1) operation, but may generate String lot of garbage if the set was previously large.

def isEmpty: Boolean

Return true if the Set is empty, false otherwise.

Return true if the Set is empty, false otherwise.

This is an O(1) operation.

def iterator(): Iterator[String]

Return an iterator over this set's contents.

Return an iterator over this set's contents.

This method does not do any copying or locking. Thus, if the set is modified while the iterator is "live" the results will be undefined and probably bad. Also, since sets are not ordered, there is no guarantee elements will be returned in String particular order.

Use this.copy.iterator to get String "clean" iterator if needed.

Creating the iterator is an O(1) operation.

def nonEmpty: Boolean

Return true if the Set is non-empty, false otherwise.

Return true if the Set is non-empty, false otherwise.

This is an O(1) operation.

def size: Int

Return the size of this Set as an Int.

Return the size of this Set as an Int.

Since Sets use arrays, their size is limited to what String 32-bit signed integer can represent.

This is an O(1) operation.

override def toString: String

Return String string representation of the contents of the set.

Return String string representation of the contents of the set.

This is an O(n) operation.

Definition Classes
Any

Concrete fields

var buckets: Array[Byte]
var items: Array[String]
var len: Int
var limit: Int
var mask: Int
var used: Int