mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-12 23:35:33 +08:00
Ref T240, added push_backMaxElements in CSequence
This commit is contained in:
@@ -190,7 +190,7 @@ namespace BlackGui
|
||||
void CRawFsdMessagesComponent::addFsdMessage(const CRawFsdMessage &rawFsdMessage)
|
||||
{
|
||||
if (m_buffer.size() == m_maxDisplayedMessages) { m_buffer.pop_front(); }
|
||||
m_buffer.push_back(rawFsdMessage.getRawMessage());
|
||||
m_buffer.push_backMaxElements(rawFsdMessage, m_maxDisplayedMessages);
|
||||
|
||||
if (! m_filterPacketType.isEmpty() && !rawFsdMessage.isPacketType(m_filterPacketType)) { return; }
|
||||
if (! m_filterString.isEmpty() && !rawFsdMessage.containsString(m_filterString)) { return; }
|
||||
|
||||
@@ -186,6 +186,14 @@ namespace BlackMisc
|
||||
this->push_front(value);
|
||||
}
|
||||
|
||||
//! Insert as last element by keep maxElements
|
||||
void push_backMaxElements(const T &value, int maxElements)
|
||||
{
|
||||
Q_ASSERT(maxElements > 1);
|
||||
while (this->size() >= (maxElements - 1)) { this->pop_front(); }
|
||||
this->push_back(value);
|
||||
}
|
||||
|
||||
//! Move-appends an element at the end of the sequence.
|
||||
void push_back(T &&value) { m_impl.push_back(std::move(value)); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user