From wpf-dev-pack
Implements O(1) lookup patterns using HashSet, FrozenSet, and optimized Dictionary in .NET for high-performance search and membership testing.
How this skill is triggered — by the user, by Claude, or both
Slash command
/wpf-dev-pack:optimizing-fast-lookuphaikuThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
A guide for fast lookup APIs leveraging O(1) time complexity.
A guide for fast lookup APIs leveraging O(1) time complexity.
Quick Reference: See QUICKREF.md for essential patterns at a glance.
| API | Time Complexity | Features |
|---|---|---|
HashSet<T> | O(1) | Mutable, no duplicates |
FrozenSet<T> | O(1) | Immutable, .NET 8+ |
Dictionary<K,V> | O(1) | Mutable, Key-Value |
FrozenDictionary<K,V> | O(1) | Immutable, .NET 8+ |
// O(1) time complexity for existence check
var allowedIds = new HashSet<int> { 1, 2, 3, 4, 5 };
if (allowedIds.Contains(userId))
{
// Allowed user
}
// Set operations
setA.IntersectWith(setB); // Intersection
setA.UnionWith(setB); // Union
setA.ExceptWith(setB); // Difference
using System.Collections.Frozen;
// Immutable fast lookup (read-only scenarios)
var allowedExtensions = new[] { ".jpg", ".png", ".gif" }
.ToFrozenSet(StringComparer.OrdinalIgnoreCase);
if (allowedExtensions.Contains(fileExtension))
{
// Allowed extension
}
// ❌ Two lookups
if (dict.ContainsKey(key))
{
var value = dict[key];
}
// ✅ Single lookup
if (dict.TryGetValue(key, out var value))
{
// Use value
}
// Lookup with default value
var value = dict.GetValueOrDefault(key, defaultValue);
// Case-insensitive string comparison
var set = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
set.Add("Hello");
set.Contains("HELLO"); // true
| Scenario | Recommended Collection |
|---|---|
| Frequently modified set | HashSet<T> |
| Read-only configuration data | FrozenSet<T> |
| Frequent existence checks | HashSet<T> / FrozenSet<T> |
| Key-Value cache | Dictionary<K,V> |
| Static mapping table | FrozenDictionary<K,V> |
npx claudepluginhub christian289/dotnet-with-claudecode --plugin wpf-dev-packDesign .NET types for performance. Covers struct vs class decision matrix, sealed by default, readonly structs, ref struct and Span/Memory selection, FrozenDictionary, ValueTask, and collection return types. Use when designing new types and APIs, reviewing code for performance issues, choosing between class, struct, and record, or working with collections and enumerables.
Provides C# LINQ guidance on query syntax, method syntax, deferred execution, performance optimization, and advanced patterns for querying collections.
Provides .NET backend patterns for APIs, MCP servers, and enterprise apps: clean architecture, DI, EF Core, Dapper, Redis caching, IOptions config, and xUnit testing.