std1.0.0-beta-7 SafeC docs

std :: collections::stack

Struct std::Stack

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

generic<T> struct Stack {
    ?&heap T data;
    unsigned long top;
    unsigned long cap;
}

Fields

§?&heap T datasource
§unsigned long topsource

number of elements

§unsigned long capsource

Methods

§static struct Stack<T> new()source · definition

empty, no allocation

§static struct Stack<T> with_cap(unsigned long cap)source · definition

room for cap elements

§int push(T value)source · definition

0 on OOM

§?T pop()source · definition

null if empty

§?&T peek() constsource · definition

null if empty

§unsigned long length() constsource · definition
§int is_empty() constsource · definition
§void clear()source · definition

drop every element, keep the buffer

§int reserve(unsigned long n)source · definition
§void drop()source · definition

drops the elements, frees the buffer (Drop)

§void free() consumesource · definition

= drop()