@vec
Dynamic heap allocated array module.
struct RawVec
ptr: *void,
len: usize,
element_size: usize,
capacity: usize,
__iterator_ptr: usize,Methods:
fn new(element_size: usize) RawVec
Creates new empty dynamic vector instance.
PANIC: Heap allocation returned NULL pointer
fn from_raw_parts(ptr: *void, len: usize, element_size: usize, capacity: usize) RawVec
Creates new dynamic vector instance from provided raw parts.
clone(&self) RawVec
Clones dynamic vector with data inside.
PANIC: Heap allocation returned NULL pointer
fn len(&self) usize
Returns dynamic vector length.
fn is_empty(&self) bool
Returns true if vector is empty.
fn capacity(&self) usize
Returns dynamic vector's capacity (capacity is element size * allocated slots).
fn element_size(&self) usize
Returns element size in bytes.
push(&self, element_ptr: *void)
Pushes new element from provided pointer (takeselement_sizebytes).
PANIC:
- Attempt to push dropped vector
- Attempt to push NULL value to vector
- Heap reallocation returned NULL pointer
fn set(&self, index: usize, value_ptr: *void)
Replaces element by provided index with element from value pointer.
PANIC:
- Attempt to edit dropped vector
- Index is out of len range
fn pop(&self) *void
Deletes last element from vector and returns pointer to it. If vector is empty returns NULL pointer.
PANIC:
- Attempt to pop dropped vector
fn get(&self, index: usize) *void
Returns pointer to element by provided index.
PANIC:
- Attempt to get dropped vector
- Index is out of len range
fn remove(&self, index: usize)
Removes element from vector by provided index. PANIC:
- Attempt to edit dropped vector
- Index is out of len range
fn clear(&self)
Clears dynamic vector (without reallocation).
fn as_ptr(&self) *void
Returns pointer to the first vector element.
Compiler Implementations:
fn drop(&self)fn iterate(&self) (*void, bool)fn slice(&self, index: usize) *voidfn slice_assign(&self, index: usize, value: *void)
For more information see Structures Implementations