• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • KDE Home
  • Contact Us
 

KCalCore Library

  • KCalCore
  • SortableList
Public Member Functions
KCalCore::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

 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 KCalCore::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 >
KCalCore::SortableList< T >::SortableList ( ) [inline]

Constructs an empty sortable list.

Definition at line 92 of file sortablelist.h.

template<class T >
KCalCore::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 KCalCore::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 KCalCore::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 KCalCore::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 KCalCore::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 KCalCore::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 KCalCore::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 KCalCore::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 KCalCore::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 KCalCore::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

KCalCore Library

Skip menu "KCalCore 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
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.7.4
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