MyStructures 0.0.1

dotnet add package MyStructures --version 0.0.1
                    
NuGet\Install-Package MyStructures -Version 0.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MyStructures" Version="0.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MyStructures" Version="0.0.1" />
                    
Directory.Packages.props
<PackageReference Include="MyStructures" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MyStructures --version 0.0.1
                    
#r "nuget: MyStructures, 0.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MyStructures@0.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MyStructures&version=0.0.1
                    
Install as a Cake Addin
#tool nuget:?package=MyStructures&version=0.0.1
                    
Install as a Cake Tool

MyStructures

A small collection of reusable C# data structures and algorithms: a stopwatch-style timer keyed by an enum, a two-level dictionary with default values, distinct-color generation, and a fast Levenshtein distance.


MyStructures.Timing.TimingObject<T> (where T : Enum)

A multi-operation stopwatch. Each enum value names an operation you can start, stop, and toggle independently; the object accumulates the elapsed time across all the intervals for that operation. Thread-safe.

Member Description
Start(T operation) Begins a new timing interval for the operation. Throws if it is already running.
Stop(T operation) Ends the current interval. Throws if it was not started/running.
Toggle(T operation) Starts the operation if stopped, stops it if running.
GetTotalElapsed(T operation) Total elapsed time across all intervals (including the live interval if still running).
GetIntervals(T operation) Read-only list of all recorded TimeIntervals for the operation.
Reset(T operation) Clears the intervals for one operation (throws if it is running).
ResetAll() Clears all operations (throws if any is running).
JsonProperties A Dictionary<T, JsonInfo> (start / stop / elapsed) convenient for serialization.
ToString() A formatted report of every operation, its intervals, and totals.

Nested types: TimeInterval (a single start/stop span with Elapsed) and the JsonInfo struct.

enum Phase { Load, Process, Save }

var timer = new TimingObject<Phase>();
timer.Start(Phase.Load);
// ... work ...
timer.Stop(Phase.Load);
Console.WriteLine(timer.GetTotalElapsed(Phase.Load));

MyStructures.DictionaryManager

DictionaryManager<TValue>

A string-keyed dictionary that internally buckets entries by their first character, which keeps each underlying dictionary smaller when working with very large key sets. It implements IEnumerable<KeyValuePair<string, TValue>> so it can be iterated with foreach.

  • Optionally constructed with a default value; otherwise missing keys are auto-created via Activator.CreateInstance<TValue>().
  • Indexer get/set transparently routes to the correct first-character bucket.

DefaultDict<TKey, TValue>

A Dictionary<TKey, TValue> whose indexer auto-creates a missing key on access — either using a supplied default value or a new TValue instance — mirroring Python's collections.defaultdict.

var counts = new DefaultDict<string, int>();
counts["a"]++;   // key "a" is created automatically

MyStructures.Distances.LevenshteinDistance

Method Description
FastDistance(value1, value2, insertionCost, deletionCost, replacementCost) Computes the Levenshtein (edit) distance between two strings using a single-row, O(n) memory dynamic-programming approach. Insertion, deletion, and replacement costs are all configurable (default 1 each).
int d = LevenshteinDistance.FastDistance("kitten", "sitting"); // 3

MyStructures.ColorGenerator.ColorGenerator

Generates a sequence of visually distinct RGB hex colors (without the leading #). It cycles through seven channel patterns and walks intensity values down a binary tree so that successive colors stay far apart in color space — handy for assigning colors to categories, chart series, highlight groups, etc.

Member Description
ColorGenerator.NextColour() Returns the next distinct color as a 6-character hex string (e.g. "FF0000").

Supporting types — PatternGenerator, IntensityGenerator, IntensityValue, and IntensityValueWalker — implement the pattern selection and the intensity tree-walk behind NextColour().

var gen = new ColorGenerator();
for (int i = 0; i < 10; i++)
    Console.WriteLine("#" + gen.NextColour());
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.1 118 6/18/2026
0.0.0 144 2/5/2026