|
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>
org.limewire.collection.FixedsizeForgetfulHashSet<E>
public class FixedsizeForgetfulHashSet<E>
Stores a fixed size of elements as a Set and removes elements
when that size is reached. FixedsizeForgetfulHashSet is a
Set version of FixedsizeForgetfulHashMap. Like
ForgetfulHashMap, values are "forgotten" using a FIFO replacement
policy.
FixedsizeForgetfulHashSet works in constant time.
FixedsizeForgetfulHashSet<String> ffhs = new FixedsizeForgetfulHashSet<String>(4);
ffhs.add("Abby");
System.out.println(ffhs);
if(!ffhs.add("Abby"))
System.out.println("The set already contained that item; Set contents: " + ffhs);
ffhs.add("Bob");
ffhs.add("Bob");
ffhs.add("Chris");
ffhs.add("Dan");
System.out.println(ffhs);
ffhs.add("Eric");
System.out.println(ffhs);
Output:
[Abby]
The set already contained that item; Set contents: [Abby]
[Abby, Bob, Chris, Dan]
[Bob, Chris, Dan, Eric]
| Constructor Summary | |
|---|---|
FixedsizeForgetfulHashSet(int size)
Constructs a new, empty set. |
|
FixedsizeForgetfulHashSet(int size,
int initialCapacity)
Constructs a new, empty set, using the given initialCapacity. |
|
FixedsizeForgetfulHashSet(int size,
int initialCapacity,
float loadFactor)
Constructs a new, empty set, using the given initialCapacity & loadFactor. |
|
| Method Summary | |
|---|---|
boolean |
add(E o)
Adds the specified element to this set if it is not already present. |
void |
clear()
Removes all of the elements from this set. |
FixedsizeForgetfulHashSet<E> |
clone()
Returns a shallow copy of this FixedsizeForgetfulHashSet instance: the elements themselves are not cloned. |
boolean |
contains(Object o)
Returns true if this set contains the specified element. |
boolean |
isEmpty()
|
boolean |
isFull()
Tests if the set is full. |
Iterator<E> |
iterator()
Returns an iterator over the elements in this set. |
boolean |
remove(Object o)
Removes the specified element from this set if it is present. |
E |
removeLRUEntry()
Removes the least recently used entry from the set |
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.Set |
|---|
addAll, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray |
| Constructor Detail |
|---|
public FixedsizeForgetfulHashSet(int size)
public FixedsizeForgetfulHashSet(int size,
int initialCapacity)
public FixedsizeForgetfulHashSet(int size,
int initialCapacity,
float loadFactor)
| Method Detail |
|---|
public boolean isFull()
public E removeLRUEntry()
public Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in interface Set<E>iterator in class AbstractCollection<E>ConcurrentModificationExceptionpublic int size()
size in interface Collection<E>size in interface Set<E>size in class AbstractCollection<E>public boolean isEmpty()
isEmpty in interface Collection<E>isEmpty in interface Set<E>isEmpty in class AbstractCollection<E>public boolean contains(Object o)
contains in interface Collection<E>contains in interface Set<E>contains in class AbstractCollection<E>o - element whose presence in this set is to be tested.
public boolean add(E o)
add in interface Collection<E>add in interface Set<E>add in class AbstractCollection<E>o - element to be added to this set.
public boolean remove(Object o)
remove in interface Collection<E>remove in interface Set<E>remove in class AbstractCollection<E>o - object to be removed from this set, if present.
public void clear()
clear in interface Collection<E>clear in interface Set<E>clear in class AbstractCollection<E>
public FixedsizeForgetfulHashSet<E> clone()
throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedException
|
LimeWire collection component api | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||