org.opengts.util
Class AccumulatorInteger

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

public class AccumulatorInteger
extends java.lang.Object

Accumulator Integer 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 "AtomicInteger" instead).


Constructor Summary
AccumulatorInteger()
          Constructor
AccumulatorInteger(int val)
          Constructor
 
Method Summary
 void add(int v)
          Adds the specified value to the accumulator
 void decrement(int v)
          Decrement the value of the accumulator by 1
 int get()
          Gets the value of the accumulator
 void increment()
          Increment the value of the accumulator by 1
 int next()
          Increment, and return the next value
 int next(int v)
          Add the specified value, and return the result
 void set(int v)
          Sets the value of the accumulator
 void subtract(int 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

AccumulatorInteger

public AccumulatorInteger()
Constructor


AccumulatorInteger

public AccumulatorInteger(int val)
Constructor

Parameters:
val - Initial value
Method Detail

set

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

Parameters:
v - The new value

get

public int get()
Gets the value of the accumulator

Returns:
The current value

add

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

Parameters:
v - The value to add

subtract

public void subtract(int 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(int v)
Decrement the value of the accumulator by 1


next

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

Returns:
The next value

next

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

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