From 6e0532af78294c76d0e0a187a40d330518bab0a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Mon, 10 Jul 2017 17:08:58 +0200 Subject: array: add helper functions for LIFO usage --- array.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'array.h') diff --git a/array.h b/array.h index 80b3619..d55af28 100644 --- a/array.h +++ b/array.h @@ -108,5 +108,26 @@ bool array_resize(Array*, size_t length); * Sort array, the comparision function works as for `qsort(3)`. */ void array_sort(Array*, int (*compar)(const void*, const void*)); +/** + * Push item onto the top of the stack. + * @rst + * .. note:: Is equivalent to ``array_add(arr, item)``. + * @endrst + */ +bool array_push(Array*, void *item); +/** + * Get and remove item at the top of the stack. + * @rst + * .. warning:: The same ownership rules as for ``array_get`` apply. + * @endrst + */ +void *array_pop(Array*); +/** + * Get item at the top of the stack without removing it. + * @rst + * .. warning:: The same ownership rules as for ``array_get`` apply. + * @endrst + */ +void *array_peek(Array*); #endif -- cgit v1.2.3