Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
stack.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2019-2021 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
10#ifndef __UTILS_STACK_H__
11#define __UTILS_STACK_H__
12
13#include <cstdlib>
14
15#include "utils/yaml.h"
16
17#include "gtk_wrapper.h"
18
25#define STACK_PUSH(s, element) stack_push (s, (void *) element)
26
31typedef struct Stack
32{
33 void ** elements;
34
43
50 gint top;
51} Stack;
52
59Stack *
60stack_new (int length);
61
62int
63stack_size (Stack * s);
64
65int
66stack_is_empty (Stack * s);
67
68int
69stack_is_full (Stack * s);
70
71void *
72stack_peek (Stack * s);
73
74void *
75stack_peek_last (Stack * s);
76
77void
78stack_push (Stack * s, void * element);
79
80void *
81stack_pop (Stack * s);
82
86void *
88
89void
90stack_free_members (Stack * s);
91
92void
93stack_free (Stack * s);
94
99#endif
void * stack_pop_last(Stack *s)
Pops the last element and moves everything back.
Stack * stack_new(int length)
Creates a new stack of the given size.
Stack implementation.
Definition stack.h:32
gint top
Index of the top of the stack.
Definition stack.h:50
int max_length
Max stack size, or -1 for unlimited.
Definition stack.h:42
YAML utils.