Template Numerical Library version\ main:4e6e2c1
Loading...
Searching...
No Matches
Overview of Segment Sort Functions

This page provides an overview of all sort functions available for segment operations, helping to understand the differences between variants and choose the right function for your needs.

Function Categories

The segment sort functions are organized into the following categories:

Basic Sort Functions

These functions sort elements within segments:

Function Segments Sorted Description
Segments_sortAllSegments All segments Sorts all segments in the container
Segments_sortSegments_range (range) Segments [begin, end) Sorts segments in a specified range
Segments_sortSegments_with_segment_indices (array) Segments in array Sorts only segments whose indices are in the provided array

When to use:

  • Use sortAllSegments when you need to sort all segments
  • Use sortSegments with range when you want to sort a contiguous range of segments
  • Use sortSegments with array when you have a specific, non-contiguous set of segment indices to sort

Conditional Sort Functions

These functions add a segment-level condition, sorting only segments that satisfy the condition:

Function Segments Sorted Description
Segments_sortAllSegmentsIf All segments matching condition Sorts all segments that satisfy the segment condition
Segments_sortSegmentsIf_range Segments [begin, end) matching condition Sorts segments in range that satisfy the segment condition

When to use:

  • Use these variants when you want to skip sorting certain segments based on segment-level properties

Low-Level Functions

The function Segments_segmentInsertionSort sorts a single segment view using insertion sort.

When to use:

  • Use this when you have a SegmentView object and need fine-grained control
  • Useful when implementing custom segment algorithms

The sorting order is determined by the comparison function (see Compare Lambda).

Common Parameters

All sort functions share these common parameters:

  • segments: The segments container to sort
  • fetch: Lambda that retrieves element values for comparison (see Fetch Lambda)
  • compare: Lambda that determines element ordering (see Compare Lambda)
  • swap: Lambda that exchanges two elements (see Swap Lambda)
  • launchConfig: Configuration for parallel execution (optional)

Conditional variants additionally require:

  • condition: Lambda that determines if a segment should be sorted (see Condition Lambda)

Related Pages