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 <stdlib.h>
14
15#include "utils/yaml.h"
16
17#include <gtk/gtk.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
53static const cyaml_schema_field_t stack_fields_schema[] = {
54 YAML_FIELD_INT (Stack, max_length),
55
56 CYAML_FIELD_END
57};
58
59static const cyaml_schema_value_t stack_schema = {
60 YAML_VALUE_PTR (Stack, stack_fields_schema),
61};
62
69Stack *
70stack_new (int length);
71
72int
73stack_size (Stack * s);
74
75int
76stack_is_empty (Stack * s);
77
78int
79stack_is_full (Stack * s);
80
81void *
82stack_peek (Stack * s);
83
84void *
85stack_peek_last (Stack * s);
86
87void
88stack_push (Stack * s, void * element);
89
90void *
91stack_pop (Stack * s);
92
96void *
98
99void
100stack_free_members (Stack * s);
101
102void
103stack_free (Stack * s);
104
109#endif
#define YAML_VALUE_PTR(cc, fields_schema)
Schema to be used as a pointer.
Definition yaml.h:202
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.