|
LimeWire Collection Component API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractSet<E>
java.util.HashSet<E>
org.limewire.collection.FixedSizeArrayHashSet<E>
public class FixedSizeArrayHashSet<E>
Provides a fixed size HashSet with index access. The replacement
policy is FIFO (First in, First out) and the iteration order is from newest
to oldest.
Adding an existing element resets the FIFO order; the newly added element is now the "last in" element.
FixedSizeArrayHashSet does not support the null element.
FixedSizeArrayHashSet<String> fsah = new FixedSizeArrayHashSet<String>(4);
fsah.add("Abby");
fsah.add("Bob");
fsah.add("Chris");
fsah.add("Dan");
fsah.add("Eric");
fsah.add("Fred");
System.out.println(fsah);
if(!fsah.add("Chris"))
System.out.println("Tried to add Chris again, but it already exists in the collection (though Chris was put to the first item).");
System.out.println(fsah);
System.out.println("Index access: " + fsah.get(0));
fsah.remove("Chris");
System.out.println(fsah);
Output:
[Fred, Eric, Dan, Chris]
Tried to add Chris again, but it already exists in the collection (though Chris was put to the first item).
[Chris, Fred, Eric, Dan]
Index access: Chris
[Fred, Eric, Dan]
| Constructor Summary | |
|---|---|
FixedSizeArrayHashSet(Collection<? extends E> c)
Creates a FixedSizeArrayHashSet with maximum capacity the
size of the provided collection and adds all the elements of that
collection. |
|
FixedSizeArrayHashSet(int maxCapacity)
creates a FixedSizeArrayHashSet with the specified maximum capacity. |
|
FixedSizeArrayHashSet(int maxCapacity,
Collection<? extends E> c)
Creates a FixedSizeArrayHashSet with the provided maximum capacity and
adds elements from the provided collection. |
|
FixedSizeArrayHashSet(int maxCapacity,
int initialCapacity)
|
|
FixedSizeArrayHashSet(int maxCapacity,
int initialCapacity,
float loadFactor)
|
|
| Method Summary | |
|---|---|
boolean |
add(E o)
|
void |
clear()
|
Object |
clone()
|
boolean |
contains(Object o)
|
E |
get(int i)
Retrieves the element at index i. |
boolean |
isEmpty()
|
Iterator<E> |
iterator()
|
boolean |
remove(Object o)
|
int |
size()
|
| Methods inherited from class java.util.AbstractSet |
|---|
equals, hashCode, removeAll |
| Methods inherited from class java.util.AbstractCollection |
|---|
addAll, containsAll, retainAll, toArray, toArray, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Collection |
|---|
addAll, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray |
| Methods inherited from interface java.util.Set |
|---|
addAll, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray |
| Constructor Detail |
|---|
public FixedSizeArrayHashSet(int maxCapacity)
public FixedSizeArrayHashSet(Collection<? extends E> c)
FixedSizeArrayHashSet with maximum capacity the
size of the provided collection and adds all the elements of that
collection.
public FixedSizeArrayHashSet(int maxCapacity,
Collection<? extends E> c)
FixedSizeArrayHashSet with the provided maximum capacity and
adds elements from the provided collection. If the capacity is less than
the size of the collection, elements will get ejected with FIFO policy.
public FixedSizeArrayHashSet(int maxCapacity,
int initialCapacity,
float loadFactor)
public FixedSizeArrayHashSet(int maxCapacity,
int initialCapacity)
| Method Detail |
|---|
public Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in interface Set<E>iterator in class HashSet<E>public int size()
size in interface Collection<E>size in interface Set<E>size in class HashSet<E>public boolean isEmpty()
isEmpty in interface Collection<E>isEmpty in interface Set<E>isEmpty in class HashSet<E>public boolean contains(Object o)
contains in interface Collection<E>contains in interface Set<E>contains in class HashSet<E>public boolean add(E o)
add in interface Collection<E>add in interface Set<E>add in class HashSet<E>public boolean remove(Object o)
remove in interface Collection<E>remove in interface Set<E>remove in class HashSet<E>public void clear()
clear in interface Collection<E>clear in interface Set<E>clear in class HashSet<E>public Object clone()
clone in class HashSet<E>public E get(int i)
RandomAccessCollection
get in interface RandomAccessCollection<E>
|
LimeWire Collection Component API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||