Cthulhu  0.2.10
Cthulhu compiler collection
vector.c File Reference
#include "std/typed/vector.h"
#include "base/util.h"
#include "core/macros.h"
#include "arena/arena.h"
#include "base/panic.h"
#include <stdlib.h>
Include dependency graph for vector.c:

Go to the source code of this file.

Functions

STA_DECL void typevec_init (typevec_t *vec, size_t width, size_t len, arena_t *arena)
 initialize a typed vector More...
 
STA_DECL typevec_t typevec_make (size_t width, size_t len, arena_t *arena)
 create a new typed vector on the stack More...
 
STA_DECL typevec_ttypevec_new (size_t width, size_t len, arena_t *arena)
 create a new typed vector on the heap More...
 
STA_DECL typevec_ttypevec_of (size_t width, size_t len, arena_t *arena)
 create a new typed vector with an initial size and length More...
 
STA_DECL typevec_ttypevec_of_array (size_t width, const void *src, size_t count, arena_t *arena)
 
STA_DECL typevec_ttypevec_slice (const typevec_t *vec, size_t start, size_t end)
 create a new typevec from an existing typevec More...
 
STA_DECL size_t typevec_len (const typevec_t *vec)
 get the length of a vector More...
 
STA_DECL void typevec_set (typevec_t *vec, size_t index, const void *src)
 set an element in the vector More...
 
STA_DECL void typevec_get (const typevec_t *vec, size_t index, void *dst)
 
STA_DECL void typevec_tail (const typevec_t *vec, void *dst)
 get the last element from the vector More...
 
STA_DECL void * typevec_push (typevec_t *vec, const void *src)
 push a value onto the vector More...
 
STA_DECL void typevec_append (typevec_t *vec, const void *src, size_t len)
 append multiple values onto the vector More...
 
STA_DECL void typevec_pop (typevec_t *vec, void *dst)
 pop a value from the vector More...
 
STA_DECL void * typevec_offset (const typevec_t *vec, size_t index)
 get a pointer to the value at the given index More...
 
STA_DECL void * typevec_data (const typevec_t *vec)
 get a pointer to the underlying data More...
 
void typevec_sort (typevec_t *vec, int(*cmp)(const void *, const void *))
 sort a vector More...
 
STA_DECL void typevec_reset (typevec_t *vec)
 reset a vector More...
 

Variables

const typevec_t kEmptyTypevec = { 0 }
 

Function Documentation

◆ typevec_get()

STA_DECL void typevec_get ( const typevec_t vec,
size_t  index,
void *  dst 
)

Definition at line 138 of file vector.c.

◆ typevec_of_array()

STA_DECL typevec_t* typevec_of_array ( size_t  width,
const void *  src,
size_t  count,
arena_t arena 
)

Definition at line 91 of file vector.c.