You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,10 @@ All notable changes to Celerity are documented here. This project follows [Keep
4
4
5
5
## [Unreleased]
6
6
7
+
### Added
8
+
9
+
-`README.md` — new "Quick start" section with concrete, runnable usage examples for `IntDictionary`, `CelerityDictionary` (with `GuidHasher`, `StringFnV1AHasher`, `DefaultHasher<T>`), the sets (`IntSet`, `CeleritySet`), and the `IEnumerable<KeyValuePair<,>>` constructor. Covers indexer get/set, `TryAdd` / `Add` semantics, `TryGetValue`, removal, and bulk-load from a BCL `Dictionary<,>`. Closes the "Add usage examples to README" item from issue #15.
10
+
7
11
## [1.1.2] - 2026-05-01
8
12
9
13
First successful 1.1.x publish. Tags `v1.1.0` and `v1.1.1` exist on the repository but never published to nuget.org: `v1.1.0` failed at deploy with HTTP 403 (NuGet API key had expired), and the follow-up `v1.1.1` failed with HTTP 401 because the trusted-publishing migration used the wrong NuGet account name (`marius-bughiu` instead of `marius.bughiu`). 1.1.2 is the same library code as the 1.1.0 tag plus the trusted-publishing migration with the correct user, shipped under a fresh version because the failed tags couldn't be cleanly recycled.
Copy file name to clipboardExpand all lines: README.md
+95Lines changed: 95 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,101 @@ Celerity is a .NET library that provides specialized high-performance collection
13
13
14
14
All dictionaries implement `IReadOnlyDictionary<TKey, TValue?>` and ship allocation-free struct enumerators, `Keys` / `Values` views, and an `IEnumerable<KeyValuePair<TKey, TValue>>` constructor. All collections handle `default(TKey)` (or zero for `int` / `long` keys, `null` for reference-type keys) out-of-band so it never collides with the empty-slot sentinel.
15
15
16
+
## Quick start
17
+
18
+
Install from NuGet:
19
+
20
+
```bash
21
+
dotnet add package Celerity.Collections
22
+
```
23
+
24
+
### `IntDictionary` — the int-keyed fast path
25
+
26
+
`IntDictionary<TValue>` defaults to `Int32WangNaiveHasher`, so most callers don't need to pick a hasher.
27
+
28
+
```csharp
29
+
usingCelerity.Collections;
30
+
31
+
varcounts=newIntDictionary<int>();
32
+
counts[42] =1;
33
+
counts[42]++; // indexer get/set
34
+
counts.TryAdd(7, 100); // returns false if key already present, no overwrite
35
+
counts.Add(8, 200); // throws ArgumentException if key already present
36
+
37
+
if (counts.TryGetValue(42, outvarhits))
38
+
Console.WriteLine(hits); // 2
39
+
40
+
counts.Remove(7);
41
+
Console.WriteLine(counts.Count); // 2
42
+
43
+
// foreach is allocation-free — Enumerator is a struct.
44
+
foreach (varkvpincounts)
45
+
Console.WriteLine($"{kvp.Key} -> {kvp.Value}");
46
+
```
47
+
48
+
The zero key is a legitimate value, not the empty-slot sentinel — `counts[0] = 99` round-trips correctly. `LongDictionary<TValue>` follows the exact same surface for `long` keys (defaulting to `Int64WangHasher`).
49
+
50
+
### `CelerityDictionary` — generic keys with a struct hasher
51
+
52
+
For non-`int`/`long` keys, pick a hasher from `Celerity.Hashing` (or supply your own). `DefaultHasher<T>` falls back to `EqualityComparer<T>.Default.GetHashCode()` for arbitrary types.
The hasher is a `struct` and is supplied as a generic constraint, so the JIT devirtualizes and inlines the `Hash()` call on the probe path.
70
+
71
+
### Sets
72
+
73
+
`IntSet` and `CeleritySet<T, THasher>` mirror the dictionary types for membership-only workloads.
74
+
75
+
```csharp
76
+
usingCelerity.Collections;
77
+
usingCelerity.Hashing;
78
+
79
+
varseen=newIntSet();
80
+
seen.Add(1);
81
+
seen.Add(2);
82
+
Console.WriteLine(seen.Contains(1)); // true
83
+
seen.Remove(2);
84
+
85
+
varvisitedIds=newCeleritySet<Guid, GuidHasher>();
86
+
visitedIds.TryAdd(Guid.NewGuid()); // returns true on first add, false on duplicate
87
+
```
88
+
89
+
### Construct from an existing collection
90
+
91
+
The dictionaries accept any `IEnumerable<KeyValuePair<TKey, TValue>>`. When the source implements `ICollection<T>`, its `Count` is used to pre-size the backing storage so the bulk fill avoids resize work.
Implement `IHashProvider<T>` as a `struct` to plug in your own hash function. See [Custom hashing](#custom-hashing) below for the contract and a worked example.
0 commit comments