Game.Simulation.Flow.LabelHeapData
Assembly:
Assembly-CSharp (game runtime)
Namespace:
Game.Simulation.Flow
Type:
struct
Base:
System.ValueType, Colossal.Collections.ILessThan
Summary:
LabelHeapData is a lightweight value-type container used by pathfinding/flow algorithms to represent a heap entry: it stores a node index and an associated distance (priority). It implements ILessThan
Fields
-
public int m_NodeIndex
Index of the node this label refers to. Typically used as an identifier into node arrays in the simulation. -
public int m_Distance
Distance (or priority) associated with the node — used by the heap to order entries (smaller = higher priority).
Properties
- This struct exposes no properties. It uses public fields for direct, allocation-free access suitable for performance-sensitive code.
Constructors
public LabelHeapData(int nodeIndex, int distance)
Creates a new LabelHeapData with the given node index and distance.
Parameters: - nodeIndex: index of the node. - distance: distance/priority value.
Methods
-
public bool LessThan(LabelHeapData other)
Implements ILessThan. Returns true if this instance's m_Distance is less than the other's m_Distance. Used by heap implementations to maintain min-heap order by distance. -
public override string ToString()
Returns a formatted string describing the instance, e.g. "m_NodeIndex: 5, m_Distance: 100".
Usage Example
// Simple usage examples
var a = new LabelHeapData(nodeIndex: 5, distance: 100);
var b = new LabelHeapData(nodeIndex: 6, distance: 150);
// Compare (used by heaps to order elements)
bool aHasHigherPriority = a.LessThan(b); // true because 100 < 150
// Debug print
Debug.Log(a.ToString()); // "m_NodeIndex: 5, m_Distance: 100"
// Typical usage pattern: pushed into a heap/priority queue used by pathfinding.
// Example (pseudo-code, actual heap API may differ):
// var heap = new Colossal.Collections.Heap<LabelHeapData>();
// heap.Enqueue(new LabelHeapData(nodeIndex, distance));
// var best = heap.Dequeue(); // uses LessThan to order entries