|
LimeWire Collection Component API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.limewire.collection.FixedSizeExpiringSet<T>
public class FixedSizeExpiringSet<T>
Maintains, at most, a fixed size of objects in a Set
for a specified time. FixedSizeExpiringSet never
holds more entries than specified in the constructor. This class
is a hash-based Set and therefore, objects must correctly
contain a Object.hashCode() and Object.equals(Object).
Note: expiration times longer than Long.MAX_VALUE / 10^6 will be truncated.
try{
FixedSizeExpiringSet<String> fses = new FixedSizeExpiringSet<String>(4, 2000);
fses.add("Abby");
fses.add("Bob");
fses.add("Chris");
fses.add("Dan");
fses.add("Eric");
System.out.println("Size: " + fses.size());
Thread.sleep(1000);
System.out.println("Size: " + fses.size());
Thread.sleep(2000);
System.out.println("Size (after expiration): " + fses.size());
} catch(Exception e) {
e.printStackTrace();
}
Output:
Size: 4
Size: 4
Size (after expiration): 0
| Constructor Summary | |
|---|---|
FixedSizeExpiringSet()
Simple constructor for the FixedSizeExpiringSet. |
|
FixedSizeExpiringSet(int size)
Constructor for the FixedSizeExpiringSet. |
|
FixedSizeExpiringSet(int size,
long expireTime)
Constructor for the FixedSizeExpiringSet |
|
| Method Summary | ||
|---|---|---|
boolean |
add(T arg0)
|
|
boolean |
addAll(Collection<? extends T> coll)
Adds all the elements in collection to this. |
|
void |
clear()
|
|
boolean |
contains(Object arg0)
|
|
boolean |
containsAll(Collection<?> arg0)
(non-Javadoc) |
|
boolean |
isEmpty()
|
|
Iterator<T> |
iterator()
|
|
boolean |
remove(Object arg0)
|
|
boolean |
removeAll(Collection<?> arg0)
|
|
boolean |
retainAll(Collection<?> arg0)
|
|
int |
size()
|
|
Object[] |
toArray()
|
|
|
toArray(B[] arg0)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Set |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public FixedSizeExpiringSet()
public FixedSizeExpiringSet(int size)
size - the max size of the set
public FixedSizeExpiringSet(int size,
long expireTime)
size - the max size of the setexpireTime - the time to keep an entry| Method Detail |
|---|
public int size()
size in interface Collection<T>size in interface Set<T>public boolean isEmpty()
isEmpty in interface Collection<T>isEmpty in interface Set<T>public boolean contains(Object arg0)
contains in interface Collection<T>contains in interface Set<T>public Iterator<T> iterator()
iterator in interface Iterable<T>iterator in interface Collection<T>iterator in interface Set<T>public Object[] toArray()
toArray in interface Collection<T>toArray in interface Set<T>public <B> B[] toArray(B[] arg0)
toArray in interface Collection<T>toArray in interface Set<T>public boolean add(T arg0)
add in interface Collection<T>add in interface Set<T>public boolean remove(Object arg0)
remove in interface Collection<T>remove in interface Set<T>public boolean containsAll(Collection<?> arg0)
containsAll in interface Collection<T>containsAll in interface Set<T>(java.util.Collection)public boolean addAll(Collection<? extends T> coll)
addAll in interface Collection<T>addAll in interface Set<T>(java.util.Collection)public boolean retainAll(Collection<?> arg0)
retainAll in interface Collection<T>retainAll in interface Set<T>(java.util.Collection)public boolean removeAll(Collection<?> arg0)
removeAll in interface Collection<T>removeAll in interface Set<T>public void clear()
clear in interface Collection<T>clear in interface Set<T>
|
LimeWire Collection Component API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||