Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mitsuba-shapenet
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
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hardik Jain
mitsuba-shapenet
Commits
461827ec
Commit
461827ec
authored
10 years ago
by
Wenzel Jakob
Browse files
Options
Downloads
Patches
Plain Diff
preserve order in ref_vector::ensureUnique
parent
5a6be59f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/mitsuba/core/ref.h
+15
-3
15 additions, 3 deletions
include/mitsuba/core/ref.h
with
15 additions
and
3 deletions
include/mitsuba/core/ref.h
+
15
−
3
View file @
461827ec
...
...
@@ -21,6 +21,7 @@
#define __MITSUBA_CORE_REF_H_
#include
"util.h"
#include
<set>
MTS_NAMESPACE_BEGIN
...
...
@@ -148,10 +149,21 @@ public:
ref_vector
(
size_t
size
)
:
parent_type
(
size
)
{}
ref_vector
(
const
ref_vector
&
vec
)
:
parent_type
(
vec
)
{}
/// Remove all duplicates
(may
chang
e
the order
)
/// Remove all duplicates
without
chang
ing
the order
inline
void
ensureUnique
()
{
std
::
sort
(
this
->
begin
(),
this
->
end
(),
ref_comparator
<
T
>
());
this
->
erase
(
std
::
unique
(
this
->
begin
(),
this
->
end
()),
this
->
end
());
std
::
set
<
T
*>
seen
;
typename
parent_type
::
iterator
it1
=
this
->
begin
(),
it2
=
this
->
begin
();
for
(;
it1
<
this
->
end
();
++
it1
)
{
if
(
seen
.
find
(
it1
->
get
())
!=
seen
.
end
())
continue
;
seen
.
insert
(
it1
->
get
());
if
(
it1
!=
it2
)
*
it2
++
=
*
it1
;
else
it2
++
;
}
this
->
erase
(
it2
,
this
->
end
());
}
/// Check if a certain pointer is contained in the vector
...
...
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