From 1c651d6c82f1a5f4d6784f9af1b6e9128a3d91cf Mon Sep 17 00:00:00 2001 From: dadhi Date: Mon, 25 Jul 2022 21:08:37 +0200 Subject: [PATCH] releasing v4.0.0 --- BuildScripts/NuGetPublish.bat | 4 ++-- README.md | 2 +- nuspecs/ImTools.nuspec | 35 ++++++++++++++++++---------- src/ImTools/ImTools.cs | 17 ++------------ src/ImTools/ImTools.csproj | 33 +++++++++++++++++--------- test/ImTools.UnitTests/ImTools.V2.cs | 2 +- 6 files changed, 51 insertions(+), 42 deletions(-) diff --git a/BuildScripts/NuGetPublish.bat b/BuildScripts/NuGetPublish.bat index 2e954b6a..07564f2d 100644 --- a/BuildScripts/NuGetPublish.bat +++ b/BuildScripts/NuGetPublish.bat @@ -4,8 +4,8 @@ set PACKAGES=.dist\packages set SOURCE=https://api.nuget.org/v3/index.json set /p APIKEY=<"..\ApiKey.txt" -dotnet nuget push "%PACKAGES%\ImTools.dll.3.1.0.nupkg" -k %APIKEY% -s %SOURCE% -dotnet nuget push "%PACKAGES%\ImTools.3.1.0.nupkg" -k %APIKEY% -s %SOURCE% +dotnet nuget push "%PACKAGES%\ImTools.dll.4.0.0.nupkg" -k %APIKEY% -s %SOURCE% +dotnet nuget push "%PACKAGES%\ImTools.4.0.0.nupkg" -k %APIKEY% -s %SOURCE% echo: echo:Publishing completed. diff --git a/README.md b/README.md index 2e30272a..e9478a4f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ - Windows, Linux, MacOS [![CI build](https://ci.appveyor.com/api/projects/status/el9echuqfnl86u53?svg=true)](https://ci.appveyor.com/project/MaksimVolkau/imtools/branch/master) - Lib package [![NuGet Badge](https://buildstats.info/nuget/ImTools.dll)](https://www.nuget.org/packages/ImTools.dll) - Code package [![NuGet Badge](https://buildstats.info/nuget/ImTools)](https://www.nuget.org/packages/ImTools) -- Latest release [![latest release](https://img.shields.io/badge/latest%20release-v3.1.0-green)](https://github.com/dadhi/ImTools/releases/tag/v3.1.0) +- Latest release [![latest release](https://img.shields.io/badge/latest%20release-v4.0.0-green)](https://github.com/dadhi/ImTools/releases/tag/v4.0.0) Fast and memory-efficient immutable collections and helper data structures. diff --git a/nuspecs/ImTools.nuspec b/nuspecs/ImTools.nuspec index 9d8b04f3..b6a416db 100644 --- a/nuspecs/ImTools.nuspec +++ b/nuspecs/ImTools.nuspec @@ -2,9 +2,9 @@ ImTools - 3.1.0 + 4.0.0 Maksim Volkau - Copyright © 2016-2021 Maksim Volkau + Copyright © 2016-2022 Maksim Volkau https://github.com/dadhi/ImTools MIT false @@ -17,19 +17,30 @@ FP Performance Simple Functional Immutable Persistent Map Avl 2-3Tree Self Balanced Tree Dictionary Thread-safe Functional Atomic Ref Algebraic Discriminated Union SumType ` type is replaced by ImHashMap`. +The implementations of ImMap and ImHashMap are combined into one, reducing the code size, and using all performance optimizations from the both. +This change will simplify further performance improvements, testing and bug-fixes. -- Minimizing the target frameworks to the net45 and netstandard2.0 -- Added fast and more memory efficient ImMap and ImHashMap based on 2-3 tree (#32, #35) -- Extended the map API with AddOrGetEntry, Count, ToArray, and ToDictionary methods, and more +I have tried to keep the API as similar as possible, +but you may expect that some types and methods were renamed, or new overloads were added. + +### Performance and memory improvements + +- Fewer allocations (~10%), see the benchmarks in project readme +- Keeping the performance almost the same + +### Closed issues + +- #41 Add a builder-like capability to the ImHashMap via BuildFromDifferent methods +- #47 Add output of the ImHashMap as mermaid diagram, e.g. `ToMermaidString` method +- #48 Merge the ImMap and ImHashMap implementations +- #50 Optimize Enumerable for the PartitionedHashMap +- #51 Reduce ImHashMap memory allocations, keeping the speed +- #52 Add AddSureNotPresent methods to compensate for GetSurePresent methods ]]> diff --git a/src/ImTools/ImTools.cs b/src/ImTools/ImTools.cs index 0586c88c..572c5d96 100644 --- a/src/ImTools/ImTools.cs +++ b/src/ImTools/ImTools.cs @@ -246,7 +246,7 @@ public static T[] CopyNonEmpty(this T[] source) return copy; } - /// Returns the new array consisting from all items from source array then the all items from added array. + /// Returns the new array consisting of all items from source array then the all items from added array. /// If source is null or empty then the added array will be returned. If added is null or empty then the source will be returned. public static T[] Append(this T[] source, params T[] added) { @@ -402,7 +402,6 @@ public static int IndexOf(this T[] source, T value) if (Equals(item, value)) return i; } - return -1; } @@ -446,7 +445,6 @@ public static T FindFirst(this T[] source, Func predicate) if (predicate(item)) return item; } - return default(T); } @@ -460,7 +458,6 @@ public static T FindFirst(this T[] source, S state, Func predi if (predicate(state, item)) return item; } - return default(T); } @@ -547,10 +544,8 @@ private static R[] AppendTo(T[] source, int sourcePos, int count, Func(T[] source, S state, int sourcePos, int cou if (count == 1) appendedResults[oldResultsCount] = map(state, source[sourcePos]); else - { for (int i = oldResultsCount, j = sourcePos; i < appendedResults.Length; ++i, ++j) appendedResults[i] = map(state, source[j]); - } return appendedResults; } @@ -609,10 +602,8 @@ private static R[] AppendTo(T[] source, A a, B b, int sourcePos, int if (count == 1) appendedResults[oldResultsCount] = map(a, b, source[sourcePos]); else - { for (int i = oldResultsCount, j = sourcePos; i < appendedResults.Length; ++i, ++j) appendedResults[i] = map(a, b, source[j]); - } return appendedResults; } @@ -1256,9 +1247,7 @@ public static int Combine(T1 a, T2 b) if (ReferenceEquals(a, null)) return bh; var ah = a.GetHashCode(); - if (ah == 0) - return bh; - return Combine(ah, bh); + return ah == 0 ? bh : Combine(ah, bh); } /// Inspired by System.Tuple.CombineHashCodes @@ -1513,7 +1502,6 @@ public T[] ResizeToArray() return items; } - // todo: @naming think of the better name /// Pops the item - just moving the counter back public T PopItem() => Items[--Count]; @@ -1991,7 +1979,6 @@ internal override Entry AddOrUpdateWithTheSameHashByReferenceEquals(ImHashMapEnt return ReferenceEquals(key, e._key) ? ImHashMap.Entry(Hash, key, update(key, Value, e.Value)) : new HashConflictingEntry(Hash, this, e); } - // todo: @wip better method names aligned with the calling side internal override ImHashMap GetMapOrReplaceWithEntry(ImHashMap oldMap, ImHashMapEntry newEntry) { var e = (KVEntry)newEntry; diff --git a/src/ImTools/ImTools.csproj b/src/ImTools/ImTools.csproj index 2adee945..52b88ae1 100644 --- a/src/ImTools/ImTools.csproj +++ b/src/ImTools/ImTools.csproj @@ -3,7 +3,7 @@ net45;netstandard2.0 ImTools - 3.1.0 + 4.0.0 $(Product) @@ -20,20 +20,31 @@ FP Performance Simple Functional Immutable Persistent Map Avl 2-3Tree Self Balanced Tree Dictionary Thread-safe Functional Atomic Ref Algebraic Discriminated Union SumType ` type is replaced by ImHashMap`. +The implementations of ImMap and ImHashMap are combined into one, reducing the code size, and using all performance optimizations from the both. +This change will simplify further performance improvements, testing and bug-fixes. -- Minimizing the target frameworks to the net45 and netstandard2.0 -- Added fast and more memory efficient ImMap and ImHashMap based on 2-3 tree (#32, #35) -- Extended the map API with AddOrGetEntry, Count, ToArray, and ToDictionary methods, and more +I have tried to keep the API as similar as possible, +but you may expect that some types and methods were renamed, or new overloads were added. + +### Performance and memory improvements + +- Fewer allocations (~10%), see the benchmarks in project readme +- Keeping the performance almost the same + +### Closed issues + +- #41 Add a builder-like capability to the ImHashMap via BuildFromDifferent methods +- #47 Add output of the ImHashMap as mermaid diagram, e.g. `ToMermaidString` method +- #48 Merge the ImMap and ImHashMap implementations +- #50 Optimize Enumerable for the PartitionedHashMap +- #51 Reduce ImHashMap memory allocations, keeping the speed +- #52 Add AddSureNotPresent methods to compensate for GetSurePresent methods ]]> diff --git a/test/ImTools.UnitTests/ImTools.V2.cs b/test/ImTools.UnitTests/ImTools.V2.cs index 2bc4e131..7e8d9034 100644 --- a/test/ImTools.UnitTests/ImTools.V2.cs +++ b/test/ImTools.UnitTests/ImTools.V2.cs @@ -2,7 +2,7 @@ /* The MIT License (MIT) -Copyright (c) 2016-2021 Maksim Volkau +Copyright (c) 2016-2022 Maksim Volkau Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal