MemoizeHashsetCountTracker<TIn, TOut>
A class in Root.Township, the global namespace.
A set of inputs mapped to outputs through a cached function, with a reference count per output. Raises events when an output first appears and when its last input goes.
Constructors
| Member | What it is |
|---|
MemoizeHashsetCountTracker(MemoizeHashset<TIn, TOut> evaluate, IEqualityComparer<TIn> inputComparer = null, IEqualityComparer<TOut> outputComparer = null) | Creates a MemoizeHashsetCountTracker from evaluate, inputComparer and outputComparer. |
Fields
2 private and internal fields
| Member | What it is |
|---|
private CountTracker<TOut> counter | Reference count per output. |
private MemoizeHashset<TIn, TOut> hashset | Inputs and their cached outputs. |
Properties
| Member | What it is |
|---|
int Count { get; } | Number of distinct outputs. |
Events
| Member | What it is |
|---|
event Action<TOut> FirstAdded | Raised when an output gets its first input. |
event Action<TOut> LastRemoved | Raised when an output loses its last input. |
Methods
| Member | What it is |
|---|
bool Add(TIn input, out TOut result) | Adds an input and gives its output. True, and FirstAdded raised, only if the output is new. |
void Clear() | Empties the set without raising events. |
bool Remove(TIn input, out TOut result) | Removes an input. True, and LastRemoved raised, only if its output has no inputs left. |
void RemoveAndClear() | Raises LastRemoved for every output, then empties the set. |
1 private and internal method
| Member | What it is |
|---|
private IEnumerator System.Collections.IEnumerable.GetEnumerator() | Enumerates the distinct outputs. |
Used in
Members of other types that take, return or hold a MemoizeHashsetCountTracker<TIn, TOut>: