# assaidy/binary_heap architecture

> Architecture diagram of the GitHub repository assaidy/binary_heap, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/assaidy/binary_heap
- Repository: https://github.com/assaidy/binary_heap

## Overview

##### Main Components

a) Core Binary Heap Structure:
- Inside, represent the underlying array/slice storage
- A reference to the comparison function

b) Operations Layer:
- Main operations (Insert, Pop, Peek)
- Helper methods (heapifyUp, heapifyDown)
- Heap sort as a separate utility function

- Binary Heap                  |

- Data Structure:                          |
- Internal Array/Slice                   |
- Comparison Function                    |

- Core Operations:                         |
- Insert                                 |
- Pop                                    |
- Peek                                   |

- Helper Operations:                       |
- heapifyUp                             |
- heapifyDown                           |
- HeapSort (utility)                    |

##### Specific Elements

- How Insert operation triggers heapifyUp
- How Pop operation triggers heapifyDown
- Demonstrate heap property maintenance

b) Type Parameters:
- Generic type support
- Comparison function interface

c) Visual Representations:
- A small binary tree visualization showing the heap property
- Array representation mapping

##### Important Details to Capture

- Generic type system implementation
- Comparison function flexibility (min-heap vs max-heap)
- Heap property maintenance
- In-place sorting capability

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph BinaryHeap
        DS[Data Structure]
        CF[Comparison Function]
        IA[Internal Array Storage]
        
        DS --> CF
        DS --> IA
    end

    subgraph CoreOperations
        INS[Insert]
        POP[Pop]
        PEEK[Peek]
    end

    subgraph HelperOperations
        HU[HeapifyUp]
        HD[HeapifyDown]
        HS[HeapSort]
    end

    subgraph Implementation
        TESTS[Tests]
        DOCS[Documentation]
    end

    %% Core Operations Flow
    INS --> HU
    POP --> HD
    HS --> POP

    %% Data Structure Relationships
    INS --> DS
    POP --> DS
    PEEK --> DS
    
    %% Helper Operations Flow
    HU --> DS
    HD --> DS
    HS --> DS

    %% Testing and Documentation
    TESTS --> BinaryHeap
    TESTS --> CoreOperations
    TESTS --> HelperOperations
    DOCS --> BinaryHeap

    %% Styling
    classDef core fill:#2374ab
    classDef ops fill:#47a025
    classDef helper fill:#ff7f50
    classDef impl fill:#8a2be2
    classDef docs fill:#808080

    class DS,CF,IA core
    class INS,POP,PEEK ops
    class HU,HD,HS helper
    class TESTS impl
    class DOCS docs

    %% Click Events
    click DS "https://github.com/assaidy/binary_heap/blob/main/binary_heap.go"
    click CF "https://github.com/assaidy/binary_heap/blob/main/binary_heap.go"
    click IA "https://github.com/assaidy/binary_heap/blob/main/binary_heap.go"
    click INS "https://github.com/assaidy/binary_heap/blob/main/binary_heap.go"
    click POP "https://github.com/assaidy/binary_heap/blob/main/binary_heap.go"
    click PEEK "https://github.com/assaidy/binary_heap/blob/main/binary_heap.go"
    click HU "https://github.com/assaidy/binary_heap/blob/main/binary_heap.go"
    click HD "https://github.com/assaidy/binary_heap/blob/main/binary_heap.go"
    click HS "https://github.com/assaidy/binary_heap/blob/main/binary_heap.go"
    click TESTS "https://github.com/assaidy/binary_heap/blob/main/binary_heap_test.go"
    click DOCS "https://github.com/assaidy/binary_heap/blob/main/README.md"

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Public Operations]:::ops
        L3[Helper Methods]:::helper
        L4[Implementation]:::impl
        L5[Documentation]:::docs
    end
```
