Show / Hide Table of Contents

Interface IBag<T>

A bag between instances of two types. The polymorphism base for bag implementations in Towel.

Inherited Members
IDataStructure<T>.ToArray()
ISteppable<T>.StepperBreak<TStep>(TStep)
DataStructure.ICountable.Count
DataStructure.IClearable.Clear()
DataStructure.IAuditable<T>.Contains(T)
DataStructure.IAddable<T>.TryAdd(T)
Namespace: Towel.DataStructures
Assembly: Towel.dll
Syntax
public interface IBag<T> : IDataStructure<T>, ISteppable<T>, System.Collections.Generic.IEnumerable<T>, DataStructure.ICountable, DataStructure.IClearable, DataStructure.IAuditable<T>, DataStructure.IRemovable<T>, DataStructure.IAddable<T>
Type Parameters
Name Description
T

The generic type to be stored in this data structure.

Properties

| Improve this Doc View Source

Item[T]

Allows indexed look-up of the structure. (Set does not replace the Add() method)

Declaration
int this[T countedValue] { get; set; }
Parameters
Type Name Description
T countedValue

The "index" to access of the structure.

Property Value
Type Description
System.Int32

The value at the index of the requested key.

Methods

| Improve this Doc View Source

CountsBreak<TStep>(TStep)

Performs a function on every pair in a bag.

Declaration
StepStatus CountsBreak<TStep>(TStep step = default(TStep))
    where TStep : struct, IFunc<(int Count, T Value), StepStatus>
Parameters
Type Name Description
TStep step

The step function to perform on every pair.

Returns
Type Description
StepStatus

The status of traversal.

Type Parameters
Name Description
TStep

The type of the step function.

| Improve this Doc View Source

CountsToArray()

Gets an array with all the pairs in the bag.

Declaration
(int Count, T Value)[] CountsToArray()
Returns
Type Description
System.ValueTuple<System.Int32, T>[]

An array with all the pairs in the bag.

| Improve this Doc View Source

GetCounts()

Gets an enumerator that will traverse the pairs of the bag.

Declaration
System.Collections.Generic.IEnumerable<(int Count, T Value)> GetCounts()
Returns
Type Description
System.Collections.Generic.IEnumerable<System.ValueTuple<System.Int32, T>>

An enumerator that will traverse the pairs of the bag.

| Improve this Doc View Source

TryAdd(T, Int32)

Tries to add a value to the bag.

Declaration
(bool Success, Exception? Exception) TryAdd(T value, int count)
Parameters
Type Name Description
T value

The value to be added.

System.Int32 count

The number of values to be added.

Returns
Type Description
System.ValueTuple<System.Boolean, System.Nullable<Exception>>
  • Success: true if the values was added or false if not.
  • ? Exception: the exception that occured if the add failed.
| Improve this Doc View Source

TryGet(T)

Tries to get the count of a value.

Declaration
(bool Success, Exception? Exception, int? Count) TryGet(T value)
Parameters
Type Name Description
T value

The value to get the count of.

Returns
Type Description
System.ValueTuple<System.Boolean, System.Nullable<Exception>, System.Nullable<System.Int32>>
  • Success: true if the key was found or false if not.
  • ? Exception: the exception that occured if the get failed.
  • ? Value: the value if the key was found or default if not.
| Improve this Doc View Source

TryRemove(T)

Tries to remove a value from the bag.

Declaration
(bool Success, Exception? Exception, int? OldCount, int? NewCount) TryRemove(T value)
Parameters
Type Name Description
T value

The value to remove from the bag.

Returns
Type Description
System.ValueTuple<System.Boolean, System.Nullable<Exception>, System.Nullable<System.Int32>, System.Nullable<System.Int32>>
  • Success: true if the values were removed or false if not.
  • ? Exception: the exception that occured if the remove failed.
  • ? OldCount: the count of the value before the removal.
  • ? NewCount: the count of the value after the removal.
| Improve this Doc View Source

TryRemove(T, Int32)

Tries to remove a value from the bag.

Declaration
(bool Success, Exception? Exception, int? OldCount, int? NewCount) TryRemove(T value, int count)
Parameters
Type Name Description
T value

The value to be removed.

System.Int32 count

The number of values to be removed.

Returns
Type Description
System.ValueTuple<System.Boolean, System.Nullable<Exception>, System.Nullable<System.Int32>, System.Nullable<System.Int32>>
  • Success: true if the values were removed or false if not.
  • ? Exception: the exception that occured if the remove failed.
  • ? OldCount: the count of the value before the removal.
  • ? NewCount: the count of the value after the removal.
| Improve this Doc View Source

TrySet(T, Int32)

Sets value in the bag.

Declaration
(bool Success, Exception? Exception, bool? Existed, int? OldCount) TrySet(T value, int count)
Parameters
Type Name Description
T value

The value to be set.

System.Int32 count

The number of values to set.

Returns
Type Description
System.ValueTuple<System.Boolean, System.Nullable<Exception>, System.Nullable<System.Boolean>, System.Nullable<System.Int32>>
  • Success: true if the key+value was set or false if not.
  • ? Exception: the exception that occured if the set failed.

Explicit Interface Implementations

| Improve this Doc View Source

DataStructure.IRemovable<T>.TryRemove(T)

Declaration
(bool Success, Exception? Exception) DataStructure.IRemovable<T>.TryRemove(T value)
Parameters
Type Name Description
T value
Returns
Type Description
System.ValueTuple<System.Boolean, System.Nullable<Exception>>

Extension Methods

Steppable.Stepper<T>(ISteppable<T>, Action<T>)
Steppable.Stepper<T, TStep>(ISteppable<T>, TStep)
Steppable.StepperBreak<T>(ISteppable<T>, Func<T, StepStatus>)
Bag.Get<T>(IBag<T>, T)
Bag.Set<T>(IBag<T>, T, Int32)
Bag.Counts<T>(IBag<T>, Action<(Int32 Count, T Value)>)
Bag.Counts<T, TStep>(IBag<T>, TStep)
Bag.CountsBreak<T>(IBag<T>, Func<(Int32 Count, T Value), StepStatus>)
DataStructure.Add<T>(DataStructure.IAddable<T>, T)
DataStructure.Remove<T>(DataStructure.IRemovable<T>, T)
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX