std1.0.0-beta-7 SafeC docs

std :: collections::slice

Struct std::Slice

#include <std/collections/slice.h> source

generic<T> struct Slice {
    ?&T ptr;
    unsigned long len;
}

Fields

§?&T ptrsource

first element; null for an empty slice

§unsigned long lensource

element count

Methods

§static struct Slice<T> from([]T s)source · definition

view of a built-in slice

§static struct Slice<T> of(&T first, unsigned long len)source · definition

view of len elements at first (a 'new T[len]')

§static struct Slice<T> alloc(unsigned long len)source · definition

zeroed heap slice; empty on OOM

§int in_bounds(unsigned long idx) constsource · definition
§?&T get(unsigned long idx) constsource · definition

null if out of range

§&T at(unsigned long idx) constsource · definition

panics if out of range

§int set(unsigned long idx, T val)source · definition

0 if out of range

§struct Slice<T> sub(unsigned long start, unsigned long end) constsource · definition

[start, end); empty if invalid

§unsigned long length() constsource · definition
§int is_empty() constsource · definition
§[]T as_slice() constsource · definition

the same elements as a built-in slice

§void free()source · definition

only for Slice::alloc() slices