RockHouse.Collections 0.9.0

dotnet add package RockHouse.Collections --version 0.9.0                
NuGet\Install-Package RockHouse.Collections -Version 0.9.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="RockHouse.Collections" Version="0.9.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RockHouse.Collections --version 0.9.0                
#r "nuget: RockHouse.Collections, 0.9.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 RockHouse.Collections as a Cake Addin
#addin nuget:?package=RockHouse.Collections&version=0.9.0

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

RockHouse.Collections

RockHouse.Collections is a Collection class package that mimics the Java language API and the Apache.Commons.CollectionsAPI. It also adds several proprietary APIs.

The following is an example of a class.

  • CollectionUtils
  • DictionaryUtils
  • EnumerableUtils
  • ListUtils
  • SetUtils
  • Dictionaries.HashMap
  • Dictionaries.LinkedHashMap
  • Dictionaries.LinkedOrderedDictionary
  • Dictionaries.ListOrderedDictionary
  • Dictionaries.LruMap/Dictionary
  • Dictionaries.ReferenceDictionary
  • Dictionaries.WeakHashMap
  • Dictionaries.Multi.HashSetValuedDictionary
  • Dictionaries.Multi.ListValuedMap/Dictionary
  • Sets.LinkedHashSet
  • Sets.LinkedOrderedSet
  • Sets.ListOrderedSet

etc

Java language-like

var map = new HashMap<string, string>();

if (map.IsEmpty)
{
    Console.WriteLine("empty");
}

var get1 = map.Get("a"); // get1 is null

var put1 = map.Put("a", "1"); // put1 is null
var get2 = map.Get("a"); // get2 is 1

var put2 = map.Put("a", "2"); // put2 is 1
var get3 = map.Get("a"); // get3 is 2

Note: There are some incompatibilities with Java. Since null is not allowed in primitive types, the API that returns null substitutes default(V). For example, default(int) is 0.

Utilities similar to functions in common scripting languages such as Perl, Ruby, Python, etc.

var list = new List<int>();
ListUtils.Push(list, 1, 2);
var tail = ListUtils.Pop(list); // tail is 2
ListUtils.Unshift(list, 0);
var head = ListUtils.Shift(list); // head is 0

Compatibility with .NET API

Collection initializer

var map = new HashMap<string, int>()
{
    { "a", 1 },
    { "b", 2 },
    { "c", 3 },
};

Indexer

map["key"] = 10;
var value = map["key"]; // value is 10
var abort = map["not found"]; // KeyNotFoundException

Enumerable

foreach (var entry in map)
{
    Console.WriteLine($"key={entry.Key}, value={entry.Value}");
}

LINQ

var filteredList = map.Where(e => e.Value > 1)
                        .Select(e => e.Key)
                        .ToList();

Json

With System.Text.Json

var json = JsonSerializer.Serialize(map);
var restore = JsonSerializer.Deserialize<HashMap<string, int>>(json);

License

This code is under the Apache License, Version 2.0.

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.1 is compatible.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.9.0 122 2/24/2024
0.8.0 181 6/29/2023
0.7.0 146 6/26/2023
0.6.0 150 6/12/2023
0.5.0 153 6/2/2023
0.4.0 144 5/31/2023
0.3.0 143 5/25/2023
0.2.0 144 5/23/2023
0.1.0 138 5/22/2023