Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
live-coding-fr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
twitch
live-coding-fr
Merge requests
!82
Resolve "Fix large grid display"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Fix large grid display"
110-fix-large-grid-display
into
master
Overview
0
Commits
1
Pipelines
0
Changes
3
Merged
Colin DAMON
requested to merge
110-fix-large-grid-display
into
master
3 years ago
Overview
0
Commits
1
Pipelines
0
Changes
3
Expand
Closes
#110 (closed)
Edited
3 years ago
by
Colin DAMON
0
0
Merge request reports
Compare
version 1
version 1
81aff3af
3 years ago
master (base)
and
latest version
latest version
157084ce
1 commit,
3 years ago
version 1
81aff3af
1 commit,
3 years ago
Show latest version
3 files
+
24
−
55
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
game-of-life/src/main/java/fr/ippon/life/Grid.java
+
13
−
28
Options
@@ -19,11 +19,12 @@ public class Grid {
}
private
Set
<
Cell
>
buildDeadCells
(
Set
<
Cell
>
aliveCells
)
{
return
aliveCells
.
stream
()
.
map
(
Box:
:
new
)
.
flatMap
(
Box:
:
cells
)
.
filter
(
cell
->
!
aliveCells
.
contains
(
cell
))
.
collect
(
Collectors
.
toUnmodifiableSet
());
return
aliveCells
.
stream
()
.
map
(
Box:
:
new
)
.
flatMap
(
Box:
:
cells
)
.
filter
(
cell
->
!
aliveCells
.
contains
(
cell
))
.
collect
(
Collectors
.
toUnmodifiableSet
());
}
public
boolean
isAlive
(
Cell
cell
)
{
@@ -65,15 +66,11 @@ public class Grid {
}
private
Stream
<
Cell
>
cells
()
{
return
IntStream
.
range
(
leftColumn
(),
rightColumn
())
.
mapToObj
(
Integer:
:
valueOf
)
.
flatMap
(
column
->
cellsColumn
(
column
));
return
IntStream
.
range
(
leftColumn
(),
rightColumn
()).
mapToObj
(
Integer:
:
valueOf
).
flatMap
(
column
->
cellsColumn
(
column
));
}
private
Stream
<
Cell
>
cellsColumn
(
Integer
column
)
{
return
IntStream
.
range
(
topRow
(),
bottomRow
())
.
mapToObj
(
Integer:
:
valueOf
)
.
map
(
row
->
new
Cell
(
row
,
column
));
return
IntStream
.
range
(
topRow
(),
bottomRow
()).
mapToObj
(
Integer:
:
valueOf
).
map
(
row
->
new
Cell
(
row
,
column
));
}
public
int
topRow
()
{
@@ -104,29 +101,17 @@ public class Grid {
}
private
static
Point
topLeft
(
Set
<
Cell
>
cells
)
{
int
row
=
cells
.
stream
()
.
mapToInt
(
Cell:
:
row
)
.
min
()
.
orElse
(
0
);
int
row
=
cells
.
stream
().
mapToInt
(
Cell:
:
row
).
min
().
orElse
(
0
);
int
column
=
cells
.
stream
()
.
mapToInt
(
Cell:
:
column
)
.
min
()
.
orElse
(
0
);
int
column
=
cells
.
stream
().
mapToInt
(
Cell:
:
column
).
min
().
orElse
(
0
);
return
new
Point
(
row
-
1
,
column
-
1
);
}
private
static
Point
bottomRight
(
Set
<
Cell
>
cells
)
{
int
row
=
cells
.
stream
()
.
mapToInt
(
Cell:
:
row
)
.
max
()
.
orElse
(
0
);
int
column
=
cells
.
stream
()
.
mapToInt
(
Cell:
:
column
)
.
max
()
.
orElse
(
0
);
int
row
=
cells
.
stream
().
mapToInt
(
Cell:
:
row
).
max
().
orElse
(
0
);
int
column
=
cells
.
stream
().
mapToInt
(
Cell:
:
column
).
max
().
orElse
(
0
);
return
new
Point
(
row
+
1
,
column
+
1
);
}
Loading