{"id":25935387,"url":"https://github.com/billowdev/fastmap","last_synced_at":"2025-03-04T01:37:54.355Z","repository":{"id":274286087,"uuid":"922441460","full_name":"billowdev/fastmap","owner":"billowdev","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-26T09:47:03.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-26T10:26:15.524Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/billowdev.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":"2025-01-26T08:02:36.000Z","updated_at":"2025-01-26T09:41:51.000Z","dependencies_parsed_at":"2025-01-26T10:36:23.343Z","dependency_job_id":null,"html_url":"https://github.com/billowdev/fastmap","commit_stats":null,"previous_names":["billowdev/fastmap"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billowdev%2Ffastmap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billowdev%2Ffastmap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billowdev%2Ffastmap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billowdev%2Ffastmap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/billowdev","download_url":"https://codeload.github.com/billowdev/fastmap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241768410,"owners_count":20017117,"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":[],"created_at":"2025-03-04T01:37:52.047Z","updated_at":"2025-03-04T01:37:54.331Z","avatar_url":"https://github.com/billowdev.png","language":"Go","readme":"# FastMap - A Type-Safe Generic HashMap Implementation in Go\n\nFastMap currently provides an efficient, type-safe HashMap implementation in Go, offering both thread-safe and non-thread-safe variants. Future releases will expand this into a comprehensive utilities package.\n\nCurrent Feature Implementation Status:\n\n✅ Core HashMap Implementation\n- Basic HashMap operations (Put, Get, Remove)\n- Type-safe implementation using Go generics\n- Full error handling\n- Comprehensive unit tests\n- Performance-optimized operations\n\n✅ Thread-Safe HashMap\n- Mutex-protected operations\n- Concurrent access support\n- Thread-safe variants of all core operations\n- Deadlock prevention\n- Performance benchmarks for concurrent operations\n\n✅ AppendableHashMap\n- Specialized slice handling\n- Type-safe append operations\n- Thread-safe variant available\n- Optimized memory management\n- Comprehensive testing coverage\n\n✅ Functional Operations\n- Map transformations\n- Filtering capabilities\n- ForEach operations with error handling\n- Chainable operations\n- Performance benchmarks\n\n\u003c!-- Planned Future Enhancements:\n\t- RobinHood HashMap Implementation\n\t- Binary Search Tree Implementation\n\t- Struct-to-Struct Conversion\n\t- Case Conversion Utilities\n\t- Additional Data Structure Support\n\t- Extended Utility Functions\n\t- Advanced Type Conversion Tools\n\t- Deep Copy Functionality --\u003e\n \nThe current version focuses on providing a robust and efficient HashMap implementation. Future releases will expand the package's capabilities to include additional data structures and utility functions.\n\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n\u003c!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --\u003e\n[contributors-shield]: https://img.shields.io/github/contributors/billowdev/fastmap.svg?style=for-the-badge\n[contributors-url]: https://github.com/billowdev/fastmap/graphs/contributors\n[forks-shield]: https://img.shields.io/github/forks/billowdev/fastmap.svg?style=for-the-badge\n[forks-url]: https://github.com/billowdev/fastmap/network/members\n[stars-shield]: https://img.shields.io/github/stars/billowdev/fastmap.svg?style=for-the-badge\n[stars-url]: https://github.com/billowdev/fastmap/stargazers\n[issues-shield]: https://img.shields.io/github/issues/billowdev/fastmap.svg?style=for-the-badge\n[issues-url]: https://github.com/billowdev/fastmap/issues\n[license-shield]: https://img.shields.io/github/license/billowdev/fastmap.svg?style=for-the-badge\n[license-url]: https://github.com/billowdev/fastmap/blob/main/LICENSE\n\n\n## Installation\n\n```bash\ngo get github.com/billowdev/fastmap\n```\n\n## Features\n\n- Generic type support for keys and values\n- Thread-safe implementation available\n- Type-safe operations\n- Functional programming utilities\n- Zero dependencies\n- Comprehensive test coverage\n\n## Usage\n\n### Basic Operations (Non-Thread-Safe)\n\n```go\n// Initialize\nhashMap := fastmap.NewHashMap[string, YourType]()\n\n// Add/Update\nhashMap.Put(\"key\", value)\n\n// Get\nvalue, exists := hashMap.Get(\"key\")\n\n// Remove\nhashMap.Remove(\"key\")\n\n// Get size\nsize := hashMap.Size()\n\n// Update existing value\nsuccess := hashMap.UpdateValue(\"key\", newValue)\n```\n\n- AppendValues\n```go\n// processSections handles the conversion and organization of section data into specialized\n// hash maps for both body content and layout components. It demonstrates the use of\n// AppendableHashMap for managing collections of PDF components per section.\n//\n// Parameters:\n//   - listSections: Slice of Section objects containing section data and components\n//\n// Example:\n//\n//\tsections := []Section{\n//\t    {\n//\t        ID: \"section1\",\n//\t        PDFListComponents: []models.PDFListComponent{comp1, comp2},\n//\t    },\n//\t}\n//\tprocessSections(sections)\nfunc processSections(listSections []Section) {\n    // Initialize specialized hash maps for different data types\n    bodyHashMap := fastmap.NewHashMap[string, domain.ResSection]()\n    layoutHashMap := fastmap.NewAppendableHashMap[string, models.PDFListComponent]()\n    \n    // Process each section and organize its data into appropriate maps\n    for _, section := range listSections {\n        // Store section metadata in body hash map\n        bodyHashMap.Put(section.ID, domain.ResSection{\n            SectionID: section.ID,\n            Section:   section.Section,\n            Priority:  section.Priority,\n            Title:     string(section.Title),\n            Elements:  nil,\n        })\n        \n        // Append PDF components to layout hash map using spread operator equivalent\n        layoutHashMap.AppendValues(section.ID, section.PDFListComponents...)\n    }\n    \n    // Example of thread-safe implementation if needed for concurrent access\n    safeLayoutHashMap := fastmap.NewThreadSafeAppendableHashMap[string, models.PDFListComponent]()\n    for _, section := range listSections {\n        safeLayoutHashMap.AppendValues(section.ID, section.PDFListComponents...)\n    }\n}\n```\n\n\n### Thread-Safe Operations\n\n```go\n// Initialize thread-safe map\nsafeMap := fastmap.NewThreadSafeHashMap[string, YourType]()\n\n// Basic Operations\nsafeMap.Put(\"key\", value)\nvalue, exists := safeMap.Get(\"key\")\nsafeMap.Remove(\"key\")\n\n// Safe iteration\nsafeMap.ForEach(func(key string, value YourType) error {\n    // Process each key-value pair safely\n})\n\n// Check existence\nif safeMap.Contains(\"key\") {\n    // Key exists, safe for concurrent access\n}\n\n// Get all keys safely\nkeys := safeMap.Keys()\nfor _, key := range keys {\n    // Process keys\n}\n\n// Get all values safely\nvalues := safeMap.Values()\nfor _, value := range values {\n    // Process values\n}\n\n// Clear all entries safely\nsafeMap.Clear()\n\n// Check if empty\nif safeMap.IsEmpty() {\n    // Map is empty\n}\n\n// Merge two thread-safe maps\notherMap := fastmap.NewThreadSafeHashMap[string, YourType]()\notherMap.Put(\"other\", value)\nsafeMap.PutAll(otherMap)\n\n// Convert to regular map\nregularMap := safeMap.ToMap()\n\n// Create from regular map\ntraditional := map[string]YourType{\"key\": value}\nsafeMap = fastmap.FromThreadSafeMap(traditional)\n```\n\n### Thread-Safe Functional Operations\n\n```go\n// Filter with thread safety\nactiveUsers := safeMap.Filter(func(key string, user User) bool {\n    return user.Active\n})\n\n// Transform with thread safety\nprocessedUsers := safeMap.Map(func(key string, user User) User {\n    user.LastProcessed = time.Now()\n    return user\n})\n\n// Conditional updates with thread safety\nif safeMap.UpdateValue(\"user1\", updatedUser) {\n    // Update successful\n}\n```\n\n### Real-World Example (Thread-Safe)\n\n```go\n// User management system with concurrent access\ntype UserSystem struct {\n    users *fastmap.ThreadSafeHashMap[string, User]\n}\n\nfunc NewUserSystem() *UserSystem {\n    return \u0026UserSystem{\n        users: fastmap.NewThreadSafeHashMap[string, User](),\n    }\n}\n\n// Safe concurrent operations\nfunc (s *UserSystem) AddUser(id string, user User) {\n    s.users.Put(id, user)\n}\n\nfunc (s *UserSystem) GetActiveUsers() []User {\n    activeUsers := s.users.Filter(func(id string, user User) bool {\n        return user.Active \u0026\u0026 !user.Deleted\n    })\n    return activeUsers.Values()\n}\n\nfunc (s *UserSystem) UpdateUserStatus(id string, active bool) bool {\n    if user, exists := s.users.Get(id); exists {\n        user.Active = active\n        return s.users.UpdateValue(id, user)\n    }\n    return false\n}\n\nfunc (s *UserSystem) ProcessUsers() {\n    s.users.ForEach(func(id string, user User) error {\n        // Safe concurrent processing\n        log.Printf(\"Processing user: %s\", id)\n        return nil\n    })\n}\n\n// Usage in concurrent environment\nfunc main() {\n    system := NewUserSystem()\n    \n    // Concurrent operations\n    go func() {\n        system.AddUser(\"1\", User{Name: \"John\", Active: true})\n    }()\n    \n    go func() {\n        system.UpdateUserStatus(\"1\", false)\n    }()\n    \n    go func() {\n        activeUsers := system.GetActiveUsers()\n        for _, user := range activeUsers {\n            log.Printf(\"Active user: %s\", user.Name)\n        }\n    }()\n}\n```\n\n- Append Values\n```go\npackage main\n\nimport (\n    \"log\"\n    \"sync\"\n    \"time\"\n\n    \"github.com/billowdev/fastmap/hashmap\"\n)\n\n// PDFProcessor represents a system that processes PDF components concurrently\ntype PDFProcessor struct {\n    layoutMap *fastmap.ThreadSafeAppendableHashMap[string, PDFComponent]\n    wg        sync.WaitGroup\n}\n\ntype PDFComponent struct {\n    ID        string\n    Content   string\n    Timestamp time.Time\n}\n\n// NewPDFProcessor initializes a new PDF processor with thread-safe storage\nfunc NewPDFProcessor() *PDFProcessor {\n    return \u0026PDFProcessor{\n        layoutMap: fastmap.NewThreadSafeAppendableHashMap[string, PDFComponent](),\n    }\n}\n\n// ProcessSection handles concurrent processing of PDF components for a section\nfunc (p *PDFProcessor) ProcessSection(sectionID string, components []PDFComponent) {\n    batchSize := 5\n    for i := 0; i \u003c len(components); i += batchSize {\n        end := i + batchSize\n        if end \u003e len(components) {\n            end = len(components)\n        }\n\n        batch := components[i:end]\n        p.wg.Add(1)\n        go p.processBatch(sectionID, batch)\n    }\n}\n\n// processBatch handles a batch of components concurrently\nfunc (p *PDFProcessor) processBatch(sectionID string, components []PDFComponent) {\n    defer p.wg.Done()\n\n    // Simulate processing time for each component\n    for _, component := range components {\n        // Simulate some processing work\n        time.Sleep(100 * time.Millisecond)\n        \n        // Safely append the processed component\n        p.layoutMap.AppendValues(sectionID, component)\n        log.Printf(\"Processed component %s for section %s\", component.ID, sectionID)\n    }\n}\n\n// GetProcessedComponents safely retrieves all components for a section\nfunc (p *PDFProcessor) GetProcessedComponents(sectionID string) []PDFComponent {\n    components, exists := p.layoutMap.Get(sectionID)\n    if !exists {\n        return []PDFComponent{}\n    }\n    return components\n}\n\n// WaitForCompletion waits for all processing to complete\nfunc (p *PDFProcessor) WaitForCompletion() {\n    p.wg.Wait()\n}\n\n// Usage example\nfunc main() {\n    processor := NewPDFProcessor()\n\n    // Simulate incoming PDF components for multiple sections\n    sections := map[string][]PDFComponent{\n        \"section1\": generateComponents(\"section1\", 15),\n        \"section2\": generateComponents(\"section2\", 10),\n        \"section3\": generateComponents(\"section3\", 20),\n    }\n\n    // Process sections concurrently\n    startTime := time.Now()\n    for sectionID, components := range sections {\n        processor.ProcessSection(sectionID, components)\n    }\n\n    // Wait for all processing to complete\n    processor.WaitForCompletion()\n    log.Printf(\"Processing completed in %v\", time.Since(startTime))\n\n    // Verify results\n    for sectionID := range sections {\n        processed := processor.GetProcessedComponents(sectionID)\n        log.Printf(\"Section %s has %d processed components\", sectionID, len(processed))\n    }\n}\n\n// generateComponents creates test PDF components\nfunc generateComponents(sectionID string, count int) []PDFComponent {\n    components := make([]PDFComponent, count)\n    for i := 0; i \u003c count; i++ {\n        components[i] = PDFComponent{\n            ID:        fmt.Sprintf(\"%s-comp%d\", sectionID, i),\n            Content:   fmt.Sprintf(\"Content %d\", i),\n            Timestamp: time.Now(),\n        }\n    }\n    return components\n}\n\n// Example of error handling and recovery\nfunc (p *PDFProcessor) ProcessSectionWithRecovery(sectionID string, components []PDFComponent) error {\n    errorChan := make(chan error, 1)\n    \n    go func() {\n        defer func() {\n            if r := recover(); r != nil {\n                errorChan \u003c- fmt.Errorf(\"processing panic: %v\", r)\n            }\n            close(errorChan)\n        }()\n\n        p.ProcessSection(sectionID, components)\n    }()\n\n    // Wait for completion or error\n    p.wg.Wait()\n    if err := \u003c-errorChan; err != nil {\n        return fmt.Errorf(\"section %s processing failed: %w\", sectionID, err)\n    }\n\n    return nil\n}\n```\n\n### Config Field Processing\n\nThe fastmap package provides robust field configuration processing capabilities for handling dynamic data transformations. This feature is particularly useful when dealing with structured data that needs type-safe conversion and validation.\n\n#### Basic Usage\n\n```go\n// Initialize HashMap\nhashMap := fastmap.NewHashMap[string, int]()\nhashMap.Put(\"age\", 0) // Initialize field\n\n// Define field configurations\nconfigs := map[string]fastmap.FieldConfig[int]{\n    \"age\": {\n        Handler: func(data map[string]interface{}) *int {\n            if val, ok := data[\"age\"].(float64); ok {\n                intVal := int(val)\n                return \u0026intVal\n            }\n            return nil\n        },\n    },\n}\n\n// Process data\ndata := []map[string]interface{}{\n    {\"age\": 25.0},\n    {\"age\": 30.0},\n}\n\n// Method 1: Handle single field\nresults := hashMap.HandleFieldConfigs(data, configs, \"age\")\n// results = []int{25, 30}\n\n// Method 2: Apply single config\nsuccess := hashMap.ApplyFieldConfig(\"age\", configs[\"age\"], data[0])\n// success = true, hashMap[\"age\"] = 25\n\n// Method 3: Process all configs with callback\nhashMap.ProcessFieldConfigs(configs, data, func(key string, value int, index int) {\n    fmt.Printf(\"Processed %s: %d at index %d\\n\", key, value, index)\n})\n```\n\n#### Thread-Safe Processing\n\n1. Basic Thread-Safe Operations\n```go\n// Initialize thread-safe map\nsafeMap := fastmap.NewThreadSafeHashMap[string, float64]()\nsafeMap.Put(\"temperature\", 0.0)\n\n// Configure field handlers\nconfigs := map[string]fastmap.FieldConfig[float64]{\n    \"temperature\": {\n        Handler: func(data map[string]interface{}) *float64 {\n            if val, ok := data[\"temp\"].(float64); ok {\n                return \u0026val\n            }\n            return nil\n        },\n    },\n}\n\n// Safe concurrent processing\nsafeMap.ProcessFieldConfigs(configs, data, func(key string, value float64, index int) {\n    log.Printf(\"Temperature reading %f at index %d\", value, index)\n})\n```\n\n2. Concurrent Data Processing\n```go\n// Initialize thread-safe map with complex config\ntype Measurement struct {\n    Value     float64\n    Timestamp time.Time\n    Valid     bool\n}\n\nsafeMap := fastmap.NewThreadSafeHashMap[string, Measurement]()\nrowIndex := 0\n\nconfigs := map[string]fastmap.FieldConfig[Measurement]{\n    \"sensor_data\": {\n        RowIndex: \u0026rowIndex,\n        Handler: func(data map[string]interface{}) *Measurement {\n            if val, ok := data[\"value\"].(float64); ok {\n                return \u0026Measurement{\n                    Value:     val,\n                    Timestamp: time.Now(),\n                    Valid:     val \u003e= 0 \u0026\u0026 val \u003c= 100,\n                }\n            }\n            return nil\n        },\n    },\n}\n\n// Concurrent processing with error handling\nvar wg sync.WaitGroup\nfor i := 0; i \u003c 10; i++ {\n    wg.Add(1)\n    go func(index int) {\n        defer wg.Done()\n        sensorData := []map[string]interface{}{\n            {\"value\": float64(index * 10)},\n        }\n        safeMap.ProcessFieldConfigs(configs, sensorData, func(key string, m Measurement, idx int) {\n            if m.Valid {\n                log.Printf(\"Valid measurement %f at time %v\", m.Value, m.Timestamp)\n            }\n        })\n    }(i)\n}\nwg.Wait()\n```\n\n3. Batch Processing with Multiple Fields\n```go\ntype ProductData struct {\n    Price    float64\n    Quantity int\n    Total    float64\n}\n\nsafeMap := fastmap.NewThreadSafeHashMap[string, ProductData]()\nconfigs := map[string]fastmap.FieldConfig[ProductData]{\n    \"product\": {\n        Handler: func(data map[string]interface{}) *ProductData {\n            price, ok1 := data[\"price\"].(float64)\n            qty, ok2 := data[\"quantity\"].(float64)\n            if !ok1 || !ok2 {\n                return nil\n            }\n            return \u0026ProductData{\n                Price:    price,\n                Quantity: int(qty),\n                Total:    price * float64(int(qty)),\n            }\n        },\n    },\n}\n\n// Process batch data concurrently\nbatchData := []map[string]interface{}{\n    {\"price\": 10.5, \"quantity\": 2.0},\n    {\"price\": 20.0, \"quantity\": 3.0},\n}\n\nsafeMap.ProcessFieldConfigs(configs, batchData, func(key string, pd ProductData, index int) {\n    log.Printf(\"Processed product at index %d: Total = %.2f\", index, pd.Total)\n})\n```\n\n4. Error Handling in Thread-Safe Context\n```go\nsafeMap := fastmap.NewThreadSafeHashMap[string, int]()\nrowIndex := 0\n\nconfigs := map[string]fastmap.FieldConfig[int]{\n    \"quantity\": {\n        RowIndex: \u0026rowIndex,\n        Handler: func(data map[string]interface{}) *int {\n            val, ok := data[\"quantity\"]\n            if !ok {\n                log.Printf(\"Missing quantity field at row %d\", *rowIndex)\n                return nil\n            }\n            if floatVal, ok := val.(float64); ok {\n                intVal := int(floatVal)\n                if intVal \u003c 0 {\n                    log.Printf(\"Invalid negative quantity at row %d\", *rowIndex)\n                    return nil\n                }\n                return \u0026intVal\n            }\n            return nil\n        },\n    },\n}\n\n// Process with validation\nsafeMap.ProcessFieldConfigs(configs, data, func(key string, quantity int, index int) {\n    log.Printf(\"Processed quantity %d at index %d\", quantity, index)\n})\n```\n\n#### Advanced Features\n\n1. Row Index Tracking\n```go\nrowIndex := 0\nconfigs := map[string]fastmap.FieldConfig[string]{\n    \"name\": {\n        RowIndex: \u0026rowIndex,\n        Handler: func(data map[string]interface{}) *string {\n            if val, ok := data[\"name\"].(string); ok {\n                return \u0026val\n            }\n            return nil\n        },\n    },\n}\n```\n\n2. Complex Type Handling\n```go\ntype UserData struct {\n    Name  string\n    Age   int\n    Score float64\n}\n\nconfigs := map[string]fastmap.FieldConfig[UserData]{\n    \"user_info\": {\n        Handler: func(data map[string]interface{}) *UserData {\n            if name, ok := data[\"name\"].(string); ok {\n                if age, ok := data[\"age\"].(float64); ok {\n                    if score, ok := data[\"score\"].(float64); ok {\n                        return \u0026UserData{\n                            Name:  name,\n                            Age:   int(age),\n                            Score: score,\n                        }\n                    }\n                }\n            }\n            return nil\n        },\n    },\n}\n```\n\n3. Batch Processing with Multiple Configs\n```go\nconfigs := map[string]fastmap.FieldConfig[string]{\n    \"name\": {Handler: nameHandler},\n    \"email\": {Handler: emailHandler},\n    \"phone\": {Handler: phoneHandler},\n}\n\nhashMap.ProcessFieldConfigs(configs, bulkData, func(key string, value string, index int) {\n    switch key {\n    case \"name\":\n        processName(value, index)\n    case \"email\":\n        processEmail(value, index)\n    case \"phone\":\n        processPhone(value, index)\n    }\n})\n```\n\n4. Field Dependencies\n```go\ntype ProductSpec struct {\n    Price    float64\n    Quantity int\n    Total    float64\n}\n\nconfigs := map[string]fastmap.FieldConfig[ProductSpec]{\n    \"product\": {\n        Handler: func(data map[string]interface{}) *ProductSpec {\n            price, ok1 := data[\"price\"].(float64)\n            qty, ok2 := data[\"quantity\"].(float64)\n            if !ok1 || !ok2 {\n                return nil\n            }\n            return \u0026ProductSpec{\n                Price:    price,\n                Quantity: int(qty),\n                Total:    price * qty,\n            }\n        },\n    },\n}\n```\n## Testing\n\n### Unit Tests\n\nRun all unit tests:\n```bash\ngo test ./...\n```\n\nRun specific test:\n```bash\ngo test -run TestHashMap_Put\n```\n\nRun tests with coverage:\n```bash\ngo test -cover ./...\n```\n\nGenerate coverage report:\n```bash\ngo test -coverprofile=coverage.out ./...\ngo tool cover -html=coverage.out\n```\n\n#### Key Test Categories\n\n1. Basic Operations\n```go\nfunc TestHashMap_Put(t *testing.T) {\n    h := fastmap.NewHashMap[string, int]()\n    h.Put(\"key\", 100)\n    if val, exists := h.Get(\"key\"); !exists || val != 100 {\n        t.Errorf(\"Put failed, got (%v, %v), want (100, true)\", val, exists)\n    }\n}\n```\n\n2. Thread-Safe Operations\n```go\nfunc TestThreadSafeConcurrentOperations(t *testing.T) {\n    m := fastmap.NewThreadSafeHashMap[string, int]()\n    var wg sync.WaitGroup\n    numGoroutines := 100\n\n    for i := 0; i \u003c numGoroutines; i++ {\n        wg.Add(1)\n        go func(val int) {\n            defer wg.Done()\n            m.Put(fmt.Sprintf(\"key%d\", val), val)\n        }(i)\n    }\n    wg.Wait()\n\n    if m.Size() != numGoroutines {\n        t.Errorf(\"Expected size %d, got %d\", numGoroutines, m.Size())\n    }\n}\n```\n\n3. Functional Operations\n```go\nfunc TestFilter(t *testing.T) {\n    h := fastmap.NewHashMap[string, int]()\n    h.Put(\"one\", 1)\n    h.Put(\"two\", 2)\n    \n    filtered := h.Filter(func(k string, v int) bool {\n        return v%2 == 0\n    })\n    \n    if filtered.Size() != 1 {\n        t.Error(\"Filter failed\")\n    }\n}\n```\n\n4. Edge Cases\n```go\nfunc TestEdgeCases(t *testing.T) {\n    h := fastmap.NewHashMap[string, *string]()\n    var nilStr *string\n    \n    h.Put(\"nilKey\", nilStr)\n    if val, exists := h.Get(\"nilKey\"); !exists || val != nil {\n        t.Error(\"Failed to handle nil value\")\n    }\n}\n```\n\n### Benchmarks\n\nRun all benchmarks:\n```bash\ngo test -bench=. ./...\n```\n\nRun specific benchmark:\n```bash\ngo test -bench=BenchmarkHashMapPut\n```\n\nRun benchmarks with memory allocation statistics:\n```bash\ngo test -bench=. -benchmem ./...\n```\n\n#### Key Benchmark Categories\n\n1. Basic Operations\n```go\nfunc BenchmarkHashMapPut(b *testing.B) {\n    h := fastmap.NewHashMap[string, int]()\n    for i := 0; i \u003c b.N; i++ {\n        h.Put(\"key\", i)\n    }\n}\n```\n\n2. Thread-Safe Operations\n```go\nfunc BenchmarkThreadSafePut(b *testing.B) {\n    m := fastmap.NewThreadSafeHashMap[string, int]()\n    b.RunParallel(func(pb *testing.PB) {\n        i := 0\n        for pb.Next() {\n            m.Put(fmt.Sprintf(\"key%d\", i), i)\n            i++\n        }\n    })\n}\n```\n\n3. Functional Operations\n```go\nfunc BenchmarkHashMapFilter(b *testing.B) {\n    h := fastmap.NewHashMap[string, int]()\n    for i := 0; i \u003c 1000; i++ {\n        h.Put(fmt.Sprintf(\"key%d\", i), i)\n    }\n    b.ResetTimer()\n    for i := 0; i \u003c b.N; i++ {\n        h.Filter(func(k string, v int) bool {\n            return v%2 == 0\n        })\n    }\n}\n```\n\n#### Benchmark Tips\n\n1. Use realistic data sizes\n2. Include parallel benchmarks for thread-safe operations\n3. Test with different data types and structures\n4. Measure memory allocations for memory-sensitive operations\n5. Compare performance with standard library map operations\n\n#### Common Benchmark Flags\n\n```bash\n-bench=.                # Run all benchmarks\n-benchmem              # Print memory allocation statistics\n-benchtime=10s         # Run each benchmark for 10 seconds\n-count=5               # Run each benchmark 5 times\n-cpu=1,2,4            # Run benchmarks with different GOMAXPROCS values\n```\n\n#### Profile Benchmarks\n\nGenerate CPU profile:\n```bash\ngo test -bench=. -cpuprofile=cpu.prof\ngo tool pprof cpu.prof\n```\n\nGenerate memory profile:\n```bash\ngo test -bench=. -memprofile=mem.prof\ngo tool pprof mem.prof\n```\n\n## Migration Guide\n\n### Traditional Map vs HashMap\n\n```go\n// Traditional\ntraditional := make(map[string]YourType)\ntraditional[key] = value\n\n// Non-Thread-Safe HashMap\nhashMap := fastmap.NewHashMap[string, YourType]()\nhashMap.Put(key, value)\n\n// Thread-Safe HashMap\nsafeMap := fastmap.NewThreadSafeHashMap[string, YourType]()\nsafeMap.Put(key, value)\n```\n\n## Performance\n\n- Built on Go's native map implementation\n- Minimal method call overhead\n- O(1) average case for basic operations\n- Thread-safe operations use sync.RWMutex\n- Read operations allow concurrent access\n- Write operations ensure exclusive access\n\n## Contributing\n\n1. Fork the repository\n2. Create your feature branch\n3. Commit your changes\n4. Push to the branch\n5. Create a Pull Request\n\n### Top contributors:\n\n\u003ca href=\"https://github.com/billowdev/fastmap/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=billowdev/fastmap\" alt=\"contrib.rocks image\" /\u003e\n\u003c/a\u003e\n\n## License\n\nThis project is licensed under the MIT License\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbillowdev%2Ffastmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbillowdev%2Ffastmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbillowdev%2Ffastmap/lists"}