• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

KCal Library

KCal::SortableList

KCal::SortableList< T > Class Template Reference

A QList which can be sorted. More...

#include <sortablelist.h>

Inherits QList< T >.

List of all members.


Public Member Functions

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)
 SortableList (const QList< T > &list)
 SortableList ()
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 <software@astrojar.org.uk>.

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:
list is 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:
value is 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 [inline]

Search the list for the first item >= value.

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

Parameters:
value is the value to find.
start is 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 [inline]

Search the list for the first item > value.

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

Parameters:
value is the value to find.
start is 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 [inline]

Search the list for the last item <= value.

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

Parameters:
value is the value to find.
start is 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 [inline]

Search the list for the last item < value.

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

Parameters:
value is the value to find.
start is 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 [inline]

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:
value is the value to find.
start is 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  )  [inline]

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:
value is 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 
) [inline]

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:
value is the value to remove.
start is 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

KCal Library

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  • kabc
  • kblog
  • kcal
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.7.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal