QtCore/qalgorithms.h File Reference

qalgorithms.h File Reference
#include <QtCore/qglobal.h>

Classes

class  qLess< T >
 
class  qGreater< T >
 

Namespaces

 QAlgorithmsPrivate
 

Functions

template<typename RandomAccessIterator , typename T , typename LessThan >
Q_OUTOFLINE_TEMPLATE void qSortHelper (RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan)
 
template<typename RandomAccessIterator , typename T >
void qSortHelper (RandomAccessIterator begin, RandomAccessIterator end, const T &dummy)
 
template<typename RandomAccessIterator , typename T , typename LessThan >
Q_OUTOFLINE_TEMPLATE void qStableSortHelper (RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan)
 
template<typename RandomAccessIterator , typename T >
void qStableSortHelper (RandomAccessIterator, RandomAccessIterator, const T &)
 
template<typename RandomAccessIterator , typename T , typename LessThan >
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBoundHelper (RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
 
template<typename RandomAccessIterator , typename T , typename LessThan >
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBoundHelper (RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
 
template<typename RandomAccessIterator , typename T , typename LessThan >
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFindHelper (RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
 
template<typename InputIterator , typename OutputIterator >
OutputIterator qCopy (InputIterator begin, InputIterator end, OutputIterator dest)
 
template<typename BiIterator1 , typename BiIterator2 >
BiIterator2 qCopyBackward (BiIterator1 begin, BiIterator1 end, BiIterator2 dest)
 
template<typename InputIterator1 , typename InputIterator2 >
bool qEqual (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
 
template<typename ForwardIterator , typename T >
void qFill (ForwardIterator first, ForwardIterator last, const T &val)
 
template<typename Container , typename T >
void qFill (Container &container, const T &val)
 
template<typename InputIterator , typename T >
InputIterator qFind (InputIterator first, InputIterator last, const T &val)
 
template<typename Container , typename T >
Container::const_iterator qFind (const Container &container, const T &val)
 
template<typename InputIterator , typename T , typename Size >
void qCount (InputIterator first, InputIterator last, const T &value, Size &n)
 
template<typename Container , typename T , typename Size >
void qCount (const Container &container, const T &value, Size &n)
 
template<typename RandomAccessIterator >
void qSort (RandomAccessIterator start, RandomAccessIterator end)
 
template<typename RandomAccessIterator , typename LessThan >
void qSort (RandomAccessIterator start, RandomAccessIterator end, LessThan lessThan)
 
template<typename Container >
void qSort (Container &c)
 
template<typename RandomAccessIterator >
void qStableSort (RandomAccessIterator start, RandomAccessIterator end)
 
template<typename RandomAccessIterator , typename LessThan >
void qStableSort (RandomAccessIterator start, RandomAccessIterator end, LessThan lessThan)
 
template<typename Container >
void qStableSort (Container &c)
 
template<typename RandomAccessIterator , typename T >
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound (RandomAccessIterator begin, RandomAccessIterator end, const T &value)
 
template<typename RandomAccessIterator , typename T , typename LessThan >
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound (RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
 
template<typename Container , typename T >
Q_OUTOFLINE_TEMPLATE Container::const_iterator qLowerBound (const Container &container, const T &value)
 
template<typename RandomAccessIterator , typename T >
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBound (RandomAccessIterator begin, RandomAccessIterator end, const T &value)
 
template<typename RandomAccessIterator , typename T , typename LessThan >
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBound (RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
 
template<typename Container , typename T >
Q_OUTOFLINE_TEMPLATE Container::const_iterator qUpperBound (const Container &container, const T &value)
 
template<typename RandomAccessIterator , typename T >
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind (RandomAccessIterator begin, RandomAccessIterator end, const T &value)
 
template<typename RandomAccessIterator , typename T , typename LessThan >
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind (RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
 
template<typename Container , typename T >
Q_OUTOFLINE_TEMPLATE Container::const_iterator qBinaryFind (const Container &container, const T &value)
 
template<typename ForwardIterator >
Q_OUTOFLINE_TEMPLATE void qDeleteAll (ForwardIterator begin, ForwardIterator end)
 
template<typename Container >
void qDeleteAll (const Container &c)
 
template<typename RandomAccessIterator >
Q_OUTOFLINE_TEMPLATE void qReverse (RandomAccessIterator begin, RandomAccessIterator end)
 
template<typename RandomAccessIterator >
Q_OUTOFLINE_TEMPLATE void qRotate (RandomAccessIterator begin, RandomAccessIterator middle, RandomAccessIterator end)
 
template<typename RandomAccessIterator , typename T , typename LessThan >
Q_OUTOFLINE_TEMPLATE void qMerge (RandomAccessIterator begin, RandomAccessIterator pivot, RandomAccessIterator end, T &t, LessThan lessThan)
 

Function Documentation

OutputIterator qCopy ( InputIterator  begin,
InputIterator  end,
OutputIterator  dest 
)
inline

Definition at line 79 of file qalgorithms.h.

80 {
81  while (begin != end)
82  *dest++ = *begin++;
83  return dest;
84 }
GLuint GLuint end
Definition: GLee.h:872
BiIterator2 qCopyBackward ( BiIterator1  begin,
BiIterator1  end,
BiIterator2  dest 
)
inline

Definition at line 87 of file qalgorithms.h.

88 {
89  while (begin != end)
90  *--dest = *--end;
91  return dest;
92 }
GLuint GLuint end
Definition: GLee.h:872
bool qEqual ( InputIterator1  first1,
InputIterator1  last1,
InputIterator2  first2 
)
inline

Definition at line 95 of file qalgorithms.h.

96 {
97  for (; first1 != last1; ++first1, ++first2)
98  if (!(*first1 == *first2))
99  return false;
100  return true;
101 }
void qFill ( ForwardIterator  first,
ForwardIterator  last,
const T &  val 
)
inline

Definition at line 104 of file qalgorithms.h.

105 {
106  for (; first != last; ++first)
107  *first = val;
108 }
GLint * first
Definition: GLee.h:1362
void qFill ( Container &  container,
const T &  val 
)
inline

Definition at line 111 of file qalgorithms.h.

112 {
113  qFill(container.begin(), container.end(), val);
114 }
void qFill(ForwardIterator first, ForwardIterator last, const T &val)
Definition: qalgorithms.h:104
InputIterator qFind ( InputIterator  first,
InputIterator  last,
const T &  val 
)
inline

Definition at line 117 of file qalgorithms.h.

118 {
119  while (first != last && !(*first == val))
120  ++first;
121  return first;
122 }
GLint * first
Definition: GLee.h:1362
Container::const_iterator qFind ( const Container &  container,
const T &  val 
)
inline

Definition at line 125 of file qalgorithms.h.

126 {
127  return qFind(container.constBegin(), container.constEnd(), val);
128 }
InputIterator qFind(InputIterator first, InputIterator last, const T &val)
Definition: qalgorithms.h:117
void qCount ( InputIterator  first,
InputIterator  last,
const T &  value,
Size &  n 
)
inline

Definition at line 131 of file qalgorithms.h.

132 {
133  for (; first != last; ++first)
134  if (*first == value)
135  ++n;
136 }
GLint * first
Definition: GLee.h:1362
GLenum GLsizei n
Definition: GLee.h:3432
GLsizei const GLfloat * value
Definition: GLee.h:1742
void qCount ( const Container &  container,
const T &  value,
Size &  n 
)
inline

Definition at line 139 of file qalgorithms.h.

140 {
141  qCount(container.constBegin(), container.constEnd(), value, n);
142 }
void qCount(InputIterator first, InputIterator last, const T &value, Size &n)
Definition: qalgorithms.h:131
GLenum GLsizei n
Definition: GLee.h:3432
GLsizei const GLfloat * value
Definition: GLee.h:1742
void qSort ( RandomAccessIterator  start,
RandomAccessIterator  end 
)
inline

Definition at line 177 of file qalgorithms.h.

178 {
179  if (start != end)
181 }
GLuint start
Definition: GLee.h:872
Q_OUTOFLINE_TEMPLATE void qSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan)
Definition: qalgorithms.h:340
GLuint GLuint end
Definition: GLee.h:872
void qSort ( RandomAccessIterator  start,
RandomAccessIterator  end,
LessThan  lessThan 
)
inline

Definition at line 184 of file qalgorithms.h.

185 {
186  if (start != end)
188 }
GLuint start
Definition: GLee.h:872
Q_OUTOFLINE_TEMPLATE void qSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan)
Definition: qalgorithms.h:340
GLuint GLuint end
Definition: GLee.h:872
void qSort ( Container &  c)
inline

Definition at line 191 of file qalgorithms.h.

192 {
193 #ifdef Q_CC_BOR
194  // Work around Borland 5.5 optimizer bug
195  c.detach();
196 #endif
197  if (!c.empty())
198  QAlgorithmsPrivate::qSortHelper(c.begin(), c.end(), *c.begin());
199 }
Q_OUTOFLINE_TEMPLATE void qSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan)
Definition: qalgorithms.h:340
const GLubyte * c
Definition: GLee.h:5419
void qStableSort ( RandomAccessIterator  start,
RandomAccessIterator  end 
)
inline

Definition at line 202 of file qalgorithms.h.

203 {
204  if (start != end)
206 }
GLuint start
Definition: GLee.h:872
GLuint GLuint end
Definition: GLee.h:872
Q_OUTOFLINE_TEMPLATE void qStableSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan)
Definition: qalgorithms.h:450
void qStableSort ( RandomAccessIterator  start,
RandomAccessIterator  end,
LessThan  lessThan 
)
inline

Definition at line 209 of file qalgorithms.h.

210 {
211  if (start != end)
213 }
GLuint start
Definition: GLee.h:872
GLuint GLuint end
Definition: GLee.h:872
Q_OUTOFLINE_TEMPLATE void qStableSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan)
Definition: qalgorithms.h:450
void qStableSort ( Container &  c)
inline

Definition at line 216 of file qalgorithms.h.

217 {
218 #ifdef Q_CC_BOR
219  // Work around Borland 5.5 optimizer bug
220  c.detach();
221 #endif
222  if (!c.empty())
223  QAlgorithmsPrivate::qStableSortHelper(c.begin(), c.end(), *c.begin());
224 }
const GLubyte * c
Definition: GLee.h:5419
Q_OUTOFLINE_TEMPLATE void qStableSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan)
Definition: qalgorithms.h:450
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound ( RandomAccessIterator  begin,
RandomAccessIterator  end,
const T &  value 
)

Definition at line 227 of file qalgorithms.h.

228 {
229  // Implementation is duplicated from QAlgorithmsPrivate to keep existing code
230  // compiling. We have to allow using *begin and value with different types,
231  // and then implementing operator< for those types.
232  RandomAccessIterator middle;
233  int n = end - begin;
234  int half;
235 
236  while (n > 0) {
237  half = n >> 1;
238  middle = begin + half;
239  if (*middle < value) {
240  begin = middle + 1;
241  n -= half + 1;
242  } else {
243  n = half;
244  }
245  }
246  return begin;
247 }
GLenum GLsizei n
Definition: GLee.h:3432
GLsizei const GLfloat * value
Definition: GLee.h:1742
GLuint GLuint end
Definition: GLee.h:872
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound ( RandomAccessIterator  begin,
RandomAccessIterator  end,
const T &  value,
LessThan  lessThan 
)

Definition at line 250 of file qalgorithms.h.

251 {
252  return QAlgorithmsPrivate::qLowerBoundHelper(begin, end, value, lessThan);
253 }
GLsizei const GLfloat * value
Definition: GLee.h:1742
GLuint GLuint end
Definition: GLee.h:872
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
Definition: qalgorithms.h:469
Q_OUTOFLINE_TEMPLATE Container::const_iterator qLowerBound ( const Container &  container,
const T &  value 
)

Definition at line 256 of file qalgorithms.h.

257 {
258  return QAlgorithmsPrivate::qLowerBoundHelper(container.constBegin(), container.constEnd(), value, qLess<T>());
259 }
GLsizei const GLfloat * value
Definition: GLee.h:1742
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
Definition: qalgorithms.h:469
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBound ( RandomAccessIterator  begin,
RandomAccessIterator  end,
const T &  value 
)

Definition at line 262 of file qalgorithms.h.

263 {
264  // Implementation is duplicated from QAlgorithmsPrivate.
265  RandomAccessIterator middle;
266  int n = end - begin;
267  int half;
268 
269  while (n > 0) {
270  half = n >> 1;
271  middle = begin + half;
272  if (value < *middle) {
273  n = half;
274  } else {
275  begin = middle + 1;
276  n -= half + 1;
277  }
278  }
279  return begin;
280 }
GLenum GLsizei n
Definition: GLee.h:3432
GLsizei const GLfloat * value
Definition: GLee.h:1742
GLuint GLuint end
Definition: GLee.h:872
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBound ( RandomAccessIterator  begin,
RandomAccessIterator  end,
const T &  value,
LessThan  lessThan 
)

Definition at line 283 of file qalgorithms.h.

284 {
285  return QAlgorithmsPrivate::qUpperBoundHelper(begin, end, value, lessThan);
286 }
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
Definition: qalgorithms.h:490
GLsizei const GLfloat * value
Definition: GLee.h:1742
GLuint GLuint end
Definition: GLee.h:872
Q_OUTOFLINE_TEMPLATE Container::const_iterator qUpperBound ( const Container &  container,
const T &  value 
)

Definition at line 289 of file qalgorithms.h.

290 {
291  return QAlgorithmsPrivate::qUpperBoundHelper(container.constBegin(), container.constEnd(), value, qLess<T>());
292 }
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
Definition: qalgorithms.h:490
GLsizei const GLfloat * value
Definition: GLee.h:1742
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind ( RandomAccessIterator  begin,
RandomAccessIterator  end,
const T &  value 
)

Definition at line 295 of file qalgorithms.h.

296 {
297  // Implementation is duplicated from QAlgorithmsPrivate.
298  RandomAccessIterator it = qLowerBound(begin, end, value);
299 
300  if (it == end || value < *it)
301  return end;
302 
303  return it;
304 }
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
Definition: qalgorithms.h:227
GLsizei const GLfloat * value
Definition: GLee.h:1742
GLuint GLuint end
Definition: GLee.h:872
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind ( RandomAccessIterator  begin,
RandomAccessIterator  end,
const T &  value,
LessThan  lessThan 
)

Definition at line 307 of file qalgorithms.h.

308 {
309  return QAlgorithmsPrivate::qBinaryFindHelper(begin, end, value, lessThan);
310 }
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFindHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
Definition: qalgorithms.h:510
GLsizei const GLfloat * value
Definition: GLee.h:1742
GLuint GLuint end
Definition: GLee.h:872
Q_OUTOFLINE_TEMPLATE Container::const_iterator qBinaryFind ( const Container &  container,
const T &  value 
)

Definition at line 313 of file qalgorithms.h.

314 {
315  return QAlgorithmsPrivate::qBinaryFindHelper(container.constBegin(), container.constEnd(), value, qLess<T>());
316 }
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFindHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
Definition: qalgorithms.h:510
GLsizei const GLfloat * value
Definition: GLee.h:1742
Q_OUTOFLINE_TEMPLATE void qDeleteAll ( ForwardIterator  begin,
ForwardIterator  end 
)

Definition at line 319 of file qalgorithms.h.

320 {
321  while (begin != end) {
322  delete *begin;
323  ++begin;
324  }
325 }
GLuint GLuint end
Definition: GLee.h:872
void qDeleteAll ( const Container &  c)
inline

Definition at line 328 of file qalgorithms.h.

329 {
330  qDeleteAll(c.begin(), c.end());
331 }
const GLubyte * c
Definition: GLee.h:5419
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319

Go to the source code of this file.