Module slice

Source

Structs§

NSTDSlice
Represents a view into a sequence of data.

Functions§

nstd_core_slice_compare
Checks if two slices carry the same data. Parameters: const NSTDSlice *const s1 - The first slice. const NSTDSlice *const s2 - The second slice. Returns: NSTDBool is_same - True if the two slices carry the same data.
nstd_core_slice_contains
Checks if a slice contains element. Parameters: const NSTDSlice *const slice - The slice. NSTDAnyConst element - The element to search for. Returns: NSTDBool is_in - True if the slice contains element.
nstd_core_slice_copy_from_slice
Copies elements from s2 to s1. The slices must be the same size in bytes. Parameters: NSTDSlice *const s1 - The slice to copy to. const NSTDSlice *const s2 - The slice to copy from.
nstd_core_slice_count
Counts the number of elements found in slice. Parameters: const NSTDSlice *const slice - The slice. NSTDAnyConst element - The element to count. Returns: NSTDUSize count - The number of elements in slice.
nstd_core_slice_ends_with
Checks if a slice ends with another slice. Parameters: const NSTDSlice *const slice - The slice. const NSTDSlice *const pattern - The slice pattern. Returns: NSTDBool ends_with - True if slice ends with pattern.
nstd_core_slice_fill
Fills a slice with element. Parameters: NSTDSlice *const slice - The slice. NSTDAnyConst element - The element.
nstd_core_slice_fill_range
Fills a specific range of a slice with element. NOTE: This function does NOT check that range is valid for operating on slice. Parameters: NSTDSlice *const slice - The slice. NSTDAnyConst element - The element. const NSTDURange *const range - The range of the slice to fill.
nstd_core_slice_find_first
Finds the first element in slice and returns the index of the element. Parameters: const NSTDSlice *const slice - The slice. NSTDAnyConst element - The element to search for. Returns: NSTDUSize index - The index of the element, -1/usize::MAX if not found.
nstd_core_slice_find_last
Finds the last element in slice and returns the index of the element. Parameters: const NSTDSlice *const slice - The slice. NSTDAnyConst element - The element to search for. Returns: NSTDUSize index - The index of the element, -1/usize::MAX if not found.
nstd_core_slice_first
Gets the first element in the slice. NOTE: This function follows the same behaviour rules as nstd_core_slice_get. Parameters: const NSTDSlice *const slice - The slice. Returns: NSTDAny element - Pointer to the first element.
nstd_core_slice_get
Gets a pointer to an element from a slice. NOTE: The returned element pointer can quickly become a dangling pointer if the slice’s memory gets reallocated or deallocated, so it is advised to create a copy of the element after getting it. Parameters: const NSTDSlice *const slice - The slice. const NSTDUSize pos - The position of the element to get. Returns: NSTDAny element - Pointer to the element.
nstd_core_slice_last
Gets the last element in the slice. NOTE: This function follows the same behaviour rules as nstd_core_slice_get. Parameters: const NSTDSlice *const slice - The slice. Returns: NSTDAny element - Pointer to the last element.
nstd_core_slice_move
Moves bytes from s2 to s1, sets all s2 bytes to 0. Parameters: NSTDSlice *const s1 - The first slice. NSTDSlice *const s2 - The second slice.
nstd_core_slice_new
Creates a new slice from raw data. Parameters: const NSTDUSize size - Number of elements to slice. const NSTDUSize element_size - Size of each element. NSTDAny data - Pointer to the raw data. Returns: NSTDSlice slice - The new slice.
nstd_core_slice_reverse
Reverses a slice’s elements. Parameters: NSTDSlice *const slice - The slice.
nstd_core_slice_shift_left
Shifts a slice x times to the left. Parameters: NSTDSlice *const slice - The slice. const NSTDUSize x - Number of times to shift the slice.
nstd_core_slice_shift_right
Shifts a slice x times to the right. Parameters: NSTDSlice *const slice - The slice. const NSTDUSize x - Number of times to shift the slice.
nstd_core_slice_starts_with
Checks if a slice starts with another slice. Parameters: const NSTDSlice *const slice - The slice. const NSTDSlice *const pattern - The slice pattern. Returns: NSTDBool starts_with - True if slice starts with pattern.
nstd_core_slice_swap
Swaps two elements in a slice. Parameters: NSTDSlice *const slice - The slice. const NSTDUSize i - The index of the first element. const NSTDUSize j - The index of the second element.
nstd_core_slice_swap_with_slice
Swaps the elements of s1 and s2. The slices must be the same size in bytes. Parameters: NSTDSlice *const s1 - The first slice. NSTDSlice *const s2 - The second slice.