package core:slice
Index
Types (3)
Constants (0)
This section is empty.
Variables (0)
This section is empty.
Procedures (86)
- all_of
- all_of_proc
- any_of
- any_of_proc
- as_ptr
- binary_search
- bytes_from_ptr
- clone
- clone_to_dynamic
- cmp
- cmp_proc
- concatenate
- contains
- count
- count_proc
- dot_product
- enumerated_array
- equal
- fill
- filter
- first
- first_ptr
- from_ptr
- get
- get_ptr
- has_prefix
- has_suffix
- into_dynamic
- is_empty
- is_sorted
- is_sorted_by
- is_sorted_by_cmp
- is_sorted_by_key
- is_sorted_cmp
- last
- last_ptr
- length
- linear_search
- linear_search_proc
- map_entries
- map_entry_infos
- map_keys
- map_values
- mapper
- max
- min
- min_max
- none_of
- none_of_proc
- prefix_length
- ptr_add
- ptr_rotate
- ptr_sub
- ptr_swap_non_overlapping
- ptr_swap_overlapping
- reduce
- reinterpret
- reverse
- reverse_sort
- reverse_sort_by
- reverse_sort_by_cmp
- reverse_sort_by_key
- rotate_left
- rotate_right
- scanner
- simple_equal
- sort
- sort_by
- sort_by_cmp
- sort_by_indices_allocate
- sort_by_indices_overwrite
- sort_by_key
- sort_by_with_indices
- sort_with_indices
- split_at
- split_first
- split_last
- stable_sort
- stable_sort_by
- stable_sort_by_cmp
- swap
- swap_between
- swap_with_slice
- to_bytes
- to_dynamic
- zero
Procedure Groups (1)
Types
Map_Entry ¶
Map_Entry :: struct($Key: typeid, $Value: typeid) where intrinsics.type_is_valid_map_key(Key) {}
Map_Entry_Info ¶
Map_Entry_Info :: struct($Key: typeid, $Value: typeid) where intrinsics.type_is_valid_map_key(Key) {}
Ordering ¶
Ordering :: enum int { Less = -1, Equal = 0, Greater = 1, }
Related Procedures With Returns
Constants
This section is empty.
Variables
This section is empty.
Procedures
bytes_from_ptr ¶
Turn a pointer and a length into a byte slice.
clone ¶
clone :: proc(a: $T/[]$T, allocator := context.allocator) -> ([]$T, runtime.Allocator_Error) #optional_ok {…}
copies a slice into a new slice
clone_to_dynamic ¶
clone_to_dynamic :: proc(a: $T/[]$T, allocator := context.allocator) -> ([dynamic]$T, runtime.Allocator_Error) #optional_ok {…}
copies slice into a new dynamic array
concatenate ¶
concatenate :: proc(a: []$T/[]$T, allocator := context.allocator) -> (res: $T/[]$T, err: runtime.Allocator_Error) #optional_ok {…}
contains ¶
contains :: proc(array: $T/[]$T, value: $T) -> bool {…}
dot_product ¶
dot_product :: proc(a, b: $T/[]$T) -> (r: $T, ok: bool) {…}
enumerated_array ¶
enumerated_array :: proc(ptr: ^$T) -> []$T {…}
Convert a pointer to an enumerated array to a slice of the element type
filter ¶
filter :: proc(s: $T/[]$T, f: proc(_: $T) -> bool, allocator := context.allocator) -> $T/[]$T {…}
first_ptr ¶
first_ptr :: proc(array: $T/[]$T) -> ^$T {…}
from_ptr ¶
from_ptr :: proc "contextless" (ptr: ^$T, count: int) -> []$T {…}
Turn a pointer and a length into a slice.
has_prefix ¶
has_prefix :: proc(array: $T/[]$T, needle: $T) -> bool {…}
has_suffix ¶
has_suffix :: proc(array: $T/[]$T, needle: $T) -> bool {…}
into_dynamic ¶
into_dynamic :: proc(a: $T/[]$T) -> [dynamic]$T {…}
Converts slice into a dynamic array without cloning or allocating memory
is_empty ¶
is_empty :: proc(a: $T/[]$T) -> bool {…}
is_sorted ¶
is_sorted :: proc(array: $T/[]$T) -> bool {…}
is_sorted_by_cmp ¶
is_sorted_by_cmp :: is_sorted_cmp
is_sorted_by_key ¶
is_sorted_by_key :: proc(array: $T/[]$T, key: proc(_: $T) -> $T) -> bool {…}
last_ptr ¶
last_ptr :: proc(array: $T/[]$T) -> ^$T {…}
map_entries ¶
map_entries :: proc(m: $T/map[$T]$T, allocator := context.allocator) -> (entries: []Map_Entry($Key, $Value), err: runtime.Allocator_Error) {…}
map_entry_infos ¶
map_entry_infos :: proc(m: $T/map[$T]$T, allocator := context.allocator) -> (entries: []Map_Entry_Info($Key, $Value)) {…}
map_keys ¶
map_keys :: proc(m: $T/map[$T]$T, allocator := context.allocator) -> (keys: []$T, err: runtime.Allocator_Error) {…}
map_values ¶
map_values :: proc(m: $T/map[$T]$T, allocator := context.allocator) -> (values: []$T, err: runtime.Allocator_Error) {…}
mapper ¶
mapper :: proc(s: $T/[]$T, f: proc(_: $T) -> $T, allocator := context.allocator) -> (r: []$T, err: runtime.Allocator_Error) #optional_ok {…}
prefix_length ¶
prefix_length :: proc(a, b: $T/[]$T) -> (n: int) {…}
return the prefix length common between slices a
and b
.
slice.prefix_length([]u8{1, 2, 3, 4}, []u8{1}) -> 1 slice.prefix_length([]u8{1, 2, 3, 4}, []u8{1, 2, 3}) -> 3 slice.prefix_length([]u8{1, 2, 3, 4}, []u8{2, 3, 4}) -> 0
reinterpret ¶
reinterpret :: proc "contextless" ($T: typeid/[]T, s: []T) -> []T {…}
Turn a slice of one type, into a slice of another type.
Only converts the type and length of the slice itself. The length is rounded down to the nearest whole number of items. ``` large_items := []i64{1, 2, 3, 4} small_items := slice.reinterpret([]i32, large_items) assert(len(small_items) == 8) ``` ``` small_items := []byte{1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0} large_items := slice.reinterpret([]i64, small_items) assert(len(large_items) == 1) // only enough bytes to make 1 x i64; two would need at least 8 bytes. ```
reverse_sort ¶
reverse_sort :: proc(data: $T/[]$T) {…}
reverse_sort_by ¶
reverse_sort_by :: proc(data: $T/[]$T, less: proc(i, j: $T) -> bool) {…}
reverse_sort_by_cmp ¶
reverse_sort_by_cmp :: proc(data: $T/[]$T, cmp: proc(i, j: $T) -> Ordering) {…}
reverse_sort_by_key ¶
reverse_sort_by_key :: proc(data: $T/[]$T, key: proc(_: $T) -> $T) {…}
rotate_left ¶
rotate_left :: proc(array: $T/[]$T, mid: int) {…}
rotate_right ¶
rotate_right :: proc(array: $T/[]$T, k: int) {…}
scanner ¶
scanner :: proc(s: $T/[]$T, initializer: $T, f: proc(_: $T, _: $T) -> $T, allocator := context.allocator) -> (res: []$T, err: runtime.Allocator_Error) #optional_ok {…}
simple_equal ¶
simple_equal :: proc(a, b: $T/[]$T) -> bool {…}
sort_by ¶
sort_by :: proc(data: $T/[]$T, less: proc(i, j: $T) -> bool) {…}
sort_by sorts a slice with a given procedure to test whether two values are ordered "i < j" This sort is not guaranteed to be stable
sort_by_cmp ¶
sort_by_cmp :: proc(data: $T/[]$T, cmp: proc(i, j: $T) -> Ordering) {…}
sort_by_indices_allocate ¶
sort_by_indices_allocate :: proc(data: $T/[]$T, indices: []int, allocator := context.allocator) -> (sorted: $T/[]$T) {…}
sort_by_indices_overwrite ¶
sort_by_indices_overwrite :: proc(data: $T/[]$T, indices: []int) {…}
sort_by_key ¶
sort_by_key :: proc(data: $T/[]$T, key: proc(_: $T) -> $T) {…}
TODO(bill): Should sort_by_key
exist or is sort_by
more than enough?
sort_by_with_indices ¶
sort_by_with_indices :: proc(data: $T/[]$T, less: proc(i, j: $T) -> bool, allocator := context.allocator) -> (indices: []int) {…}
sort_by sorts a slice with a given procedure to test whether two values are ordered "i < j" This sort is not guaranteed to be stable
sort_with_indices ¶
sort_with_indices :: proc(data: $T/[]$T, allocator := context.allocator) -> (indices: []int) {…}
sort sorts a slice and returns a slice of the original indices This sort is not guaranteed to be stable
split_at ¶
split_at :: proc(array: $T/[]$T, index: int) -> (a, b: $T/[]$T) {…}
split_first ¶
split_first :: proc(array: $T/[]$T) -> (first: $T, rest: $T/[]$T) {…}
split_last ¶
split_last :: proc(array: $T/[]$T) -> (rest: $T/[]$T, last: $T) {…}
stable_sort_by ¶
stable_sort_by :: proc(data: $T/[]$T, less: proc(i, j: $T) -> bool) {…}
stable_sort_by sorts a slice with a given procedure to test whether two values are ordered "i < j"
stable_sort_by_cmp ¶
stable_sort_by_cmp :: proc(data: $T/[]$T, cmp: proc(i, j: $T) -> Ordering) {…}
swap_between ¶
swap_between :: proc(a, b: $T/[]$T) {…}
swap_with_slice ¶
swap_with_slice :: proc(a, b: $T/[]$T, loc := #caller_location) {…}
to_bytes ¶
to_bytes :: proc "contextless" (s: []$T) -> []u8 {…}
Turn a slice into a byte slice.
See `slice.reinterpret` to go the other way.
Procedure Groups
sort_by_indices ¶
sort_by_indices :: proc{ sort_by_indices_allocate, _sort_by_indices, }
Source Files
Generation Information
Generated with odin version dev-2023-10 (vendor "odin") Windows_amd64 @ 2023-10-03 21:09:46.887800800 +0000 UTC