Agent skill

optimizing-fast-lookup-lite

Provides essential fast lookup patterns with HashSet and Dictionary. Use when quickly referencing core O(1) lookup techniques without detailed explanations.

Stars 163
Forks 31

Install this agent skill to your Project

npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/optimizing-fast-lookup-lite

SKILL.md

Fast Lookup Essentials

1. HashSet<T>

csharp
// O(1) existence check
var allowedIds = new HashSet<int> { 1, 2, 3, 4, 5 };

if (allowedIds.Contains(userId))
{
    // Allowed user
}

2. FrozenSet<T> (.NET 8+)

csharp
using System.Collections.Frozen;

// Immutable fast lookup
var allowedExtensions = new[] { ".jpg", ".png", ".gif" }
    .ToFrozenSet(StringComparer.OrdinalIgnoreCase);

3. Dictionary Optimization

csharp
// ❌ Two lookups
if (dict.ContainsKey(key))
    var value = dict[key];

// ✅ Single lookup
if (dict.TryGetValue(key, out var value))
{
    // Use value
}

4. When to Use

Scenario Recommended Collection
Frequently modified set HashSet<T>
Read-only configuration FrozenSet<T>
Key-Value cache Dictionary<K,V>

For details: See /dotnet-fast-lookup skill

Expand your agent's capabilities with these related and highly-rated skills.

Didn't find tool you were looking for?

Be as detailed as possible for better results