|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
High-level sorting functions for Aleph containers. More...
#include <algorithm>#include <numeric>#include <ranges>#include <stdexcept>#include <utility>#include <ah-errors.H>#include <ahFunctional.H>#include <tpl_sort_utils.H>#include <tpl_dynDlist.H>#include <htlist.H>#include <ah-zip.H>Go to the source code of this file.
Namespaces | |
| namespace | Aleph |
| Main namespace for Aleph-w library functions. | |
Functions | |
| Aleph::List_Sort (DynList) | |
| Aleph::List_Sort (DynDlist) | |
| template<typename T , class Cmp = Aleph::less<T>> | |
| DynArray< T > | Aleph::sort (const DynArray< T > &a, Cmp &&cmp=Cmp()) |
| Returns a sorted copy of a DynArray. | |
| template<typename T , class Cmp = Aleph::less<T>> | |
| DynArray< T > | Aleph::sort (DynArray< T > &&a, Cmp &&cmp=Cmp()) |
| Sorts an rvalue DynArray in place and returns it. | |
| template<typename T , class Cmp = Aleph::less<T>> | |
| Array< T > | Aleph::sort (const Array< T > &a, Cmp &&cmp=Cmp()) |
| Returns a sorted copy of an Array. | |
| template<typename T , class Cmp = Aleph::less<T>> | |
| Array< T > | Aleph::sort (Array< T > &&a, Cmp &&cmp=Cmp()) |
| Sorts an rvalue Array in place and returns it. | |
| template<typename Container , class Cmp = std::less<typename Container::value_type>> | |
| Container | Aleph::stdsort (const Container &c, Cmp cmp=Cmp()) |
| Sorts an STL-compatible container using std::sort. | |
| template<typename T , class Cmp = Aleph::less<T>> | |
| DynArray< T > & | Aleph::in_place_sort (DynArray< T > &c, Cmp cmp=Cmp()) |
| Sorts a DynArray in place. | |
| template<typename T , class Cmp = Aleph::less<T>> | |
| Array< T > & | Aleph::in_place_sort (Array< T > &c, Cmp cmp=Cmp()) |
| Sorts an Array in place. | |
| template<typename T > | |
| Array< size_t > | Aleph::ranks (const Array< T > &array) |
| Computes the rank of each element in an Array. | |
| template<typename T > | |
| DynArray< size_t > | Aleph::ranks (const DynArray< T > &array) |
| Computes the rank of each element in a DynArray. | |
| template<typename T > | |
| DynArray< size_t > | Aleph::ranks (const DynList< T > &l) |
| Computes the rank of each element in a DynList. | |
| template<typename T > | |
| DynArray< size_t > | Aleph::ranks (const DynDlist< T > &l) |
| Computes the rank of each element in a DynDlist. | |
| template<typename T > | |
| auto | Aleph::pair_ranks (const Array< T > &c) |
| Computes (value, rank) pairs for each element in an Array. | |
| template<typename T > | |
| auto | Aleph::pair_ranks (const DynArray< T > &c) |
| Computes (value, rank) pairs for each element in a DynArray. | |
| template<typename T > | |
| auto | Aleph::pair_ranks (const DynList< T > &l) |
| Computes (value, rank) pairs for each element in a DynList. | |
| template<typename T > | |
| auto | Aleph::pair_ranks (const DynDlist< T > &l) |
| Computes (value, rank) pairs for each element in a DynDlist. | |
| template<typename C , typename... Args, typename Cmp = std::less<typename C::value_type>> | |
| void | Aleph::in_place_multisort_arrays (Cmp cmp, C &first, Args &... args) |
| Sorts multiple arrays in place, using the first array as the key. | |
High-level sorting functions for Aleph containers.
This file provides generic sorting functions that work with Aleph containers (DynList, DynDlist, DynArray, Array) using efficient sorting algorithms.
| Container | Algorithm | Stable | Time | Space |
|---|---|---|---|---|
| DynList | Merge sort | Yes | O(n log n) | O(log n) stack |
| DynDlist | Merge sort | Yes | O(n log n) | O(log n) stack |
| DynArray | Quicksort | No | O(n log n) avg | O(log n) stack |
| Array | Quicksort | No | O(n log n) avg | O(log n) stack |
sort() returns a sorted copy (original unchanged)sort(std::move(c)) sorts efficiently by movingin_place_sort() modifies container directlyranks() and pair_ranks() compute element positionsin_place_multisort_arrays() sorts multiple arrays together| Function | Description |
|---|---|
sort(c) | Returns sorted copy of container |
sort(c, cmp) | Sorted copy with custom comparator |
in_place_sort(c) | Sorts container in place |
stdsort(c) | Sorts STL containers using std::sort |
ranks(c) | Returns array of ranks for each element |
pair_ranks(c) | Returns pairs of (value, rank) |
in_place_multisort_arrays(cmp, a, b, ...) | Sorts multiple arrays by first |
Definition in file ahSort.H.