Skip to main content

CountTracker<T>

A class in Root.Township, the global namespace.

Reference-counted set: tracks how many times each item was added and reports when one first appears or is fully removed.

Constructors​

MemberWhat it is
CountTracker(IEqualityComparer<T> comparer = null)Creates a CountTracker from comparer.

Fields​

1 private and internal field
MemberWhat it is
private Dictionary<T, int> countsCount per item.

Properties​

MemberWhat it is
int Count { get; }Number of distinct items held.

Methods​

MemberWhat it is
bool Add(T item)Adds one to the item's count. Returns true if it was not there before.
void Clear()Removes every item and count.
IEnumerator<T> GetEnumerator()Enumerates the distinct items.
bool Remove(T item)Takes one from the item's count. Returns true when it reaches zero and is removed.
1 private and internal method
MemberWhat it is
private IEnumerator System.Collections.IEnumerable.GetEnumerator()Enumerates the distinct items.

Used in​

Members of other types that take, return or hold a CountTracker&lt;T>: