Class Counter<T>
- Namespace
- AlgorithmsSW.Counter
- Assembly
- AlgorithmsSW.dll
Supports all classes in the .NET class hierarchy and provides low-level services to derived classes. This is the ultimate base class of all .NET classes; it is the root of the type hierarchy.
public class Counter<T> : ICounter<T>, IEnumerable<KeyValuePair<T, int>>, IEnumerable
Type Parameters
T
- Inheritance
-
Counter<T>
- Implements
-
ICounter<T>
- Inherited Members
- Extension Methods
Constructors
Counter(IComparer<T>)
public Counter(IComparer<T> comparer)
Parameters
comparer
IComparer<T>
Properties
this[T]
Gets the number of times an item has been added (minus the number of times it has been removed).
public int this[T item] { get; }
Parameters
item
TThe item to get the count of.
Property Value
Keys
Gets the items that have been added (and not removed the same number of times).
public IEnumerable<T> Keys { get; }
Property Value
- IEnumerable<T>
Methods
Add(T)
Increments the count of an item by 1.
public void Add(T item)
Parameters
item
TThe item to add.
Clear()
Sets the count of all items to 0.
public void Clear()
GetCount(T)
public int GetCount(T item)
Parameters
item
T
Returns
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<KeyValuePair<T, int>> GetEnumerator()
Returns
- IEnumerator<KeyValuePair<T, int>>
An enumerator that can be used to iterate through the collection.
Remove(T)
Reduces the count of an item by 1.
public void Remove(T item)
Parameters
item
TThe item to remove.
RemoveAll(T)
public void RemoveAll(T item)
Parameters
item
T