• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

KCal Library

  • KCal
  • SortableList
Public Member Functions | List of all members
KCal::SortableList< T > Class Template Reference

#include <sortablelist.h>

Inherits QList< T >.

Public Member Functions

 SortableList ()
 
 SortableList (const QList< T > &list)
 
bool containsSorted (const T &value) const
 
int findGE (const T &value, int start=0) const
 
int findGT (const T &value, int start=0) const
 
int findLE (const T &value, int start=0) const
 
int findLT (const T &value, int start=0) const
 
int findSorted (const T &value, int start=0) const
 
int insertSorted (const T &value)
 
int removeSorted (const T &value, int start=0)
 
void sortUnique ()
 

Detailed Description

template<class T>
class KCal::SortableList< T >

A QList which can be sorted.

For a QList is capable of being sorted, SortedList provides additional optimized methods which can be used when the list is sorted and has no duplicate entries.

Because SortableList has no data members, an object may be referred to interchangeably as either a QList or SortableList. Just bear in mind that the results of the SortableList methods are undefined when the list is unsorted or contains duplicate entries.

To sort the list and remove duplicate entries, thereby allowing use of other SortableList methods, use sortUnique(). Once sortUnique() has been called, use findSorted(), containsSorted() and removeSorted() in preference to QList::indexOf(), QList::contains() and QList::removeAll(). Use findLE(), findLT(), findGE(), findGT() to find the index to the nearest value in the list which is <=, <, >= or > a given value. To add a value to the list, use insertSorted() in preference to insert(), append(), prepend(), operator<<() or operator+=().

Author
David Jarvie <softw.nosp@m.are@.nosp@m.astro.nosp@m.jar..nosp@m.org.u.nosp@m.k>.

Definition at line 86 of file sortablelist.h.

Constructor & Destructor Documentation

template<class T >
KCal::SortableList< T >::SortableList ( )
inline

Constructs an empty sortable list.

Definition at line 92 of file sortablelist.h.

template<class T >
KCal::SortableList< T >::SortableList ( const QList< T > &  list)
inline

Constructs a sortable list by copying another one.

Parameters
listis the list to copy.

Definition at line 99 of file sortablelist.h.

Member Function Documentation

template<class T >
bool KCal::SortableList< T >::containsSorted ( const T &  value) const
inline

Return whether the list contains value value.

The list must be sorted; if not, the result is undefined. When the list is sorted, use this optimised method in preference to QList<T>::contains().

Parameters
valueis the value to find.
Returns
true if list contains value; false otherwise.

Definition at line 110 of file sortablelist.h.

template<class T >
int KCal::SortableList< T >::findGE ( const T &  value,
int  start = 0 
) const

Search the list for the first item >= value.

The list must be sorted; if not, the result is undefined.

Parameters
valueis the value to find.
startis the start index for search (default is from beginning).
Returns
index to item in list, or -1 if value > last value in the list.

Definition at line 246 of file sortablelist.h.

template<class T >
int KCal::SortableList< T >::findGT ( const T &  value,
int  start = 0 
) const

Search the list for the first item > value.

The list must be sorted; if not, the result is undefined.

Parameters
valueis the value to find.
startis the start index for search (default is from beginning).
Returns
index to item in list, or -1 if value >= last value in the list.

Definition at line 264 of file sortablelist.h.

template<class T >
int KCal::SortableList< T >::findLE ( const T &  value,
int  start = 0 
) const

Search the list for the last item <= value.

The list must be sorted; if not, the result is undefined.

Parameters
valueis the value to find.
startis the start index for search (default is from beginning).
Returns
index to item in list, or -1 if value < first value in the list.

Definition at line 212 of file sortablelist.h.

template<class T >
int KCal::SortableList< T >::findLT ( const T &  value,
int  start = 0 
) const

Search the list for the last item < value.

The list must be sorted; if not, the result is undefined.

Parameters
valueis the value to find.
startis the start index for search (default is from beginning).
Returns
index to item in list, or -1 if value <= first value in the list.

Definition at line 229 of file sortablelist.h.

template<class T >
int KCal::SortableList< T >::findSorted ( const T &  value,
int  start = 0 
) const

Search the list for the item equal to value.

The list must be sorted; if not, the result is undefined. When the list is sorted, use this optimised method in preference to QList<T>::indexOf().

Parameters
valueis the value to find.
startis the start index for search (default is from beginning).
Returns
index to item in list, or -1 if value not found in the list.

Definition at line 195 of file sortablelist.h.

template<class T >
int KCal::SortableList< T >::insertSorted ( const T &  value)

Insert a value in the list, in correct sorted order.

If the same value is already in the list, no change is made.

The list must already be sorted before calling this method; otherwise the result is undefined.

Parameters
valueis the value to insert.
Returns
index to inserted item in list, or to the pre-existing entry equal to value.

Definition at line 282 of file sortablelist.h.

template<class T >
int KCal::SortableList< T >::removeSorted ( const T &  value,
int  start = 0 
)

Remove value value from the list.

The list must be sorted. When the list is sorted, use this optimised method in preference to QList<T>::removeAll().

Parameters
valueis the value to remove.
startis the start index for search (default is from beginning).
Returns
index to removed value, or -1 if not found.

Definition at line 292 of file sortablelist.h.

template<class T >
void KCal::SortableList< T >::sortUnique ( )
inline

Sort the list.

Any duplicate values are removed.

Definition at line 191 of file sortablelist.h.


The documentation for this class was generated from the following file:
  • sortablelist.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KCal Library

Skip menu "KCal Library"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal