mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 02:35:33 +08:00
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:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user