• Effekt Logo Effekt Library
    • heap
      • Heap
      • heap
      • heap
      • left
      • right
      • parent
      • bubbleUp
      • sinkDown
      • insert
      • findMin
      • deleteMin
      • size
    • heap
    • Jump to source: libraries/common/heap.effekt
      Example usage: examples/stdlib/heap
      • Heap [T] (rawContents: ResizableArray[T], cmp: (T, T) => Ordering at {})
      • Resizable 2-ary min-heap, backed by a resizable array
        `cmp` defines the ordering of elements
      • heap [T] (cmp: (T, T) => Ordering at {})
      • Make a new Heap with the given comparison operation
      • heap [T] (cmp: (T, T) => Ordering at {}, capacity: Int)
      • Make a new Heap with the given comparison operation and initial capacity
      • left (idx: Int)
      • right (idx: Int)
      • parent (idx: Int)
      • bubbleUp [A] (heap: Heap[A], idx: Int)
      • sinkDown [A] (heap: Heap[A], idx: Int)
      • insert [T] (heap: Heap[T], value: T): Unit / {}
      • Insert value into heap
        
        O(log n) worst case if capacity suffices, O(1) average
      • findMin [T] (heap: Heap[T]): T / {Exception[OutOfBounds]}
      • find and return (but not remove) the minimal element in this heap
        
        O(1)
      • deleteMin [T] (heap: Heap[T]): T / {Exception[OutOfBounds]}
      • find and remove the minimal element in this heap
        
        O(log n)
      • size [T] (heap: Heap[T]): Int / {}
      • Number of elements in the heap
        
        O(1)