AABB
AlignmentBehavior
ArriveBehavior
AStar
BFS
BoundingSphere
BVH
BVHNode
Cell
CellSpacePartitioning
CohesionBehavior
CompositeGoal
ConvexHull
Corridor
CostTable
DFS
Dijkstra
Edge
EntityManager
EvadeBehavior
EventDispatcher
Behavior
FollowPathBehavior
FuzzyAND
FuzzyCompositeTerm
FuzzyFAIRLY
FuzzyModule
FuzzyOR
FuzzyRule
FuzzySet
FuzzyTerm
FuzzyVariable
FuzzyVERY
GameEntity
Goal
GoalEvaluator
Graph
GraphUtils
HalfEdge
HeuristicPolicyDijkstra
HeuristicPolicyEuclid
HeuristicPolicyEuclidSquared
HeuristicPolicyManhattan
InterposeBehavior
LeftSCurveFuzzySet
LeftShoulderFuzzySet
LineSegment
Logger
MathUtils
Matrix3
Matrix4
MemoryRecord
MemorySystem
MeshGeometry
MessageDispatcher
MovingEntity
NavEdge
NavMesh
NavMeshLoader
NavNode
Node
NormalDistFuzzySet
OBB
ObstacleAvoidanceBehavior
OffsetPursuitBehavior
OnPathBehavior
Path
Plane
Polygon
Polyhedron
PriorityQueue
PursuitBehavior
Quaternion
Ray
RectangleTriggerRegion
Regular
RightSCurveFuzzySet
RightShoulderFuzzySet
SAT
SeekBehavior
SeparationBehavior
SingletonFuzzySet
Smoother
SphericalTriggerRegion
State
StateMachine
SteeringBehavior
SteeringManager
Task
TaskQueue
Telegram
Think
Time
TriangularFuzzySet
Trigger
TriggerRegion
Vector3
Vehicle
Version
WanderBehavior

data

简介

Yuka js库中的PriorityQueue类是一种优先级队列,它能够根据元素的优先级进行排序并保证下次弹出的元素是优先级最高的。该类的 data 属性存储了所有的元素,以数组的形式排队等待处理。

数据结构

数据结构为一维数组,其中元素根据优先级进行排序。

示例

const queue = new PriorityQueue();

queue.push('B', 2);
queue.push('A', 1);
queue.push('C', 3);

console.log(queue.data); // 输出:['C', 'B', 'A']

API

push(item, priority)

添加一个元素到队列中。

  • item - 要添加到队列中的元素。
  • priority - 该元素的优先级。

pop()

从队列中移除优先级最高的元素并返回它。

peek()

查看优先级最高的元素,但不从队列中移除。

clear()

清空队列中的所有元素。

isEmpty()

如果队列为空则返回 true,否则返回 false

size()

返回队列中元素的数量。