Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CellulutLO21
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
Container 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
LO21_Pin_Noir_Boucher_Bouri_Detree
CellulutLO21
Commits
867ab833
Commit
867ab833
authored
3 years ago
by
Yann Boucher
Browse files
Options
Downloads
Patches
Plain Diff
Implémentation de la fonction retournant une structure à partir d'un Grid : Fixed
#36
parent
270164c5
No related branches found
No related tags found
No related merge requests found
Pipeline
#77933
passed
3 years ago
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/grid.h
+5
-0
5 additions, 0 deletions
include/grid.h
src/grid.cpp
+13
-0
13 additions, 0 deletions
src/grid.cpp
with
18 additions
and
0 deletions
include/grid.h
+
5
−
0
View file @
867ab833
...
@@ -21,6 +21,8 @@ using namespace std;
...
@@ -21,6 +21,8 @@ using namespace std;
// TODO : documenter
// TODO : documenter
class
Structure
;
class
Grid
{
class
Grid
{
int
nb_rows
;
int
nb_rows
;
int
nb_col
;
int
nb_col
;
...
@@ -43,6 +45,9 @@ public:
...
@@ -43,6 +45,9 @@ public:
+
((
j
%
nb_col
+
nb_col
)
%
nb_col
)];
+
((
j
%
nb_col
+
nb_col
)
%
nb_col
)];
}
}
Grid
&
operator
=
(
const
Grid
&
g
);
Grid
&
operator
=
(
const
Grid
&
g
);
//! \brief Retourne une structure représentant le contenu non-nul de la Grid (les cellules d'état != 0), pour un enregistrement dans un fichier par exemple.
Structure
to_structure
()
const
;
};
};
ostream
&
operator
<<
(
ostream
&
f
,
const
Grid
&
g
);
ostream
&
operator
<<
(
ostream
&
f
,
const
Grid
&
g
);
...
...
This diff is collapsed.
Click to expand it.
src/grid.cpp
+
13
−
0
View file @
867ab833
...
@@ -11,6 +11,8 @@ Cette classe représente un réseau de cellules.
...
@@ -11,6 +11,8 @@ Cette classe représente un réseau de cellules.
#include
"grid.h"
#include
"grid.h"
#include
"structure.hpp"
Grid
::
Grid
(
size_t
l
,
size_t
c
)
:
nb_rows
(
l
),
nb_col
(
c
){
Grid
::
Grid
(
size_t
l
,
size_t
c
)
:
nb_rows
(
l
),
nb_col
(
c
){
this
->
matrix
.
resize
(
l
*
c
);
this
->
matrix
.
resize
(
l
*
c
);
}
}
...
@@ -41,3 +43,14 @@ Grid& Grid::operator=(const Grid& g){
...
@@ -41,3 +43,14 @@ Grid& Grid::operator=(const Grid& g){
this
->
matrix
=
g
.
matrix
;
this
->
matrix
=
g
.
matrix
;
return
*
this
;
return
*
this
;
}
}
Structure
Grid
::
to_structure
()
const
{
std
::
vector
<
std
::
pair
<
Coord
,
unsigned
>>
data
;
for
(
size_t
i
=
0
;
i
<
get_rows
();
++
i
)
for
(
size_t
j
=
0
;
j
<
get_col
();
++
j
)
data
.
push_back
(
std
::
make_pair
(
Coord
{(
int
)
j
,
(
int
)
i
},
get_state
(
i
,
j
)));
return
Structure
{
data
.
begin
(),
data
.
end
()};
}
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