KCal Library
Go to the documentation of this file.
29 #ifndef KCAL_SORTABLELIST_H
30 #define KCAL_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() ) {
122 int findSorted(
const T &value,
int start = 0 )
const;
132 int findLE(
const T &value,
int start = 0 )
const;
142 int findLT(
const T &value,
int start = 0 )
const;
152 int findGE(
const T &value,
int start = 0 )
const;
162 int findGT(
const T &value,
int start = 0 )
const;
199 int end = QList<T>::count();
200 while ( end - st > 1 ) {
201 int i = ( st + end ) / 2;
202 if ( value < QList<T>::at(i) ) {
208 return ( end > start && value == QList<T>::at(st) ) ? st : -1;
216 int end = QList<T>::count();
217 while ( end - st > 1 ) {
218 int i = ( st + end ) / 2;
219 if ( value < QList<T>::at(i) ) {
225 return ( end > start ) ? st : -1;
233 int end = QList<T>::count();
234 while ( end - st > 1 ) {
235 int i = ( st + end ) / 2;
236 if ( value <= QList<T>::at(i) ) {
242 return ( end > start ) ? st : -1;
250 int end = QList<T>::count();
251 while ( end - st > 1 ) {
252 int i = ( st + end ) / 2;
253 if ( value <= QList<T>::at(i) ) {
260 return ( st == QList<T>::count() ) ? -1 : st;
268 int end = QList<T>::count();
269 while ( end - st > 1 ) {
270 int i = ( st + end ) / 2;
271 if ( value < QList<T>::at(i) ) {
278 return ( st == QList<T>::count() ) ? -1 : st;
284 int i = findLE( value );
285 if ( i < 0 || QList<T>::at(i) != value ) {
286 QList<T>::insert( ++i, value );
294 int i = findSorted( value, start );
296 QList<T>::removeAt( i );
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:29:17 by
doxygen 1.8.3.1 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.