Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
stack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
algorithmique
lib_2021_malaspinas
stack
Commits
94a4d62f
Commit
94a4d62f
authored
3 years ago
by
orestis.malaspin
Browse files
Options
Downloads
Plain Diff
Merge branch '7-add-peek-function' into 'main'
Resolve "Add peek function" Closes
#7
See merge request
!5
parents
6aab0548
50386f6c
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!5
Resolve "Add peek function"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
stack.c
+8
-3
8 additions, 3 deletions
stack.c
stack.h
+2
-0
2 additions, 0 deletions
stack.h
with
10 additions
and
3 deletions
stack.c
+
8
−
3
View file @
94a4d62f
#include
"stack.h"
#include
<assert.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
"stack.h"
#define DEFAULT_CAPACITY 4
...
...
@@ -10,4 +9,10 @@ void stack_init(stack *s)
s
->
top
=
-
1
;
s
->
capacity
=
DEFAULT_CAPACITY
;
s
->
data
=
malloc
(
sizeof
(
int
)
*
DEFAULT_CAPACITY
);
}
\ No newline at end of file
}
void
stack_peek
(
stack
s
,
int
*
value
){
if
(
!
stack_is_empty
(
s
))
{
*
value
=
s
.
data
[
s
.
top
];
}
}
This diff is collapsed.
Click to expand it.
stack.h
+
2
−
0
View file @
94a4d62f
...
...
@@ -9,4 +9,6 @@ typedef struct _stack {
void
stack_init
(
stack
*
stack
);
void
stack_peek
(
stack
s
,
int
*
value
);
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment