HCoop
/
clinton
/
bobotpp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
656c065
)
Slightly better Utils::push_sorted
author
clinton
<clinton@unknownlamer.org>
Tue, 18 Nov 2008 21:41:48 +0000
(21:41 +0000)
committer
clinton
<clinton@unknownlamer.org>
Tue, 18 Nov 2008 21:41:48 +0000
(21:41 +0000)
No need to special case the not found case
source/Utils.H
patch
|
blob
|
blame
|
history
diff --git
a/source/Utils.H
b/source/Utils.H
index
0c5c008
..
46c0496
100644
(file)
--- a/
source/Utils.H
+++ b/
source/Utils.H
@@
-87,13
+87,10
@@
namespace Utils {
template<typename T, typename C>
void push_sorted (std::list<T> & storage, T item, C compare)
{
- typename std::list<T>::iterator it =
- std::find_if (storage.begin (), storage.end (),
- std::bind1st (compare, item));
- if (it != storage.end ())
- storage.insert (it, item);
- else
- storage.push_back (item);
+ storage.insert (std::find_if (storage.begin (), storage.end (),
+ std::bind1st (compare, item)),
+ item);
+
}
}