Skip to content
Snippets Groups Projects
Commit f39dc138 authored by orestis.malaspin's avatar orestis.malaspin
Browse files

Merge branch '10-add-is-empty-function' into 'main'

Resolve "Add is empty function"

Closes #10

See merge request !19
parents 287ed7af 3126857e
Branches
Tags
1 merge request!19Resolve "Add is empty function"
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include "stack.h"
......@@ -75,3 +78,13 @@ int get_length(stack s) {
return s.top + 1;
}
/**
* @brief Check if a stack is empty
*
* @param s
* @return bool - true if stack is empty, false otherwise
*/
bool stack_is_empty(stack s)
{
return s.top == -1;
}
\ No newline at end of file
#ifndef _STACK_H_
#define _STACK_H_
typedef struct _stack {
int *data;
int capacity;
......@@ -17,6 +16,7 @@ void stack_pop(stack *s, int *value);
void stack_peek(stack s, int *value);
void stack_clone(stack s, stack *clone);
int get_length(stack s);
bool stack_is_empty(stack s);
void stack_print(const stack s);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment