|
Copyright Workingmouse Pty. Ltd. 2007, 2008 This software is released under an open source BSD licence. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectfj.data.HashSet<A>
public final class HashSet<A>
A mutable hash set that guarantees uniqueness of its elements providing O(1) lookup.
HashMap| Constructor Summary | |
|---|---|
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. |
|
| Method Summary | |
|---|---|
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. |
boolean |
eq(A a1,
A a2)
Compare two values for equality using the underlying equality strategy. |
int |
hash(A a)
Compute the hash of the given value using the underlying hashing strategy. |
boolean |
isEmpty()
Determines if this hash set contains any elements. |
Iterator<A> |
iterator()
Returns an iterator for this hash set. |
void |
set(A a)
Insert the given element into this hash set. |
int |
size()
Returns the number of entries in this hash set. |
Collection<A> |
toCollection()
Projects an immutable collection of this hash set. |
List<A> |
toList()
Returns a list projection of this hash set. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
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 HashSet(Equal<A> e,
Hash<A> h,
int initialCapacity,
float loadFactor)
e - The equality strategy.h - The hashing strategy.initialCapacity - The initial capacity.loadFactor - The load factor.| Method Detail |
|---|
public Iterator<A> iterator()
for-each loop.
iterator in interface 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 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 Collection<A> toCollection()
|
Copyright Workingmouse Pty. Ltd. 2007, 2008 This software is released under an open source BSD licence. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||