Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
Vector 2023
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VIOLA Anthony
Vector 2023
Commits
b81956de
Commit
b81956de
authored
Sep 21, 2023
by
VIOLA Anthony
Browse files
Options
Downloads
Patches
Plain Diff
TP1
parent
85a9a3ec
No related branches found
No related tags found
No related merge requests found
Pipeline
#17399
passed
Sep 21, 2023
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/Stack.java
+51
-0
51 additions, 0 deletions
src/main/java/Stack.java
src/main/java/Vector.java
+1
-1
1 addition, 1 deletion
src/main/java/Vector.java
with
52 additions
and
1 deletion
src/main/java/Stack.java
0 → 100644
+
51
−
0
View file @
b81956de
/**
* Pile d'entiers
*/
public
class
Stack
{
/**
* Vecteur d'entiers.
*/
private
Vector
vector
;
/**
* Construit une pile d'entiers avec un vecteur vector.
*
* @param vector Vecteur initial
*/
public
Stack
(
Vector
vector
)
{
this
.
vector
=
vector
;
}
/**
* Empile la valeur de l'entier value dans le vecteur.
*
* @param value entier à empiler dans le le vecteur
*/
public
void
push
(
int
value
)
{
vector
.
add
(
value
);
}
/**
* Retourne l'entier en haut de la pile sans le dépiler
*
* @return l'entier en fin du vecteur
*/
public
int
peek
()
{
return
vector
.
get
(
vector
.
size
());}
/**
* Retourne l'entier en haut de la pile et le dépile
*
* @return
*/
public
int
pop
()
{
int
number
=
peek
();
vector
.
set
(
vector
.
size
(),
0
);
return
number
;
}
public
int
size
()
{
return
vector
.
size
();}
public
boolean
isEmpty
()
{
return
vector
.
isEmpty
();}
}
This diff is collapsed.
Click to expand it.
src/main/java/Vector.java
+
1
−
1
View file @
b81956de
...
@@ -110,7 +110,7 @@ public class Vector {
...
@@ -110,7 +110,7 @@ public class Vector {
*/
*/
public
int
get
(
int
index
)
{
public
int
get
(
int
index
)
{
if
(
capacity
()>=
index
+
1
){
if
(
capacity
()>=
index
+
1
){
return
elements
[
index
];
return
this
.
elements
[
index
];
}
}
return
0
;
return
0
;
}
}
...
...
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