All Known Implementing Classes:
PrimitiveMinHeap, QuaternaryPrimitiveMinHeap

public interface Siftable
Contract for heap implementations that use sift operations to maintain heap property.

Sifting is the fundamental operation in heap data structures to restore the heap invariant after insertions or deletions.

Since:
5.4.3
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    siftDown(int index)
    Moves a node down the heap until the heap property is restored.
    void
    siftUp(int index)
    Moves a node up the heap until the heap property is restored.
  • Method Details

    • siftUp

      void siftUp(int index)
      Moves a node up the heap until the heap property is restored.

      Used after inserting a new node or decreasing a node's cost.

      Parameters:
      index - the starting position of the node to sift up
    • siftDown

      void siftDown(int index)
      Moves a node down the heap until the heap property is restored.

      Used after removing the minimum element or increasing a node's cost.

      Parameters:
      index - the starting position of the node to sift down