com.aliasi.util
Class Counter

java.lang.Object
  extended by java.lang.Number
      extended by com.aliasi.util.Counter
All Implemented Interfaces:
Serializable

public class Counter
extends Number

A reassignable integer usable for counting. Counters do not override Obect's methods hashCode() or equals(), so two counters with the same value are not necessarily equal.

The value of a counter is stored as an integer. No checks are done in the increment methods to ensure that the results remain within bounds.

Since:
LingPipe1.0
Version:
1.0.7
Author:
Bob Carpenter
See Also:
Serialized Form

Constructor Summary
Counter()
          Create a counter with initial count 0.
Counter(int count)
          Create a counter with the specified count value.
 
Method Summary
 double doubleValue()
          Returns the value of this counter as a double.
 float floatValue()
          Returns the value of this counter as a float.
 void increment()
          Increments the current count value.
 void increment(int n)
          Increment the count value by the specified amount.
 int intValue()
          Returns the value of this counter as an int.
 long longValue()
          Returns the value of this counter as a long.
 void set(int count)
          Sets the count to the specified value.
 String toString()
          Return a string representation of this counter's value.
 int value()
          Returns the current count value.
 
Methods inherited from class java.lang.Number
byteValue, shortValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Counter

public Counter()
Create a counter with initial count 0.


Counter

public Counter(int count)
Create a counter with the specified count value.

Parameters:
count - Initial value of counter.
Method Detail

value

public int value()
Returns the current count value.

Returns:
Current count value.

increment

public void increment()
Increments the current count value.


increment

public void increment(int n)
Increment the count value by the specified amount.

Parameters:
n - Amount by which to increase the count value.

set

public void set(int count)
Sets the count to the specified value.

Parameters:
count - New value of the counter.

doubleValue

public double doubleValue()
Returns the value of this counter as a double.

Specified by:
doubleValue in class Number
Returns:
The value of this counter as a double.

floatValue

public float floatValue()
Returns the value of this counter as a float.

Specified by:
floatValue in class Number
Returns:
The value of this counter as a float.

intValue

public int intValue()
Returns the value of this counter as an int.

Specified by:
intValue in class Number
Returns:
The value of this counter as an int.

longValue

public long longValue()
Returns the value of this counter as a long.

Specified by:
longValue in class Number
Returns:
The value of this counter as an int.

toString

public String toString()
Return a string representation of this counter's value.

Overrides:
toString in class Object
Returns:
String representation of this counter's value.