Show / Hide Table of Contents

Class BagMap<T, TMap>

An unsorted structure of unique items.

Inheritance
System.Object
BagMap<T, TMap>
Implements
IBag<T>
IDataStructure<T>
ISteppable<T>
System.Collections.Generic.IEnumerable<T>
DataStructure.ICountable
DataStructure.IClearable
DataStructure.IAuditable<T>
DataStructure.IRemovable<T>
DataStructure.IAddable<T>
ICloneable<BagMap<T, TMap>>
Namespace: Towel.DataStructures
Assembly: Towel.dll
Syntax
public class BagMap<T, TMap> : object, IBag<T>, IDataStructure<T>, ISteppable<T>, System.Collections.Generic.IEnumerable<T>, DataStructure.ICountable, DataStructure.IClearable, DataStructure.IAuditable<T>, DataStructure.IRemovable<T>, DataStructure.IAddable<T>, ICloneable<BagMap<T, TMap>> where TMap : IMap<int, T>, ICloneable<TMap>
Type Parameters
Name Description
T

The generic type of the structure.

TMap

The type of function for quality checking T values.

Properties

| Improve this Doc View Source

Count

Gets the current count of the data structure.

Declaration
public int Count { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Item[T]

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

Declaration
public 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

Clear()

Returns the data structure to an empty state.

Declaration
public void Clear()
| Improve this Doc View Source

Clone()

Clones a T.

Declaration
public BagMap<T, TMap> Clone()
Returns
Type Description
BagMap<T, TMap>

A clone of the T.

| Improve this Doc View Source

Contains(T)

Checks if the data structure contains a value.

Declaration
public bool Contains(T value)
Parameters
Type Name Description
T value

The value to look for in the data structure.

Returns
Type Description
System.Boolean

True if the value exists in the data structure. False if not.

| Improve this Doc View Source

CountsBreak<TStep>(TStep)

Performs a function on every pair in a bag.

Declaration
public 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
public (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
public 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

GetEnumerator()

Declaration
public System.Collections.Generic.IEnumerator<T> GetEnumerator()
Returns
Type Description
System.Collections.Generic.IEnumerator<T>
| Improve this Doc View Source

StepperBreak<TStep>(TStep)

Traverses values and invokes a function on every T value.

Declaration
public StepStatus StepperBreak<TStep>(TStep step = default(TStep))
    where TStep : struct, IFunc<T, StepStatus>
Parameters
Type Name Description
TStep step

The function to invoke on every T value.

Returns
Type Description
StepStatus

The status of the traversal.

Type Parameters
Name Description
TStep

The type of function to invoke on every T value.

| Improve this Doc View Source

ToArray()

Constructs an array with the values of this data structure.

Declaration
public T[] ToArray()
Returns
Type Description
T[]

An array with the values of this data structure.

| Improve this Doc View Source

TryAdd(T)

Tries to add a value to a data structure.

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

The value to add to the data structure.

Returns
Type Description
System.ValueTuple<System.Boolean, System.Nullable<Exception>>

True if the value was added or false if not.

| Improve this Doc View Source

TryAdd(T, Int32)

Tries to add a value to the bag.

Declaration
public (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
public (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
public (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
public (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
public (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.

Implements

IBag<T>
IDataStructure<T>
ISteppable<T>
System.Collections.Generic.IEnumerable<>
DataStructure.ICountable
DataStructure.IClearable
DataStructure.IAuditable<T>
DataStructure.IRemovable<T>
DataStructure.IAddable<T>
ICloneable<T>
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX