KCalCore Library
Go to the documentation of this file.
29 #ifndef KCALCORE_SORTABLELIST_H
30 #define KCALCORE_SORTABLELIST_H
32 #include <QtCore/QList>
33 #include <QtCore/QtAlgorithms>
39 void qSortUnique(QList<T> &list)
41 if (list.count() <= 1) {
45 typename QList<T>::iterator prev = list.begin();
46 for (
typename QList<T>::iterator it = prev + 1; it != list.end(); ++it) {
50 while (++it != list.end() && *it == *prev) ;
51 prev = it = list.erase(prev + 1, it);
52 if (it == list.end()) {
124 int findSorted(
const T &value,
int start = 0)
const;
134 int findLE(
const T &value,
int start = 0)
const;
144 int findLT(
const T &value,
int start = 0)
const;
154 int findGE(
const T &value,
int start = 0)
const;
164 int findGT(
const T &value,
int start = 0)
const;
203 int end = QList<T>::count();
204 while (end - st > 1) {
205 int i = (st + end) / 2;
206 if (value < QList<T>::at(i)) {
212 return (end > start && value == QList<T>::at(st)) ? st : -1;
220 int end = QList<T>::count();
221 while (end - st > 1) {
222 int i = (st + end) / 2;
223 if (value < QList<T>::at(i)) {
229 return (end > start) ? st : -1;
237 int end = QList<T>::count();
238 while (end - st > 1) {
239 int i = (st + end) / 2;
240 if (value <= QList<T>::at(i)) {
246 return (end > start) ? st : -1;
254 int end = QList<T>::count();
255 while (end - st > 1) {
256 int i = (st + end) / 2;
257 if (value <= QList<T>::at(i)) {
264 return (st == QList<T>::count()) ? -1 : st;
272 int end = QList<T>::count();
273 while (end - st > 1) {
274 int i = (st + end) / 2;
275 if (value < QList<T>::at(i)) {
282 return (st == QList<T>::count()) ? -1 : st;
288 int i = findLE(value);
289 if (i < 0 || QList<T>::at(i) != value) {
290 QList<T>::insert(++i, value);
298 int i = findSorted(value, start);
300 QList<T>::removeAt(i);
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Fri Jan 3 2014 22:20:29 by
doxygen 1.8.3.1 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.