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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.