Skip to content

Game.Net.EdgeIteratorValueSorted

Assembly: Assembly-CSharp
Namespace: Game.Net

Type: struct

Base: IComparable

Summary: A lightweight value type used to represent and sort edge-related items by a numeric sort index. It stores a reference to an edge Entity and two boolean flags (m_End and m_Middle). The CompareTo implementation orders instances by m_SortIndex in ascending order (returns -1 if this < other, 0 if equal, 1 if this > other) using Unity.Mathematics.math.select to avoid branching — suitable for performance-sensitive contexts (Burst-friendly patterns).


Fields

  • public Unity.Entities.Entity m_Edge Reference to the underlying edge entity. This identifies the edge associated with this entry; the sort does not consider this field.

  • public uint m_SortIndex Primary sort key. Instances are ordered by this value in ascending order. CompareTo only compares this field.

  • public bool m_End Flag indicating whether this iterator value corresponds to an edge "end" (semantic meaning depends on how the caller sets it).

  • public bool m_Middle Flag indicating whether this iterator value corresponds to an edge "middle" (semantic meaning depends on how the caller sets it).

Properties

  • This type defines no properties.

Constructors

  • public EdgeIteratorValueSorted()
    Struct default constructor (value-initialized). No custom constructors are defined in the source.

Methods

  • public int CompareTo(EdgeIteratorValueSorted other) Compares this instance to another by m_SortIndex. Behavior:
  • Returns 0 if m_SortIndex == other.m_SortIndex
  • Returns -1 if m_SortIndex < other.m_SortIndex
  • Returns 1 if m_SortIndex > other.m_SortIndex

Implementation note: the comparison is implemented with Unity.Mathematics.math.select to reduce branching and keep the method suitable for high-performance contexts (Burst-friendly code style). The method does not consider m_Edge, m_End, or m_Middle — only m_SortIndex determines ordering.

Usage Example

using System;
using Unity.Entities;
using Game.Net;

// Create an array of items and sort them by m_SortIndex
EdgeIteratorValueSorted[] items = new EdgeIteratorValueSorted[3];

items[0] = new EdgeIteratorValueSorted { m_Edge = Entity.Null, m_SortIndex = 42, m_End = false, m_Middle = true };
items[1] = new EdgeIteratorValueSorted { m_Edge = Entity.Null, m_SortIndex = 10, m_End = true, m_Middle = false };
items[2] = new EdgeIteratorValueSorted { m_Edge = Entity.Null, m_SortIndex = 21, m_End = false, m_Middle = false };

Array.Sort(items); // Uses CompareTo to sort by m_SortIndex ascending

for (int i = 0; i < items.Length; i++)
{
    Console.WriteLine($"Index {i}: SortIndex={items[i].m_SortIndex}, End={items[i].m_End}, Middle={items[i].m_Middle}");
}

Notes and recommendations: - If stable sorting that respects tie-breakers is required, extend the comparison to include additional fields (for example m_Edge or flags) because current CompareTo treats equal m_SortIndex as equal items. - The implementation is optimized to avoid branching; this favors use inside performance-critical loops or Burst-compiled code.