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
dd46ba20
Commit
dd46ba20
authored
Aug 07, 2018
by
Tiago Peixoto
Browse files
idx_map.hh: Fix random access
parent
7041c30f
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/graph/idx_map.hh
View file @
dd46ba20
...
...
@@ -72,7 +72,10 @@ public:
T
&
operator
[](
const
Key
&
key
)
{
return
insert
(
std
::
make_pair
(
key
,
T
())).
first
->
second
;
auto
iter
=
find
(
key
);
if
(
iter
==
end
())
iter
=
insert
(
std
::
make_pair
(
key
,
T
())).
first
;
return
iter
->
second
;
}
iterator
find
(
const
Key
&
key
)
...
...
@@ -115,6 +118,9 @@ public:
const_iterator
begin
()
const
{
return
_items
.
begin
();
}
const_iterator
end
()
const
{
return
_items
.
end
();
}
size_t
size
()
{
return
_items
.
size
();
}
bool
empty
()
{
return
_items
.
empty
();
}
private:
std
::
vector
<
std
::
pair
<
Key
,
T
>>
_items
;
std
::
vector
<
size_t
>
_pos
;
...
...
@@ -209,6 +215,9 @@ public:
const_iterator
begin
()
const
{
return
_items
.
begin
();
}
const_iterator
end
()
const
{
return
_items
.
end
();
}
size_t
size
()
{
return
_items
.
size
();
}
bool
empty
()
{
return
_items
.
empty
();
}
private:
std
::
vector
<
Key
>
_items
;
std
::
vector
<
size_t
>
_pos
;
...
...
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