|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object fulmine.util.collection.TtlSet<COMPONENT>
COMPONENT
- the element type contained by the listpublic final class TtlSet<COMPONENT>
A Set
implementation backed by an internal set. It tracks the
'time-to-live' of entries in the internal set. When entries are added, they
are given a TTL (time-to-live) and on each successive call to
Set.clear()
, Set.remove(Object)
,
Set.removeAll(Collection)
or any other 'reducing' method, the TTL is
decreased. When the TTL reaches 0, the entry is removed.
This is not thread safe.
Field Summary | |
---|---|
static int |
DEFAULT_TTL
The default TTL |
Constructor Summary | |
---|---|
TtlSet()
Standard constructor for the TtlSet . |
|
TtlSet(int ttl)
Construct the TtlSet with the specified TTL for any new entry
added. |
Method Summary | ||
---|---|---|
boolean |
add(COMPONENT o)
|
|
boolean |
addAll(Collection<? extends COMPONENT> c)
|
|
void |
clear()
Decreases the TTL of all entries by 1. |
|
boolean |
contains(Object o)
|
|
boolean |
containsAll(Collection<?> c)
|
|
boolean |
equals(Object o)
|
|
int |
hashCode()
|
|
boolean |
isEmpty()
|
|
Iterator<COMPONENT> |
iterator()
|
|
boolean |
remove(Object o)
Decreases the TTL of the element by 1. |
|
boolean |
removeAll(Collection<?> c)
For each element in the passed in collection, calls remove(Object) . |
|
boolean |
retainAll(Collection<?> c)
Unsupported. |
|
int |
size()
|
|
Object[] |
toArray()
|
|
|
toArray(T[] a)
|
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_TTL
Constructor Detail |
---|
public TtlSet()
TtlSet
. Sets the
startingTtl
to DEFAULT_TTL
.
public TtlSet(int ttl)
TtlSet
with the specified TTL for any new entry
added.
ttl
- the TTL for new entriesMethod Detail |
---|
public boolean add(COMPONENT o)
add
in interface Collection<COMPONENT>
add
in interface Set<COMPONENT>
public boolean addAll(Collection<? extends COMPONENT> c)
addAll
in interface Collection<COMPONENT>
addAll
in interface Set<COMPONENT>
public void clear()
clear
in interface Collection<COMPONENT>
clear
in interface Set<COMPONENT>
public boolean contains(Object o)
contains
in interface Collection<COMPONENT>
contains
in interface Set<COMPONENT>
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<COMPONENT>
containsAll
in interface Set<COMPONENT>
public boolean isEmpty()
isEmpty
in interface Collection<COMPONENT>
isEmpty
in interface Set<COMPONENT>
public Iterator<COMPONENT> iterator()
iterator
in interface Iterable<COMPONENT>
iterator
in interface Collection<COMPONENT>
iterator
in interface Set<COMPONENT>
public boolean remove(Object o)
remove
in interface Collection<COMPONENT>
remove
in interface Set<COMPONENT>
true
if the element was removed, false
otherwiseSet.remove(Object)
public boolean removeAll(Collection<?> c)
remove(Object)
.
removeAll
in interface Collection<COMPONENT>
removeAll
in interface Set<COMPONENT>
true
if any element in this TtlSet
was
removed as a result of this call, false
otherwiseSet.removeAll(Collection)
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<COMPONENT>
retainAll
in interface Set<COMPONENT>
UnsupportedOperationException
public int size()
size
in interface Collection<COMPONENT>
size
in interface Set<COMPONENT>
public Object[] toArray()
toArray
in interface Collection<COMPONENT>
toArray
in interface Set<COMPONENT>
public <T> T[] toArray(T[] a)
toArray
in interface Collection<COMPONENT>
toArray
in interface Set<COMPONENT>
public String toString()
toString
in class Object
public boolean equals(Object o)
equals
in interface Collection<COMPONENT>
equals
in interface Set<COMPONENT>
equals
in class Object
public int hashCode()
hashCode
in interface Collection<COMPONENT>
hashCode
in interface Set<COMPONENT>
hashCode
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |