Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cppack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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
Container 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
passwords
cppack
Commits
dfc1fc5b
Commit
dfc1fc5b
authored
Feb 5, 2020
by
Mathieu Valois
Browse files
Options
Downloads
Patches
Plain Diff
Fix map collision by using multimap for stats in decreasing order
parent
df80fdf5
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/Utils.h
+3
-3
3 additions, 3 deletions
include/Utils.h
src/core/Statsgen.cpp
+1
-1
1 addition, 1 deletion
src/core/Statsgen.cpp
src/gui/MainWindow.cpp
+4
-4
4 additions, 4 deletions
src/gui/MainWindow.cpp
with
8 additions
and
8 deletions
include/Utils.h
+
3
−
3
View file @
dfc1fc5b
...
...
@@ -37,8 +37,8 @@ using MapIterator = typename std::map<K, V>::const_iterator;
* @return ordered map
*/
template
<
typename
A
>
std
::
map
<
uint64_t
,
A
,
std
::
greater
<
uint64_t
>>
flip_map
(
const
std
::
unordered_map
<
A
,
uint64_t
>
&
src
)
{
std
::
map
<
uint64_t
,
A
,
std
::
greater
<
uint64_t
>>
dst
;
std
::
multi
map
<
uint64_t
,
A
,
std
::
greater
<
uint64_t
>>
flip_map
(
const
std
::
unordered_map
<
A
,
uint64_t
>
&
src
)
{
std
::
multi
map
<
uint64_t
,
A
,
std
::
greater
<
uint64_t
>>
dst
;
for
(
UnorderedMapIterator
<
A
,
uint64_t
>
it
=
src
.
begin
();
it
!=
src
.
end
();
++
it
)
dst
.
insert
(
std
::
make_pair
(
it
->
second
,
it
->
first
));
...
...
@@ -83,7 +83,7 @@ void readResult(const uint64_t & res, const Type& carac, int & count, const uint
template
<
typename
Type
>
void
showMap
(
const
std
::
unordered_map
<
Type
,
uint64_t
>
&
stats
,
const
int
&
top
,
const
uint64_t
&
total_counter
,
const
int
&
hiderare
,
int
&
count
)
{
count
=
0
;
std
::
map
<
uint64_t
,
Type
,
std
::
greater
<
uint64_t
>>
reverse
=
flip_map
<
Type
>
(
stats
);
std
::
multi
map
<
uint64_t
,
Type
,
std
::
greater
<
uint64_t
>>
reverse
=
flip_map
<
Type
>
(
stats
);
std
::
pair
<
uint64_t
,
Type
>
it
;
for
(
std
::
pair
<
uint64_t
,
Type
>
it
:
reverse
)
{
readResult
<
Type
>
(
it
.
first
,
it
.
second
,
count
,
total_counter
,
hiderare
);
...
...
This diff is collapsed.
Click to expand it.
src/core/Statsgen.cpp
+
1
−
1
View file @
dfc1fc5b
...
...
@@ -169,7 +169,7 @@ void Statsgen::print_stats() {
if
(
!
outfile_name
.
empty
()){
locale
::
global
(
locale
(
"C"
));
ofstream
outfile_stream
(
outfile_name
);
map
<
uint64_t
,
string
,
greater
<
uint64_t
>>
reverse
=
flip_map
(
results
.
advancedmasks
);
multi
map
<
uint64_t
,
string
,
greater
<
uint64_t
>>
reverse
=
flip_map
(
results
.
advancedmasks
);
for
(
pair
<
uint64_t
,
string
>
it
:
reverse
){
if
(
it
.
second
==
"othermasks"
)
continue
;
outfile_stream
<<
it
.
second
<<
","
<<
it
.
first
<<
endl
;
...
...
This diff is collapsed.
Click to expand it.
src/gui/MainWindow.cpp
+
4
−
4
View file @
dfc1fc5b
...
...
@@ -162,7 +162,7 @@ double MainWindow::initGraphicalStats(QBarSeries * barLength, QPieSeries * pieCh
percentageSecurity
=
percentage
(
stats
.
getNbSecurePasswords
(),
total
);
/* LENGTH HISTOGRAM */
map
<
uint64_t
,
int
,
greater
<
uint64_t
>>
reverseL
=
flip_map
<
int
>
(
stats
.
getStatsL
ength
()
);
multi
map
<
uint64_t
,
int
,
greater
<
uint64_t
>>
reverseL
=
flip_map
<
int
>
(
results
.
l
ength
);
double
percentageL
;
double
maxPercLength
=
0
;
uint64_t
nbHideL
=
0
;
...
...
@@ -187,7 +187,7 @@ double MainWindow::initGraphicalStats(QBarSeries * barLength, QPieSeries * pieCh
/* CHARSET PIECHART */
map
<
uint64_t
,
string
,
greater
<
uint64_t
>>
reverseC
=
flip_map
(
stats
.
getStatsCha
rsets
()
);
multi
map
<
uint64_t
,
string
,
greater
<
uint64_t
>>
reverseC
=
flip_map
(
results
.
characte
rsets
);
uint64_t
top
=
0
;
uint64_t
nbHideC
=
0
;
pieCharset
->
clear
();
...
...
@@ -203,7 +203,7 @@ double MainWindow::initGraphicalStats(QBarSeries * barLength, QPieSeries * pieCh
pieCharset
->
append
(
"Other charsets"
,
nbHideC
);
/* SIMPLE PIECHART */
map
<
uint64_t
,
string
,
greater
<
uint64_t
>>
reverseS
=
flip_map
(
stats
.
getStatsSimple
()
);
multi
map
<
uint64_t
,
string
,
greater
<
uint64_t
>>
reverseS
=
flip_map
(
results
.
simplemasks
);
uint64_t
top_simple
=
0
;
uint64_t
nbHideS
=
0
;
pieSimple
->
clear
();
...
...
@@ -219,7 +219,7 @@ double MainWindow::initGraphicalStats(QBarSeries * barLength, QPieSeries * pieCh
pieSimple
->
append
(
"Other Masks"
,
nbHideS
);
/* ADVANCED PIECHART */
map
<
uint64_t
,
string
,
greater
<
uint64_t
>>
reverseA
=
flip_map
(
stats
.
getStatsA
dvanced
()
);
multi
map
<
uint64_t
,
string
,
greater
<
uint64_t
>>
reverseA
=
flip_map
(
results
.
a
dvanced
masks
);
uint64_t
top_advanced
=
0
;
uint64_t
nbHideA
=
0
;
pieAdvanced
->
clear
();
...
...
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