Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Network
libktorrent
Commits
82ab01a7
Commit
82ab01a7
authored
May 17, 2021
by
Ömer Fadıl Usta
😊
Browse files
update random_shuffle for equivalent of cpp17
parent
97bbfdc8
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/download/chunkselector.cpp
View file @
82ab01a7
...
...
@@ -83,12 +83,15 @@ void ChunkSelector::init(ChunkManager *cman, Downloader *downer, PeerManager *pm
{
bt
::
ChunkSelectorInterface
::
init
(
cman
,
downer
,
pman
);
std
::
vector
<
Uint32
>
tmp
;
std
::
random_device
rd
;
std
::
mt19937
g
(
rd
());
for
(
Uint32
i
=
0
;
i
<
cman
->
getNumChunks
();
i
++
)
{
if
(
!
cman
->
getBitSet
().
get
(
i
))
{
tmp
.
push_back
(
i
);
}
}
std
::
random_
shuffle
(
tmp
.
begin
(),
tmp
.
end
());
std
::
shuffle
(
tmp
.
begin
(),
tmp
.
end
()
,
g
);
// std::list does not support random_shuffle so we use a vector as a temporary storage
// for the random_shuffle
chunks
.
insert
(
chunks
.
begin
(),
tmp
.
begin
(),
tmp
.
end
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment