{"id":23164756,"url":"https://github.com/stillpoint-software/hyperbee.collections","last_synced_at":"2025-12-12T01:45:14.943Z","repository":{"id":232841577,"uuid":"785270585","full_name":"Stillpoint-Software/hyperbee.collections","owner":"Stillpoint-Software","description":"Additional collections types such as ConcurrentSet, OrderDictionary and LinkedDictionaries","archived":false,"fork":false,"pushed_at":"2024-12-17T17:18:50.000Z","size":660,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-17T18:19:04.589Z","etag":null,"topics":["collections","csharp","deque","dictionaries","dotnet","trie"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Stillpoint-Software.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-11T14:47:37.000Z","updated_at":"2024-12-17T17:18:47.000Z","dependencies_parsed_at":"2024-04-11T19:40:51.875Z","dependency_job_id":"5f151eeb-7aac-4621-9c21-4ca03433a40d","html_url":"https://github.com/Stillpoint-Software/hyperbee.collections","commit_stats":null,"previous_names":["stillpoint-software/hyperbee.collections"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stillpoint-Software%2Fhyperbee.collections","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stillpoint-Software%2Fhyperbee.collections/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stillpoint-Software%2Fhyperbee.collections/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stillpoint-Software%2Fhyperbee.collections/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Stillpoint-Software","download_url":"https://codeload.github.com/Stillpoint-Software/hyperbee.collections/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230202349,"owners_count":18189437,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collections","csharp","deque","dictionaries","dotnet","trie"],"created_at":"2024-12-18T01:12:47.420Z","updated_at":"2025-12-12T01:45:14.938Z","avatar_url":"https://github.com/Stillpoint-Software.png","language":"C#","readme":"﻿# Hyperbee.Collection\n\nAdditional collections types and extensions.\n\n## Reference Documentation\n\n### AhoCorasickTrie\n\nThe `AhoCorasickTrie` class is an implementation of the Aho-Corasick algorithm for pattern matching in text.\n\n#### Properties\n- **IgnoreCase**: Determines if the trie ignores case during matching.\n\n#### Methods\n- `void Add(string match)`: Adds a search phrase to the trie.\n- `IEnumerable\u003cFindResult\u003cTTag\u003e\u003e Find(string text)`: Finds all matches for the given text.\n\n#### Example\n```csharp\nvar trie = new AhoCorasickTrie\u003cstring\u003e();\ntrie.Add(\"apple\", \"fruit\");\ntrie.Add(\"app\", \"prefix\");\nvar results = trie.Find(\"apple pie\");\nforeach (var result in results)\n{\n    Console.WriteLine($\"Match: {result.Tag}, Index: {result.Index}\");\n}\n```\n\n\n### ConcurrentSet\n\nThe `ConcurrentSet\u003cT\u003e` provides a thread-safe set implementation.\n\n#### Properties\n- **Count**: The number of items in the set.\n- **IsEmpty**: Indicates whether the set is empty.\n\n#### Methods\n- `bool TryAdd(T item)`: Attempts to add an item.\n- `bool TryRemove(T item)`: Attempts to remove an item.\n- `void Clear()`: Removes all items from the set.\n- `bool Contains(T item)`: Checks if the set contains an item.\n\n#### Example\n```csharp\nvar set = new ConcurrentSet\u003cint\u003e();\nset.TryAdd(1);\nConsole.WriteLine(set.Contains(1)); // True\nset.TryRemove(1);\n```\n\n\n### Deque\n\nA double-ended queue supporting efficient operations at both ends.\n\n#### Properties\n- **Count**: The number of items in the deque.\n- **IsEmpty**: Indicates whether the deque is empty.\n\n#### Methods\n- `void AddFirst(T item)`: Adds an item to the front.\n- `void AddLast(T item)`: Adds an item to the end.\n- `T RemoveFirst()`: Removes and returns the front item.\n- `T RemoveLast()`: Removes and returns the last item.\n- `void Insert(int index, T item)`: Inserts an item at a specific index.\n- `void RemoveAt(int index)`: Removes an item at a specific index.\n- `T this[int index]`: Gets or sets the item at the specified index.\n\n#### Example\n```csharp\nvar deque = new Deque\u003cint\u003e();\ndeque.AddFirst(1);\ndeque.AddLast(2);\n\nConsole.WriteLine(deque.RemoveFirst()); // 1\n```\n\n### DisjointSet\n\nThe `DisjointSet` class provides an implementation of the union-find algorithm, which is used to efficiently manage and query disjoint sets.\n\n#### Properties\n- **Count**: The number of disjoint sets.\n- **Size**: The size of the underlying data structure.\n\n#### Methods\n- `void Clear()`: Clears the set.\n- `bool TryAdd(T item)`: Creates a new set containing the specified item.\n- `bool TryAdd(IEnumerable\u003cT\u003e items)`: Creates a new set containing the specified items.\n- `T Find(T item)`: Finds the representative of the set containing the specified item.\n- `void Union(T item1, T item2)`: Merges the sets containing the two specified items.\n- `bool AreConnected(T item1, T item2)`: Checks if two items belong to the same set.\n\n#### Example\n```csharp\nvar set = new DisjointSet\u003cint\u003e();\n\n// Add elements to the set\nset.TryAdd(1);\nset.TryAdd(2);\nset.TryAdd(3);\n\n// Union two elements\nset.Union(1, 2);\n\n// Find the representative of a group\nConsole.WriteLine(set.Find(1)); // Outputs: 1\nConsole.WriteLine(set.Find(2)); // Outputs: 1 (same group as 1)\n\n// Check if two elements are in the same group\nConsole.WriteLine(AreConnected(1, 2)); // Outputs: False\n```\n\n### DynamicDictionary\n\nA dynamic dictionary that allows adding and retrieving dynamic properties.\n\n#### Properties\n- **Source**: The underlying dictionary.\n\n#### Methods\n- `dynamic this[string name]`: Gets or sets a value dynamically.\n- `bool TryGetMember(GetMemberBinder binder, out object result)`: Dynamically retrieves a member value.\n- `bool TrySetMember(SetMemberBinder binder, object value)`: Dynamically sets a member value.\n\n#### Example\n```csharp\ndynamic dict = new DynamicDictionary();\ndict.Name = \"Hyperbee\";\nConsole.WriteLine(dict.Name); // Hyperbee\n```\n\n\n### LinkedDictionary\n\nA stack of dictionaries with layered key-value lookup that supports pushing and popping scopes.\n\n#### Properties\n- **Name**: The name of the current dictionary layer.\n- **Comparer**: The equality comparer used for keys.\n\n#### Methods\n- `void Push(IEnumerable\u003cKeyValuePair\u003cTKey, TValue\u003e\u003e collection)`: Pushes a new dictionary layer.\n- `void Push(string name, IEnumerable\u003cKeyValuePair\u003cTKey, TValue\u003e\u003e collection)`: Pushes a named dictionary layer.\n- `LinkedDictionaryNode\u003cTKey, TValue\u003e Pop()`: Pops the top dictionary layer.\n- `bool TryGetValue(TKey key, out TValue value)`: Attempts to get a value by key.\n- `TValue this[TKey key, KeyValueOptions options]`: Layered key-value assignment.\n\n#### Example\n```csharp\nvar linked = new LinkedDictionary\u003cstring, string\u003e();\n\n// push an initial set of keys\nlinked.Push( new Dictionary\u003cstring, string\u003e\n{\n    [\"first\"] = \"default_first\",\n    [\"last\"] = \"default_last\",\n    [\"suffix\"] = \"\",\n} );\n\nlinked.Push( new Dictionary\u003cstring, string\u003e\n{\n    [\"first\"] = \"Tim\",            // new scope masks original values\n    [\"last\"] = \"Jones\",           // new scope masks original values\n    [\"address\"] = \"123 Main St.\"  // New key\n} );\n```\n\n\n### OrderedSet\n\nA set that maintains the order of insertion.\n\n#### Properties\n- **Comparer**: The equality comparer used for items.\n- **Count**: The number of items in the set.\n\n#### Methods\n- `bool TryGetValue(T key, out T item)`: Gets a value if it exists.\n- `void Add(T item)`: Adds an item to the set.\n- `bool Remove(T item)`: Removes an item from the set.\n- `bool Contains(T item)`: Checks if the set contains an item.\n- `T this[T key]`: Accesses the set by key.\n\n#### Example\n```csharp\nvar orderedSet = new OrderedSet\u003cint\u003e { 1, 2, 3 };\nConsole.WriteLine(orderedSet[1]); // 1\n```\n\n\n### PooledArray\n\nA high-performance array pool for reusable arrays.\n\n### Important\nThe `PooledArray` class uses `ArrayPool` internally and must be disposed to avoid memory leaks. Always wrap instances in a `using` block or explicitly call `Dispose()`.\n\n#### Properties\n- **Count**: The number of items in the array.\n- `T this[int index]`: Gets or sets the item at the specified index.\n\n#### Methods\n- `void Add(T item)`: Adds an item to the array.\n- `void Resize(int newSize)`: Resizes the array.\n- `void Remove(int index)`: Removes an item at the specified index.\n- `void Insert(int index, T item)`: Inserts an item at a specified index.\n- `void CopyTo(T[] destination, int sourceIndex, int destinationIndex, int count)`: Copies items to another array.\n\n#### Example\n```csharp\nusing (var pooledArray = new PooledArray\u003cint\u003e(10))\n{\n    pooledArray.Add(42);\n    Console.WriteLine(pooledArray[0]); // 42\n}\n```\n\n\n### PooledStack\n\nA stack implementation built on `PooledArray`.\n\n### Important\nThe `PooledStack` class uses `ArrayPool` internally and must be disposed to avoid memory leaks. Always wrap instances in a `using` block or explicitly call `Dispose()`.\n\n#### Properties\n- **Count**: The number of items in the stack.\n\n#### Methods\n- `void Push(T item)`: Pushes an item onto the stack.\n- `T Pop()`: Removes and returns the top item.\n- `T Peek()`: Returns the top item without removing it.\n- `void Clear()`: Removes all items from the stack.\n\n#### Example\n```csharp\nusing (var stack = new PooledStack\u003cint\u003e())\n{\n    stack.Push(42);\n    Console.WriteLine(stack.Pop()); // 42\n}\n```\n\n### Credits\n\nSpecial thanks to:\n\n- Tom Jacques - for the original [deque implementation](https://github.com/tejacques/Deque).\n- Peteris Nikiforovs - for the original [AhoCorasick implementation](https://github.com/pdonald/aho-corasick).\n- [Just The Docs](https://github.com/just-the-docs/just-the-docs) for the documentation theme.\n\n## Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](https://github.com/Stillpoint-Software/.github/blob/main/.github/CONTRIBUTING.md) \nfor more details.\n\n# Status\n\n| Branch     | Action                                                                                                                                                                                                                      |\n|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `develop`  | [![Build status](https://github.com/Stillpoint-Software/Hyperbee.Collections/actions/workflows/pack_publish.yml/badge.svg?branch=develop)](https://github.com/Stillpoint-Software/Hyperbee.Collections/actions/workflows/pack_publish.yml)  |\n| `main`     | [![Build status](https://github.com/Stillpoint-Software/Hyperbee.Collections/actions/workflows/pack_publish.yml/badge.svg)](https://github.com/Stillpoint-Software/Hyperbee.Collections/actions/workflows/pack_publish.yml)                 |\n\n\n# Benchmarks\n See [Benchmarks](https://github.com/Stillpoint-Software/Hyperbee.Collections/test/Hyperbee.Collections.Benchmark/benchmark/results/Hyperbee.Collections.Benchmark.CollectionsBenchmark-report-github.md)\n \n\n# Help\n See [Todo](https://github.com/Stillpoint-Software/Hyperbee.Collections/blob/main/docs/todo.md)\n\n[![Hyperbee.Collections](https://github.com/Stillpoint-Software/Hyperbee.Collections/blob/main/assets/hyperbee.svg?raw=true)](https://github.com/Stillpoint-Software/Hyperbee.Collections)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstillpoint-software%2Fhyperbee.collections","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstillpoint-software%2Fhyperbee.collections","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstillpoint-software%2Fhyperbee.collections/lists"}