Click or drag to resize
Counter Class
The Counter class is a mutable data type to encapsulate a counter.
Inheritance Hierarchy
SystemObject
  Algs4NetCounter

Namespace: Algs4Net
Assembly: Algs4Net (in Algs4Net.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public class Counter : IComparable<Counter>

The Counter type exposes the following members.

Constructors
  NameDescription
Public methodCounter
Initializes a new counter starting at 0, with the given id.
Top
Properties
  NameDescription
Public propertyTally
Returns the current value of this counter.
Top
Methods
  NameDescription
Public methodCompareTo
Compares this counter to the specified counter.
Public methodIncrement
Increments the counter by 1.
Public methodStatic memberMainTest
Reads two command-line integers N and T; creates N counters; increments T counters at random; and prints results.
Public methodToString
Returns a string representation of this counter.
(Overrides ObjectToString.)
Top
Remarks

For additional documentation, see Section 1.2 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

This class is a C# port from the original Java class Counter implementation by the respective authors.

See Also