Skip to content
Snippets Groups Projects
Commit 9fc3efa4 authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Joseph Mirabel
Browse files

Add method Statistics::insert

parent 5a36b447
No related branches found
No related tags found
No related merge requests found
...@@ -115,6 +115,11 @@ namespace hpp { ...@@ -115,6 +115,11 @@ namespace hpp {
/// already in the set. /// already in the set.
virtual T& increment (const T& bin) __attribute__ ((deprecated)); virtual T& increment (const T& bin) __attribute__ ((deprecated));
/// insert a Bin.
/// \note bin is inserted in the set of bins if it was not
/// already in the set.
virtual iterator insert (const T& bin);
iterator find (const T& bin); iterator find (const T& bin);
template < typename U > iterator find (const U& value); template < typename U > iterator find (const U& value);
...@@ -166,6 +171,24 @@ namespace hpp { ...@@ -166,6 +171,24 @@ namespace hpp {
return *it; return *it;
} }
template < typename T >
typename Statistics<T>::iterator Statistics <T>::insert (const T& b)
{
counts_++;
iterator it = bins_.begin ();
for (; it != bins_.end (); it++) {
if (! (*it < b)) {
if (! (*it == b))
it = bins_.insert (it, b);
(*it)++;
return it;
}
}
it = bins_.insert (it, b);
(*it)++;
return it;
}
template < typename T> template < typename T>
typename Statistics<T>::iterator Statistics <T>::find (const T& b) typename Statistics<T>::iterator Statistics <T>::find (const T& b)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment