|
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(java.util.Collection<? extends T> coll)
Adds all the elements in collection to this. |
|
void |
clear()
|
|
boolean |
contains(java.lang.Object arg0)
|
|
boolean |
containsAll(java.util.Collection<?> arg0)
|
|
boolean |
isEmpty()
|
|
java.util.Iterator<T> |
iterator()
|
|
boolean |
remove(java.lang.Object arg0)
|
|
boolean |
removeAll(java.util.Collection<?> arg0)
|
|
boolean |
retainAll(java.util.Collection<?> arg0)
|
|
int |
size()
|
|
java.lang.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 java.util.Collection<T>size in interface java.util.Set<T>public boolean isEmpty()
isEmpty in interface java.util.Collection<T>isEmpty in interface java.util.Set<T>public boolean contains(java.lang.Object arg0)
contains in interface java.util.Collection<T>contains in interface java.util.Set<T>public java.util.Iterator<T> iterator()
iterator in interface java.lang.Iterable<T>iterator in interface java.util.Collection<T>iterator in interface java.util.Set<T>public java.lang.Object[] toArray()
toArray in interface java.util.Collection<T>toArray in interface java.util.Set<T>public <B> B[] toArray(B[] arg0)
toArray in interface java.util.Collection<T>toArray in interface java.util.Set<T>public boolean add(T arg0)
add in interface java.util.Collection<T>add in interface java.util.Set<T>public boolean remove(java.lang.Object arg0)
remove in interface java.util.Collection<T>remove in interface java.util.Set<T>public boolean containsAll(java.util.Collection<?> arg0)
containsAll in interface java.util.Collection<T>containsAll in interface java.util.Set<T>public boolean addAll(java.util.Collection<? extends T> coll)
addAll in interface java.util.Collection<T>addAll in interface java.util.Set<T>(java.util.Collection)public boolean retainAll(java.util.Collection<?> arg0)
retainAll in interface java.util.Collection<T>retainAll in interface java.util.Set<T>(java.util.Collection)public boolean removeAll(java.util.Collection<?> arg0)
removeAll in interface java.util.Collection<T>removeAll in interface java.util.Set<T>public void clear()
clear in interface java.util.Collection<T>clear in interface java.util.Set<T>
|
LimeWire collection component api | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||