public final class HashSet<A>
extends java.lang.Object
implements java.lang.Iterable<A>
HashMap| Constructor and Description |
|---|
HashSet(Equal<A> e,
Hash<A> h)
Construct a hash set with the given equality and hashing strategy.
|
HashSet(Equal<A> e,
Hash<A> h,
int initialCapacity)
Construct a hash set with the given equality and hashing strategy.
|
HashSet(Equal<A> e,
Hash<A> h,
int initialCapacity,
float loadFactor)
Construct a hash set with the given equality and hashing strategy.
|
| Modifier and Type | Method and Description |
|---|---|
static <A> HashSet<A> |
arrayHashSet(A... as)
Create a HashSet from the array.
|
static <A> HashSet<A> |
arrayHashSet(Equal<A> e,
Hash<A> h,
A... as)
Create a HashSet from the array.
|
void |
clear()
Clear all elements from this hash set.
|
boolean |
contains(A a)
Determines if this hash set contains the given element.
|
boolean |
delete(A a)
Deletes the given element from this hash set.
|
static <A> HashSet<A> |
empty()
Creates an empty HashSet
|
static <A> HashSet<A> |
empty(Equal<A> e,
Hash<A> h)
Creates a new HashSet using the given Equal and Hash
|
boolean |
eq(A a1,
A a2)
Compare two values for equality using the underlying equality strategy.
|
static <A> HashSet<A> |
fromSet(java.util.Set<A> s) |
int |
hash(A a)
Compute the hash of the given value using the underlying hashing strategy.
|
static <A> HashSet<A> |
hashSet(A... as)
Create a HashSet from the array.
|
static <A> HashSet<A> |
hashSet(Equal<A> e,
Hash<A> h,
A... as)
Create a HashSet from the array.
|
boolean |
isEmpty()
Determines if this hash set contains any elements.
|
static <A> HashSet<A> |
iterableHashSet(Equal<A> e,
Hash<A> h,
java.lang.Iterable<A> it)
Create a HashSet from the Iterable.
|
static <A> HashSet<A> |
iterableHashSet(java.lang.Iterable<A> it)
Create a HashSet from the Iterable.
|
java.util.Iterator<A> |
iterator()
Returns an iterator for this hash set.
|
static <A> HashSet<A> |
iteratorHashSet(Equal<A> e,
Hash<A> h,
java.util.Iterator<A> it)
Create a HashSet from the Iterator.
|
static <A> HashSet<A> |
iteratorHashSet(java.util.Iterator<A> it)
Create a HashSet from the Iterator.
|
void |
set(A a)
Insert the given element into this hash set.
|
int |
size()
Returns the number of entries in this hash set.
|
java.util.Collection<A> |
toCollection()
Projects an immutable collection of this hash set.
|
java.util.List<A> |
toJavaList() |
java.util.Set<A> |
toJavaSet() |
List<A> |
toList()
Returns a list projection of this hash set.
|
public HashSet(Equal<A> e, Hash<A> h)
e - The equality strategy.h - The hashing strategy.public HashSet(Equal<A> e, Hash<A> h, int initialCapacity)
e - The equality strategy.h - The hashing strategy.initialCapacity - The initial capacity.public java.util.Iterator<A> iterator()
for-each loop.iterator in interface java.lang.Iterable<A>public boolean eq(A a1, A a2)
a1 - One value to compare.a2 - The other value to compare.true if the two values are equal, false otherwise.public int hash(A a)
a - The value to computer the hash of.public static <A> HashSet<A> empty(Equal<A> e, Hash<A> h)
public static <A> HashSet<A> empty()
public static <A> HashSet<A> iterableHashSet(java.lang.Iterable<A> it)
public static <A> HashSet<A> iterableHashSet(Equal<A> e, Hash<A> h, java.lang.Iterable<A> it)
public static <A> HashSet<A> iteratorHashSet(java.util.Iterator<A> it)
public static <A> HashSet<A> iteratorHashSet(Equal<A> e, Hash<A> h, java.util.Iterator<A> it)
@SafeVarargs public static <A> HashSet<A> arrayHashSet(A... as)
@SafeVarargs public static <A> HashSet<A> arrayHashSet(Equal<A> e, Hash<A> h, A... as)
@SafeVarargs public static <A> HashSet<A> hashSet(A... as)
@SafeVarargs public static <A> HashSet<A> hashSet(Equal<A> e, Hash<A> h, A... as)
public boolean contains(A a)
a - The element to look for in this hash set.true if this hash set contains the given element, false otherwise.public void set(A a)
a - The element to insert.public void clear()
public boolean isEmpty()
true if this hash set contains no elements, false otherwise.public int size()
public boolean delete(A a)
a - The element to delete from this hash set.true if this hash set contained the given element prior to deletion, false
otherwise.public List<A> toList()
public java.util.List<A> toJavaList()
public java.util.Set<A> toJavaSet()
public static <A> HashSet<A> fromSet(java.util.Set<A> s)
public java.util.Collection<A> toCollection()