XU XUv0.8.8
中文

API

#sort

import: #sort

counts: 17 fns, 0 methods, 1 types, 0 consts, 0 ifaces

ints/f64s/strings introsort; slice / slice_func by Ord or callback.

slice

XuAPI
pub fn slice#T:Ord(a &mut []T)

Purpose

In-place sort using Ord.less.

Parameters

a &mut []T
slice to operate on (exclusive borrow; type &mut []T)

ints

XuAPI
pub fn ints(a &mut []int)

Purpose

In-place ascending sort.

Parameters

a &mut []int
slice to operate on (exclusive borrow; type &mut []int)

strings

XuAPI
pub fn strings(a &mut []string)

Purpose

In-place ascending sort.

Parameters

a &mut []string
slice to operate on (exclusive borrow; type &mut []string)

f64s

XuAPI
pub fn f64s(a &mut []f64)

Purpose

In-place ascending sort.

Parameters

a &mut []f64
slice to operate on (exclusive borrow; type &mut []f64)

slice_func

XuAPI
pub fn slice_func#T(a &mut []T, less fn(T, T) bool)

Purpose

Small integer ranges and f64s use introsort. Generic `slice_func` keeps the original

Parameters

a &mut []T
slice to operate on (exclusive borrow; type &mut []T)
less fn(T, T) bool
less callback: true means left < right (function value; type fn(T, T) bool)

lookup_ints

XuAPI
pub fn lookup_ints(a &[]int, v int) Search

Purpose

Lookup int slice.

Parameters

a &[]int
slice to operate on (borrowed; caller keeps it; type &[]int)
v int
value (int)

Returns

Search — a value of this type

lookup_strings

XuAPI
pub fn lookup_strings(a &[]string, v string) Search

Purpose

Lookup string slice.

Parameters

a &[]string
slice to operate on (borrowed; caller keeps it; type &[]string)
v string
value (string)

Returns

Search — a value of this type

lookup_f64s

XuAPI
pub fn lookup_f64s(a &[]f64, v f64) Search

Purpose

Lookup f64 slice.

Parameters

a &[]f64
slice to operate on (borrowed; caller keeps it; type &[]f64)
v f64
value (f64)

Returns

Search — a value of this type

search_ints

XuAPI
pub fn search_ints(a &[]int, v int) int

Purpose

Binary search a sorted slice.

Parameters

a &[]int
slice to operate on (borrowed; caller keeps it; type &[]int)
v int
value (int)

Returns

int — index in the sorted slice (insertion point if missing)

search_strings

XuAPI
pub fn search_strings(a &[]string, v string) int

Purpose

Binary search a sorted slice.

Parameters

a &[]string
slice to operate on (borrowed; caller keeps it; type &[]string)
v string
value (string)

Returns

int — index in the sorted slice (insertion point if missing)

search_f64s

XuAPI
pub fn search_f64s(a &[]f64, v f64) int

Purpose

Binary search a sorted slice.

Parameters

a &[]f64
slice to operate on (borrowed; caller keeps it; type &[]f64)
v f64
value (f64)

Returns

int — index in the sorted slice (insertion point if missing)

is_sorted_ints

XuAPI
pub fn is_sorted_ints(a &[]int) bool

Purpose

Whether the slice is sorted ascending.

Parameters

a &[]int
slice to operate on (borrowed; caller keeps it; type &[]int)

Returns

bool — true or false

is_sorted_strings

XuAPI
pub fn is_sorted_strings(a &[]string) bool

Purpose

Whether the slice is sorted ascending.

Parameters

a &[]string
slice to operate on (borrowed; caller keeps it; type &[]string)

Returns

bool — true or false

is_sorted_f64s

XuAPI
pub fn is_sorted_f64s(a &[]f64) bool

Purpose

Whether the slice is sorted ascending.

Parameters

a &[]f64
slice to operate on (borrowed; caller keeps it; type &[]f64)

Returns

bool — true or false

reverse_ints

XuAPI
pub fn reverse_ints(a &mut []int)

Purpose

In-place descending sort (sort ascending, then reverse).

Parameters

a &mut []int
slice to operate on (exclusive borrow; type &mut []int)

reverse_strings

XuAPI
pub fn reverse_strings(a &mut []string)

Purpose

In-place descending sort (sort ascending, then reverse).

Parameters

a &mut []string
slice to operate on (exclusive borrow; type &mut []string)

reverse_f64s

XuAPI
pub fn reverse_f64s(a &mut []f64)

Purpose

In-place descending sort (sort ascending, then reverse).

Parameters

a &mut []f64
slice to operate on (exclusive borrow; type &mut []f64)