tango.util.container.HashSet

License:

BSD style: see license.txt

Version:

Apr 2008: Initial release

Authors:

Kris

Since:

0.99.7

Based upon Doug Lea's Java collection package
class HashSet(V, alias Hash = Container.hash, alias Reap = Container.reap, alias Heap = Container.DefaultCollect) : IContainer!(V)
Hash table implementation of a Set
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Iterator iterator ()
int opApply (scope int delegate(ref V value) dg)

bool add (V element)
bool contains (V element)
bool take (ref V element)
bool remove (V element)
size_t remove (IContainer!(V) e)
bool replace (V oldElement, V newElement)

size_t size ()
bool isEmpty ()
V[] toArray (V[] dst)
HashSet dup ()
HashSet clear ()
HashSet reset ()

size_t buckets ()
void buckets (size_t cap)
float threshold ()
void threshold (float desired)
this(float f = defaultLoadFactor)
Construct a HashSet instance
~this()
Clean up when deleted
Iterator iterator() [final]
Return a generic iterator for contained elements
int opApply(scope int delegate(ref V value) dg) [final]
size_t size() [@property, final, const]
Return the number of elements contained
bool add(V element) [final]
Add a new element to the set. Does not add if there is an equivalent already present. Returns true where an element is added, false where it already exists Time complexity: O(1) average; O(n) worst.
bool contains(V element) [final]
Does this set contain the given element? Time complexity: O(1) average; O(n) worst
HashSet dup() [@property, final]
Make an independent copy of the container. Does not clone elements Time complexity: O(n)
size_t remove(V element, bool all) [final]
Remove the provided element. Returns true if found, false otherwise Time complexity: O(1) average; O(n) worst
bool remove(V element) [final]
Remove the provided element. Returns true if found, false otherwise Time complexity: O(1) average; O(n) worst
size_t replace(V oldElement, V newElement, bool all) [final]
Replace the first instance of oldElement with newElement. Returns true if oldElement was found and replaced, false otherwise.
bool replace(V oldElement, V newElement) [final]
Replace the first instance of oldElement with newElement. Returns true if oldElement was found and replaced, false otherwise.
bool take(ref V element) [final]
Remove and expose the first element. Returns false when no more elements are contained Time complexity: O(n)
void add(IContainer!(V) e) [public]
size_t remove(IContainer!(V) e) [public]
HashSet clear() [final]
Clears the HashMap contents. Various attributes are retained, such as the internal table itself. Invoke reset() to drop everything.
Time complexity: O(n)
HashSet reset() [final]
Reset the HashSet contents and optionally configure a new heap manager. This releases more memory than clear() does
Time complexity: O(1)
size_t buckets() [final]
Return the number of buckets
Time complexity: O(1)
HashSet buckets(size_t cap) [final]
Set the number of buckets and resize as required Time complexity: O(n)
float threshold() [final, const]
Return the resize threshold Time complexity: O(1)
void threshold(float desired) [final]
Set the resize threshold, and resize as required Time complexity: O(n)
HashSet cache(size_t chunk, size_t count = 0) [final]
Configure the assigned allocator with the size of each allocation block (number of nodes allocated at one time) and the number of nodes to pre-populate the cache with. Time complexity: O(n)
V[] toArray(V[] dst = null) [final]
Copy and return the contained set of values in an array, using the optional dst as a recipient (which is resized as necessary).
Returns a slice of dst representing the container values. Time complexity: O(n)
bool isEmpty() [final, const]
Is this container empty? Time complexity: O(1)
HashSet check() [final]
Sanity check