org.opengts.util
Class AccumulatorLong

java.lang.Object
  extended by org.opengts.util.AccumulatorLong

public class AccumulatorLong
extends java.lang.Object

Accumulator Long container. Typically used in conditions where it is desireable to pass an accumulator to an inner-class and have the value accessible from outside the inner-class. (If the accumulator is to be used from different threads in a multi-threaded environment, use "AtomicLong" instead).


Constructor Summary
AccumulatorLong()
          Constructor
AccumulatorLong(long val)
          Constructor
 
Method Summary
 void add(long v)
          Adds the specified value to the accumulator
 void decrement(long v)
          Decrement the value of the accumulator by 1
 long get()
          Gets the value of the accumulator
 void increment()
          Increment the value of the accumulator by 1
 long next()
          Increment, and return the next value
 long next(long v)
          Add the specified value, and return the result
 void set(long v)
          Sets the value of the accumulator
 void subtract(long v)
          Subtracts the specified value from the accumulator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AccumulatorLong

public AccumulatorLong()
Constructor


AccumulatorLong

public AccumulatorLong(long val)
Constructor

Parameters:
val - Initial value
Method Detail

set

public void set(long v)
Sets the value of the accumulator

Parameters:
v - The new value

get

public long get()
Gets the value of the accumulator

Returns:
The current value

add

public void add(long v)
Adds the specified value to the accumulator

Parameters:
v - The value to add

subtract

public void subtract(long v)
Subtracts the specified value from the accumulator

Parameters:
v - The value to subtract

increment

public void increment()
Increment the value of the accumulator by 1


decrement

public void decrement(long v)
Decrement the value of the accumulator by 1


next

public long next()
Increment, and return the next value

Returns:
The next value

next

public long next(long v)
Add the specified value, and return the result

Parameters:
v - The value to add
Returns:
The next value