org.aksw.commons.collections
Class CacheSet<K>

java.lang.Object
  extended by org.aksw.commons.collections.CacheSet<K>
Type Parameters:
K -
All Implemented Interfaces:
Iterable<K>, Collection<K>, Set<K>

public class CacheSet<K>
extends Object
implements Set<K>

T is the Timestamp object (e.g. Date, Long, etc). Multiple keys may have the same timestamp. At each time there may only be a single key.

Author:
raven JFreeChart

Constructor Summary
CacheSet()
          inclusive: wheter max distance is inclusive or exclusive.
CacheSet(int maxItemCount, boolean allowRenewal)
           
 
Method Summary
 boolean _add(K key)
          Put operations are done for the current time
 boolean add(K key)
           
 boolean addAll(Collection<? extends K> arg0)
           
 K addAndGetRemoved(K key)
          Adds an item, and returns an item that was removed - or null if no item was removed
 void clear()
           
 boolean contains(Object arg0)
           
 boolean containsAll(Collection<?> arg0)
           
 boolean equals(Object o)
           
 Integer getKeyTime(K key)
           
 int hashCode()
           
 boolean isEmpty()
           
 Iterator<K> iterator()
          FIXME Make sure that the iterator's remove method cannot be invoked directly
 boolean remove(Object arg0)
           
 boolean removeAll(Collection<?> items)
           
 boolean renew(Object key)
           
 boolean retainAll(Collection<?> arg0)
           
 Set<K> setMaxItemCount(int newMaxItemCount)
          Sets a new maximum distance.
 int size()
           
 Object[] toArray()
           
<X> X[]
toArray(X[] arg0)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CacheSet

public CacheSet()
inclusive: wheter max distance is inclusive or exclusive. e.g. if maxDistance is 10, and a distance is also 10, then inclusive: the item is retained (10 is included) exclusive: the item is removed


CacheSet

public CacheSet(int maxItemCount,
                boolean allowRenewal)
Method Detail

getKeyTime

public Integer getKeyTime(K key)

setMaxItemCount

public Set<K> setMaxItemCount(int newMaxItemCount)
Sets a new maximum distance. Returns all items that become outdated

Parameters:
newMaxItemCount -

renew

public boolean renew(Object key)

addAndGetRemoved

public K addAndGetRemoved(K key)
Adds an item, and returns an item that was removed - or null if no item was removed

Parameters:
key -
Returns:

add

public boolean add(K key)
Specified by:
add in interface Collection<K>
Specified by:
add in interface Set<K>

_add

public boolean _add(K key)
Put operations are done for the current time


addAll

public boolean addAll(Collection<? extends K> arg0)
Specified by:
addAll in interface Collection<K>
Specified by:
addAll in interface Set<K>

clear

public void clear()
Specified by:
clear in interface Collection<K>
Specified by:
clear in interface Set<K>

contains

public boolean contains(Object arg0)
Specified by:
contains in interface Collection<K>
Specified by:
contains in interface Set<K>

containsAll

public boolean containsAll(Collection<?> arg0)
Specified by:
containsAll in interface Collection<K>
Specified by:
containsAll in interface Set<K>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection<K>
Specified by:
isEmpty in interface Set<K>

iterator

public Iterator<K> iterator()
FIXME Make sure that the iterator's remove method cannot be invoked directly

Specified by:
iterator in interface Iterable<K>
Specified by:
iterator in interface Collection<K>
Specified by:
iterator in interface Set<K>

remove

public boolean remove(Object arg0)
Specified by:
remove in interface Collection<K>
Specified by:
remove in interface Set<K>

removeAll

public boolean removeAll(Collection<?> items)
Specified by:
removeAll in interface Collection<K>
Specified by:
removeAll in interface Set<K>

retainAll

public boolean retainAll(Collection<?> arg0)
Specified by:
retainAll in interface Collection<K>
Specified by:
retainAll in interface Set<K>

size

public int size()
Specified by:
size in interface Collection<K>
Specified by:
size in interface Set<K>

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection<K>
Specified by:
toArray in interface Set<K>

toArray

public <X> X[] toArray(X[] arg0)
Specified by:
toArray in interface Collection<K>
Specified by:
toArray in interface Set<K>

hashCode

public int hashCode()
Specified by:
hashCode in interface Collection<K>
Specified by:
hashCode in interface Set<K>
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Specified by:
equals in interface Collection<K>
Specified by:
equals in interface Set<K>
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.