Parsing Engine

danbikel.util
Class IntCounter

java.lang.Object
  extended by danbikel.util.IntCounter
All Implemented Interfaces:
Serializable, Comparable

public class IntCounter
extends Object
implements Comparable, Serializable

A class to hold an int that may be incremented or decremented.

See Also:
Serialized Form

Constructor Summary
IntCounter()
          Constructs an IntCounter with an initial value of zero.
IntCounter(int count)
          Constructs an IntCounter with the specified initial value.
 
Method Summary
 int compareTo(Object obj)
           
 boolean equals(Object obj)
          Returns true if the specified object is an instance of IntCounter and if its count is the same as that of this IntCounter object, false otherwise.
 int get()
          Gets the current count.
 int hashCode()
           
 int increment()
          Increments this counter by 1, returning the previous count (postincrement).
 void increment(int n)
          Increments this counter by the specified integer.
 void set(int count)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntCounter

public IntCounter()
Constructs an IntCounter with an initial value of zero.


IntCounter

public IntCounter(int count)
Constructs an IntCounter with the specified initial value.

Method Detail

increment

public final int increment()
Increments this counter by 1, returning the previous count (postincrement).


increment

public final void increment(int n)
Increments this counter by the specified integer. If the integer is negative, then the counter will get decremented by the absolute value of n.


get

public final int get()
Gets the current count.


set

public final void set(int count)

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Returns true if the specified object is an instance of IntCounter and if its count is the same as that of this IntCounter object, false otherwise.

Overrides:
equals in class Object
Parameters:
obj - the object to compare with this object
Returns:
true if the specified object is an instance of IntCounter and if its count is the same as that of this IntCounter object, false otherwise

toString

public String toString()
Overrides:
toString in class Object

compareTo

public int compareTo(Object obj)
Specified by:
compareTo in interface Comparable

Parsing Engine

Author: Dan Bikel.