Interface IBag<T>
A bag between instances of two types. The polymorphism base for bag implementations in Towel.
Inherited Members
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 SourceItem[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 SourceCountsBreak<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. |
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. |
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. |
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>> |
|
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>> |
|
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>> |
|
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>> |
|
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>> |
|
Explicit Interface Implementations
| Improve this Doc View SourceDataStructure.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>> |