proper.util
Class Counter

java.lang.Object
  extended by proper.util.Counter

public class Counter
extends java.lang.Object

A little helper class that can do counting based on Objects , i.e. we have Object identifiers we want to count.

Version:
$Revision: 1.2 $
Author:
FracPete

Constructor Summary
Counter()
          initializes the object
 
Method Summary
 void dec(java.lang.Object id)
          decreases the count for the given id by 1
 void dec(java.lang.Object id, int count)
          decreases the count for the given id by the given amount
 int get(java.lang.Object id)
          returns the count for the given id
 java.util.Enumeration ids()
          returns a sorted enumeration of the stored IDs
 void inc(java.lang.Object id)
          increases the count for the given id by 1
 void inc(java.lang.Object id, int count)
          increases the count for the given id by the given amount
static void main(java.lang.String[] args)
          for testing only
 java.lang.String toString()
          returns the counter in a string representation
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Counter

public Counter()
initializes the object

Method Detail

inc

public void inc(java.lang.Object id)
increases the count for the given id by 1


inc

public void inc(java.lang.Object id,
                int count)
increases the count for the given id by the given amount


dec

public void dec(java.lang.Object id)
decreases the count for the given id by 1


dec

public void dec(java.lang.Object id,
                int count)
decreases the count for the given id by the given amount


get

public int get(java.lang.Object id)
returns the count for the given id


ids

public java.util.Enumeration ids()
returns a sorted enumeration of the stored IDs


toString

public java.lang.String toString()
returns the counter in a string representation

Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)
for testing only