aboutsummaryrefslogtreecommitdiff
path: root/events/event.h
diff options
context:
space:
mode:
authorFelix Rohrbach <fxrh@gmx.de>2016-04-11 23:51:26 +0200
committerFelix Rohrbach <fxrh@gmx.de>2016-04-11 23:51:26 +0200
commit00a73167ca455370868f1f82257420f0cb399a15 (patch)
treecb2ee402b352c236b9bd93ed5d82ce4191c9e8c6 /events/event.h
parente074be6a42d4fbc9fd76566365f3ef148a8e7bdd (diff)
parentba8b886e1e027ee1eadfc8fd66346bc0ad4a816b (diff)
downloadlibquotient-00a73167ca455370868f1f82257420f0cb399a15.tar.gz
libquotient-00a73167ca455370868f1f82257420f0cb399a15.zip
Merge pull request #2 from KitsuneRal/code-maintenance
Code maintenance
Diffstat (limited to 'events/event.h')
-rw-r--r--events/event.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/events/event.h b/events/event.h
index b25b1378..6a8d0e89 100644
--- a/events/event.h
+++ b/events/event.h
@@ -19,6 +19,8 @@
#ifndef QMATRIXCLIENT_EVENT_H
#define QMATRIXCLIENT_EVENT_H
+#include <algorithm>
+
#include <QtCore/QString>
#include <QtCore/QDateTime>
#include <QtCore/QJsonObject>
@@ -53,6 +55,22 @@ namespace QMatrixClient
class Private;
Private* d;
};
+
+ /**
+ * Finds a place in the timeline where a new event/message could be inserted.
+ * @return an iterator to an item with the earliest timestamp after
+ * the one of 'item'; or timeline.end(), if all events are earlier
+ */
+ template <class ItemT, template <typename> class ContT>
+ typename ContT<ItemT *>::iterator
+ findInsertionPos(ContT<ItemT *> & timeline, const ItemT *item)
+ {
+ return std::lower_bound (timeline.begin(), timeline.end(), item,
+ [](const ItemT * a, const ItemT * b) {
+ return a->timestamp() < b->timestamp();
+ }
+ );
+ }
}
#endif // QMATRIXCLIENT_EVENT_H