Show / Hide Table of Contents

Class Bag

Static Extension class for bag interface implementers.

Inheritance
System.Object
Bag
Namespace: Towel.DataStructures
Assembly: Towel.dll
Syntax
public static class Bag : object

Methods

| Improve this Doc View Source

Counts<T>(IBag<T>, Action<(Int32 Count, T Value)>)

Performs a function on every pair in a bag.

Declaration
public static void Counts<T>(this IBag<T> bag, Action<(int Count, T Value)> step)
Parameters
Type Name Description
IBag<T> bag

The bag to traverse the pairs of.

Action<System.ValueTuple<System.Int32, T>> step

The step function to perform on every pair.

Type Parameters
Name Description
T

The type of values in the bag.

| Improve this Doc View Source

Counts<T, TStep>(IBag<T>, TStep)

Performs a function on every pair in a bag.

Declaration
public static void Counts<T, TStep>(this IBag<T> bag, TStep step = default(TStep))
    where TStep : struct, IAction<(int Count, T Value)>
Parameters
Type Name Description
IBag<T> bag

The bag to traverse the pairs of.

TStep step

The step function to perform on every pair.

Type Parameters
Name Description
T

The type of values in the bag.

TStep

The type of step function to perform on every pair.

| Improve this Doc View Source

CountsBreak<T>(IBag<T>, Func<(Int32 Count, T Value), StepStatus>)

Performs a function on every pair in a bag.

Declaration
public static StepStatus CountsBreak<T>(this IBag<T> bag, Func<(int Count, T Value), StepStatus> step)
Parameters
Type Name Description
IBag<T> bag

The bag to traverse the pairs of.

Func<System.ValueTuple<System.Int32, T>, StepStatus> step

The step function to perform on every pair.

Returns
Type Description
StepStatus

The status of the traversal.

Type Parameters
Name Description
T

The type of values in the bag.

| Improve this Doc View Source

Get<T>(IBag<T>, T)

Gets the count of a value in a bag.

Declaration
public static int Get<T>(this IBag<T> bag, T value)
Parameters
Type Name Description
IBag<T> bag

The bag to get the count of a value in.

T value

The value to get the count of.

Returns
Type Description
System.Int32

The count of the values in the bag.

Type Parameters
Name Description
T

The generic type to be stored in this data structure.

| Improve this Doc View Source

Set<T>(IBag<T>, T, Int32)

Sets the count of a value in a bag.

Declaration
public static (bool Existed, int? OldCount) Set<T>(this IBag<T> bag, T value, int count)
Parameters
Type Name Description
IBag<T> bag

The bag to set the value count in.

T value

The value to set the count of.

System.Int32 count

The count to set the number of value's to.

Returns
Type Description
System.ValueTuple<System.Boolean, System.Nullable<System.Int32>>
  • Existed: True if the value already existed or false.
  • ? OldCount: The previous count if the value existed or default.
Type Parameters
Name Description
T

The generic type to be stored in this data structure.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX