Ref T241, Ref T243, ITimestampWithOffsetObjectList

* there was already ITimestampWithOffsetBased for objects
* this creates the container version
* functions to add objects (parts/situations) and guarantee the sort order
* moved push_frontMaxElements to CSequence (not specific for timestamp lists)
* added in-place reverse
This commit is contained in:
Klaus Basan
2018-02-02 20:41:41 +01:00
parent e9e0ae1ff4
commit 51ba6398bb
9 changed files with 170 additions and 17 deletions

View File

@@ -178,6 +178,14 @@ namespace BlackMisc
//! Insert as first element.
void push_front(const T &value) { insert(begin(), value); }
//! Insert as first element by keep maxElements
void push_frontMaxElements(const T &value, int maxElements)
{
Q_ASSERT(maxElements > 1);
if (this->size() >= (maxElements - 1)) { this->truncate(maxElements - 1); }
this->push_front(value);
}
//! Move-appends an element at the end of the sequence.
void push_back(T &&value) { m_impl.push_back(std::move(value)); }
@@ -376,6 +384,12 @@ namespace BlackMisc
else { push_back(replacement); }
}
//! In-place reverse
void reverse()
{
std::reverse(begin(), end());
}
//! In-place sort by a given comparator predicate.
template <class Predicate> void sort(Predicate p)
{