Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ArrayPriorityQueue<T>

ArrayPriorityQueue allows for push/pop based on an attribute of the inserted objects. The array based implementation underneath has theoretic O(c) insert time, and O(n) peek/pop time.

Though this is slower in many cases than the heap based implementation, it preserves the order better and can result in more 'normal' paths when used with pathfinding.

Type parameters

  • T

Hierarchy

  • ArrayPriorityQueue

Index

Constructors

Methods

Constructors

constructor

  • Parameters

    • priorityFunc: (t: T) => number

      A function that takes the a value that has previously been inserted, and returns a priority.

      A lower score is higher priority.

      Ex. (monster) => monster.speed

        • (t: T): number
        • Parameters

          • t: T

          Returns number

    Returns ArrayPriorityQueue

Methods

insert

  • insert(data: T): void

peek

  • peek(): T | undefined

pop

  • pop(): T | undefined
  • Get the item with the lowest priority score, removing it from the queue.

    Returns T | undefined

    • The lowest priority item

size

  • size(): number

Generated using TypeDoc