Table of Contents

Class ClusterSeedMortonSorter

Namespace
LansMap.Core.Markers

Reorders a cluster build's seed list into Morton (Z-order) spatial order in place, so the greedy merge loop that follows visits spatially adjacent seeds consecutively instead of in an arbitrary input order.

public sealed class ClusterSeedMortonSorter
Inheritance
object
ClusterSeedMortonSorter

Remarks

A caller that clusters the same store contents twice must feed the sorter the same pre-sort seed order both times to get the same result - Sort(List<ClusterSeed>) itself is deterministic given that order, on any runtime.

Reusable scratch: Sort(List<ClusterSeed>) allocates only the first time it is asked to sort more seeds than any previous call on this instance, so a caller that reuses one instance across many builds pays that cost once.

Fields

MaxSeeds

Most seeds one Sort(List<ClusterSeed>) call can order: the tiebreak ordinal packed into the key's low 24 bits caps out here.

public const int MaxSeeds = 16777216

Field Value

int

Methods

Sort(List<ClusterSeed>)

Reorders seeds in place into ascending Morton order over its seeds' normalized mercator position, breaking a tie (including an exact duplicate coordinate) by each seed's original position in seeds - so the result is a total order, reproducible identically on any runtime, for any input.

public void Sort(List<ClusterSeed> seeds)

Parameters

seeds List<ClusterSeed>

Caller-owned list, reordered in place. Zero or one seed is left untouched.

Exceptions

ArgumentNullException

seeds is null.

ArgumentOutOfRangeException

seeds holds more than MaxSeeds entries.