com.hazelcast.util
Class ItemCounter<T>

java.lang.Object
  extended by com.hazelcast.util.ItemCounter<T>
Type Parameters:
T -

public final class ItemCounter<T>
extends Object

Non Thread-Safe Counter of things. It allows to count items without worrying about nulls.


Constructor Summary
ItemCounter()
           
 
Method Summary
 void add(T item, long delta)
          Add delta to the item
 boolean equals(Object o)
           
 long get(T item)
          Get current counter for an item item
 long getAndSet(T item, long value)
          Set counter for item and return previous value
 int hashCode()
           
 void reset()
          Reset state of the counter to 0.
 void set(T item, long value)
          Set counter of item to value
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ItemCounter

public ItemCounter()
Method Detail

get

public long get(T item)
Get current counter for an item item

Parameters:
item -
Returns:
current state of a counter for item

set

public void set(T item,
                long value)
Set counter of item to value

Parameters:
item - to set set the value for
value - a new value

add

public void add(T item,
                long delta)
Add delta to the item

Parameters:
item -
delta -

reset

public void reset()
Reset state of the counter to 0. It will NOT necessary remove all data referenced. Time complexity of this operation is O(n) where n is number of items.


getAndSet

public long getAndSet(T item,
                      long value)
Set counter for item and return previous value

Parameters:
item -
value -
Returns:

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.