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
c4e5b4ad
Commit
c4e5b4ad
authored
3 years ago
by
orestis.malaspin
Browse files
Options
Downloads
Plain Diff
Merge branch '6-add-pop-function' into 'main'
Resolve "Add pop function" Closes
#6
See merge request
!16
parents
e4bcf652
d93508e5
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!16
Resolve "Add pop function"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+2
-0
2 additions, 0 deletions
.gitignore
stack.c
+13
-1
13 additions, 1 deletion
stack.c
stack.h
+1
-0
1 addition, 0 deletions
stack.h
with
16 additions
and
1 deletion
.gitignore
0 → 100644
+
2
−
0
View file @
c4e5b4ad
*.o
main
\ No newline at end of file
This diff is collapsed.
Click to expand it.
stack.c
+
13
−
1
View file @
c4e5b4ad
...
...
@@ -18,6 +18,19 @@ void stack_destroy(stack *s){
s
->
top
=
-
1
;
}
void
stack_pop
(
stack
*
s
,
int
*
value
){
if
(
stack_is_empty
(
*
s
))
{
return
;
}
if
(
s
->
top
==
s
->
capacity
/
4
){
s
->
capacity
/=
2
;
s
->
data
=
realloc
(
s
->
data
,
sizeof
(
int
)
*
s
->
capacity
);
}
*
value
=
s
->
data
[
s
->
top
];
s
->
top
-=
1
;
}
void
stack_peek
(
stack
s
,
int
*
value
){
if
(
!
stack_is_empty
(
s
))
{
*
value
=
s
.
data
[
s
.
top
];
...
...
@@ -51,4 +64,3 @@ int get_length(stack s)
{
return
s
.
top
+
1
;
}
This diff is collapsed.
Click to expand it.
stack.h
+
1
−
0
View file @
c4e5b4ad
...
...
@@ -11,6 +11,7 @@ void stack_init(stack *stack);
void
stack_destroy
(
stack
*
s
);
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
);
...
...
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