com.github.fedorchuck.developers_notification.helpers
Class Lifetime<V>

java.lang.Object
  extended by com.github.fedorchuck.developers_notification.helpers.Lifetime<V>

public class Lifetime<V>
extends java.lang.Object

Stack with the lifetime of objects. This stack automatic remove objects which are obsolete.

Author: Volodymyr Fedorchuk

Since:
0.2.0

Constructor Summary
Lifetime(long timeToLive, long updateTimerInterval)
          Constructor of stack.
 
Method Summary
 boolean contains(V object)
          Returns true if this stack contains the specified element.
 V get(int index)
          Returns the element at the specified position in this stack.
 V getOldest()
          Returns the element at the specified position in this stack.
 void put(V value)
          Appends the specified element to the end of this stack.
 int size()
          Returns the number of elements in this stack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Lifetime

public Lifetime(long timeToLive,
                long updateTimerInterval)
Constructor of stack. It receive data about time of living for added objects and time of interval updating for find and remove obsolete objects.

Parameters:
timeToLive - time of living for added objects
updateTimerInterval - time of interval updating for find and remove obsolete objects
Since:
0.2.0
Method Detail

put

public void put(V value)
Appends the specified element to the end of this stack. Append JUST unique elements.

Parameters:
value - element to be appended to this stack
Since:
0.2.0

get

public V get(int index)
Returns the element at the specified position in this stack.

Parameters:
index - index of the element to return
Returns:
the element at the specified position in this stack
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range
index less than 0 || index more or equal size()
Since:
0.2.0

getOldest

public V getOldest()
Returns the element at the specified position in this stack.

Returns:
the first element in this stack or null if this stack is empty
Since:
0.2.0

size

public int size()
Returns the number of elements in this stack.

Returns:
the number of elements in this stack
Since:
0.2.0

contains

public boolean contains(V object)
Returns true if this stack contains the specified element.

Parameters:
object - element whose presence in this stack is to be tested
Returns:
true if this stack contains the specified element
Since:
0.2.0