Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tiago Peixoto
graph-tool
Commits
72e74070
Commit
72e74070
authored
Dec 19, 2017
by
Tiago Peixoto
Browse files
Cosmetic improvements to Sampler and DynamicSampler
parent
7bb82a5b
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/graph/generation/dynamic_sampler.hh
View file @
72e74070
...
...
@@ -105,8 +105,9 @@ public:
else
{
pos
=
_free
.
back
();
_items
[
_idx
[
pos
]]
=
v
;
_valid
[
_idx
[
pos
]]
=
true
;
auto
i
=
_idx
[
pos
];
_items
[
i
]
=
v
;
_valid
[
i
]
=
true
;
_tree
[
pos
]
=
w
;
_free
.
pop_back
();
}
...
...
@@ -160,7 +161,7 @@ public:
return
_items
[
i
];
}
bool
is_valid
(
size_t
i
)
bool
is_valid
(
size_t
i
)
const
{
return
(
i
<
_items
.
size
()
&&
_valid
[
i
]);
}
...
...
src/graph/generation/sampler.hh
View file @
72e74070
...
...
@@ -134,7 +134,7 @@ private:
// uniform sampling from containers
template
<
class
Iter
,
class
RNG
>
auto
&
uniform_sample
(
Iter
begin
,
const
Iter
&
end
,
RNG
&
rng
)
auto
&
&
uniform_sample
(
Iter
begin
,
const
Iter
&
end
,
RNG
&
rng
)
{
auto
N
=
end
-
begin
;
std
::
uniform_int_distribution
<
size_t
>
i_rand
(
0
,
N
-
1
);
...
...
@@ -143,7 +143,7 @@ auto& uniform_sample(Iter begin, const Iter& end, RNG& rng)
}
template
<
class
Container
,
class
RNG
>
auto
&
uniform_sample
(
Container
&
v
,
RNG
&
rng
)
auto
&
&
uniform_sample
(
Container
&
v
,
RNG
&
rng
)
{
return
uniform_sample
(
v
.
begin
(),
v
.
end
(),
rng
);
}
...
...
Write
Preview
Supports
Markdown
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