Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sort-template
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FOURNEL Alexandre
sort-template
Compare revisions
main to 70c22aa69e00d7fc6be514c71e543aa631c7c8ce
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
f20021643/sort-template
Select target project
No results found
70c22aa69e00d7fc6be514c71e543aa631c7c8ce
Select Git revision
Branches
main
1 result
Swap
Target
gnaves/sort-template
Select target project
gnaves/sort-template
g21232913/sort-tp-6
t19015527/tp-6
f20021643/sort-template
a22027291/sort-salim
s19033421/sort-template
b21232450/sort-template
7 results
main
Select Git revision
Branches
main
1 result
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
question 2
· 3a1535ed
FOURNEL Alexandre
authored
2 years ago
3a1535ed
question 2.5
· 70c22aa6
FOURNEL Alexandre
authored
2 years ago
70c22aa6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/fr/univamu/sorting/SortableIntList.java
+36
-0
36 additions, 0 deletions
src/main/java/fr/univamu/sorting/SortableIntList.java
src/test/java/fr/univamu/sorting/ListSortTest.java
+20
-1
20 additions, 1 deletion
src/test/java/fr/univamu/sorting/ListSortTest.java
with
56 additions
and
1 deletion
src/main/java/fr/univamu/sorting/SortableIntList.java
0 → 100644
View file @
70c22aa6
package
fr.univamu.sorting
;
import
java.util.*
;
public
class
SortableIntList
{
public
ArrayList
<
Integer
>
IntList
;
public
void
swap
(
int
index1
,
int
index2
)
{
int
value1
=
IntList
.
get
(
index1
);
int
value2
=
IntList
.
get
(
index2
);
IntList
.
set
(
index1
,
value1
);
IntList
.
set
(
index2
,
value2
);
}
public
int
compare
(
int
index1
,
int
index2
)
{
return
IntList
.
get
(
index1
).
compareTo
(
IntList
.
get
(
index2
));
}
public
int
size
()
{
return
IntList
.
size
();
}
public
int
get
(
int
index
)
{
return
IntList
.
get
(
index
);
}
public
void
sort
()
{
for
(
int
i
=
0
;
i
<
IntList
.
size
()
-
1
;
i
++)
{
for
(
int
j
=
i
+
1
;
j
<
IntList
.
size
();
j
++)
{
if
(
compare
(
IntList
.
get
(
j
),
IntList
.
get
(
i
))
<
0
)
{
swap
(
IntList
.
get
(
i
),
IntList
.
get
(
j
));
}
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/test/java/fr/univamu/sorting/ListSortTest.java
View file @
70c22aa6
...
...
@@ -2,7 +2,7 @@ package fr.univamu.sorting;
import
org.junit.jupiter.api.Test
;
import
java.util.
List
;
import
java.util.
*
;
import
static
fr
.
univamu
.
sorting
.
IntLists
.*;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
...
@@ -12,6 +12,25 @@ class ListSortTest {
@Test
void
testSort
()
{
ArrayList
<
Integer
>
TestList
=
new
ArrayList
<
Integer
>(
8
);
TestList
.
add
(
1
);
TestList
.
add
(
8
);
TestList
.
add
(
9
);
TestList
.
add
(
5
);
TestList
.
add
(
4
);
TestList
.
add
(
3
);
TestList
.
add
(
2
);
TestList
.
add
(
4
);
ArrayList
<
Integer
>
TestList2
=
new
ArrayList
<
Integer
>(
8
);
TestList
.
add
(
1
);
TestList
.
add
(
2
);
TestList
.
add
(
3
);
TestList
.
add
(
4
);
TestList
.
add
(
4
);
TestList
.
add
(
5
);
TestList
.
add
(
8
);
TestList
.
add
(
9
);
assertThat
(
TestList
.
sort
()).
isEqualTo
(
TestList2
);
}
...
...
This diff is collapsed.
Click to expand it.