RockHouse.Collections
0.9.0
.NET 5.0
This package targets .NET 5.0. The package is compatible with this framework or higher.
.NET Core 2.1
This package targets .NET Core 2.1. The package is compatible with this framework or higher.
.NET Framework 4.8
This package targets .NET Framework 4.8. The package is compatible with this framework or higher.
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 | Versions 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.
-
.NETCoreApp 2.1
- Microsoft.Bcl.HashCode (>= 1.1.1)
- System.Text.Json (>= 4.6.0)
-
.NETCoreApp 3.1
- No dependencies.
-
.NETFramework 4.8
- Microsoft.Bcl.HashCode (>= 1.1.1)
- System.Text.Json (>= 4.6.0)
-
net5.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.