MG.Collections 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package MG.Collections --version 1.0.0                
NuGet\Install-Package MG.Collections -Version 1.0.0                
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="MG.Collections" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MG.Collections --version 1.0.0                
#r "nuget: MG.Collections, 1.0.0"                
#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.
// Install MG.Collections as a Cake Addin
#addin nuget:?package=MG.Collections&version=1.0.0

// Install MG.Collections as a Cake Tool
#tool nuget:?package=MG.Collections&version=1.0.0                

Expanded Specialized Collections

GitHub Project Site

WPF library - MG.Collections.Wpf

Helper libraries that provide some collection classes that I use in my projects. Some examples include:

UniqueList<T>

  • Same as System.Collections.Generic.List<T> but ensures that each element is unique according to a custom IEqualityComparer<T> or the default.

// input is: "test test Test"
using MG.Collections;
using System;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var col = new UniqueList<string>(args);

            Console.WriteLine(col.Count); // outputs '1'
            Console.WriteLine(col[0]);    // outputs 'test'.
        }
    }
}

ManagedKeySortedList<TKey, TValue>

  • Similar to System.Collections.Generic.SortedList<TKey, TValue>. The difference is that the 'key' is retrieved from an incoming object using a specified Func<TValue, TKey> function defined in the constructor. Elements can be added then, and the 'key' will be retrieved automatically from it.

  • The other difference is that the default enumerator for this collection uses the simple List enumerator instead of a Dictionary one.

// input is: 1 2 87 2 "what up"
using MG.Collections;
using System;
using System.Collections;
using System.Collections.Generic;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var sortedList = new ManagedKeySortedList<int, StringInt>(x => x.IntValue);

            Array.ForEach((a) => {
                sortedList.Add(a);
            });

            Console.WriteLine(sortedList.Count); // outputs '4'
        }
    }

    struct StringInt
    {
        public int IntValue;
        public string StrValue;

        public static implicit operator StringInt(string parsingStr)
        {
            int intVal = -1;
            if (int.TryParse(parsingStr, out int tryInt))
            {
                intVal = tryInt;
            }

            return new StringInt
            {
                IntValue = intVal,
                StrValue = parsingStr
            };
        }
    }
}

ReadOnlyList<T> & ReadOnlySet<T>

  • A List and a Set readonly wrapper (similiar to System.Collections.ObjectModel.ReadOnlyCollection<T>) exposing only the 'readonly' methods of the corresponding collection types.

    • *NOTE* - In .NET5 projects, ReadOnlySet<T> implements System.Collections.Generic.IReadOnlySet<T>. All other target frameworks, it implements a custom MG.Collections.IReadOnly<T>.
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETFramework 4.6.2

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.
  • net5.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on MG.Collections:

Package Downloads
MG.Collections.Wpf

A library consisting of list, collection, and set classes that can be used with WPF applications.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.0 409 11/9/2022
1.1.0 623 5/1/2022
1.0.3 684 2/3/2022
1.0.2 474 10/8/2021
1.0.1 318 9/17/2021
1.0.0 407 8/31/2021

Initial Release