C5 3.0.0

C5 Generic Collection Library for C# and CLI

NuGet version (C5) .github/workflows/main.yml

The C5 library is a set of generic collection classes (or container classes) for the C# programming language and other generics-enabled languages on later versions of the .NET runtime (Common Language Runtime).

The C5 library provides a wide range of classic data structures, rich functionality, the best possible asymptotic time complexity, documented performance, and a thoroughly tested implementation.

Goals of the C5 library

The overall goal is for C5 to be a generic collection library for the C# programming language and the Common Language Infrastructure (CLI) whose functionality, efficiency and quality meets or exceeds what is available for similar contemporary programming platforms.

The design has been influenced by the collection libraries for Java and SmallTalk and the published critique of these.

However, it contains functionality and a regularity of design that considerably exceeds that of the standard libraries for those languages.

Documentation

Research notes are available here: https://www.itu.dk/research/c5/.

Why yet another generic collection library

There are already other generic collection libraries for C#/CLI, including the System.Collections.Generic namespace introduced with .NET 2.0 and Wintellect's Power Collections for .NET by Peter Golde (http://powercollections.codeplex.com/).

The CLI generic collection library as implemented by in Microsoft .NET Framework 2.0 provides a limited choice of data structures.

In general, the CLI Framework library has a proliferation of methods variants and rather poor orthogonality.

Collection implementations such as array lists and linked lists have much the same functionality but do not implement a common interface. This impairs the learnability of the library in contexts where nano-second efficiency is more important that rich functionality, and the need to support also rather resource-constrained run-time systems.

The Power Collections library by Peter Golde augments the CLI version 2.0 collection library with various data structures and algorithms.

However, it accepts the basic design of the CLI collection classes and therefore suffers from some of the same shortcommings, and also does not provide most of the advanced functionality (updatable views, snapshots, directed enumeration, priority queue handles, ...) of C5.

Thus, in our opinion, C5 provides the most powerful, well-structured and scalable generic collections library available for C#/CLI.

What does the name C5 stand for?

This is not entirely clear, but it may stand for Copenhagen Comprehensive Collection Classes for C#, although the library may be used from VB.NET, F# and other CLI languages, not just C#. It has nothing to do with a Microsoft Dynamics product that used to be called Concorde C5/Damgaard C5/Navision C5, nor a real-time operation system called C5 (or Chorus), nor the C5 Corporation (system visualization), nor an Eclipse plug-in called C5, nor with cars such as the Citroën C5 or Corvette C5 or Clive Sinclair's ill-fated C5 concept vehicle.

The name may be inspired by the versatile C4 plastic explosive known from e.g. James Bond movies.

All trademarks belong to their owners.

State of completion

At the time of writing, library design and implementation are complete, and extensive unit tests have been written and applied systematically.

Most of the library API documentation is in place but requires proof-reading.

The C5 implementation was originally built on .NET 2.0 and has only recently been upgraded to .NET 4.0. It does not (yet) use a great number of the new features introduced with C# 3 and 4, notably LINQ and covariant and contravariant type parameters.

C5 targets .NET Standard 2.0, NET 6.0, and .NET 8.0.

Getting Started

  1. Get C5 from NuGet:

    dotnet add package C5
    
  2. Building the unit test project requires NUnit. If you have NuGet installed it should automatically add the reference.

    There are more than 1400 NUnit test cases which should execute in less than 5 seconds. All should pass.

No packages depend on C5.

Release 3.0.0 of 2024-06-05 - C5 now targets .NET Standard 2.0, .NET 6.0 and .NET 8.0. - Breaking change: Rec<T1, T2, ...> type removed. - Breaking change: All public readonly fields are now properties. - Breaking change: EventTypeEnum is now EventType. - Breaking change: custom KeyValuePair<K, V> has been replaced by the standard System.Collections.Generic.KeyValue<TKey, TValue> for better compatibility. - Breaking change: EnumerationDirection is now Direction. - Breaking change: Serializable attribute removed.

.NET 6.0

  • No dependencies.

.NET 8.0

  • No dependencies.

.NET Standard 2.0

  • No dependencies.

Version Downloads Last updated
3.0.0 4 11/24/2024
3.0.0-rc 5 11/21/2024
3.0.0-beta 2 12/06/2024
2.5.3 10 11/09/2023
2.5.0 3 11/24/2024
2.4.5947.17249 4 12/02/2024
2.4.5828.26833 3 12/10/2024
2.4.5827.29151 8 11/09/2024
2.3.0.1 5 11/21/2024
2.3.0 5 11/12/2024
2.2.5073.27396 3 12/03/2024
2.2.4881.16939 3 11/24/2024
2.2.4822.42600 6 11/09/2024
2.1.4492.18142 0 04/19/2012
2.0.4398.25000 5 11/25/2024
2.0.4398.23817 0 01/16/2012
2.0.4398.21073 0 01/16/2012
2.0.1 3 12/02/2024
2.0.0 8 11/09/2023
1.0.2 3 12/02/2024