summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qalgorithms.qdoc
blob: 096ede2fec46fe5da4d7d7127e9f4731a1ee21e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
    \headerfile <QtAlgorithms>
    \title Generic Algorithms
    \ingroup funclists

    \brief The <QtAlgorithms> header includes the generic, template-based algorithms.

    Qt provides a number of global template functions in \c
    <QtAlgorithms> that work on containers and perform small tasks to
    make life easier, such as qDeleteAll(), which invokes \c{operator delete}
    on all items in a given container or in a given range.
    You can use these algorithms with any \l {container
    class} that provides STL-style iterators, including Qt's QList,
    QLinkedList, QVector, QMap, and QHash classes.

    Most algorithms take \l {STL-style iterators} as parameters. The
    algorithms are generic in the sense that they aren't bound to a
    specific iterator class; you can use them with any iterators that
    meet a certain set of requirements.

    Different algorithms can have different requirements for the
    iterators they accept. For example, qFill() accepts two
    \l {forward iterators}. The iterator types required are specified
    for each algorithm. If an iterator of the wrong type is passed (for
    example, if QList::ConstIterator is passed as an
    \l {Output Iterators}{output iterator}), you will always get a
    compiler error, although not necessarily a very informative one.

    Some algorithms have special requirements on the value type
    stored in the containers. For example,
    qDeleteAll() requires that the value type is a
    non-const pointer type (for example, QWidget *). The value type
    requirements are specified for each algorithm, and the compiler
    will produce an error if a requirement isn't met.

    The generic algorithms can be used on other container classes
    than those provided by Qt and STL. The syntax of STL-style
    iterators is modeled after C++ pointers, so it's possible to use
    plain arrays as containers and plain pointers as iterators. A
    common idiom is to use qBinaryFind() together with two static
    arrays: one that contains a list of keys, and another that
    contains a list of associated values. For example, the following
    code will look up an HTML entity (e.g., \c &amp;) in the \c
    name_table array and return the corresponding Unicode value from
    the \c value_table if the entity is recognized:

    \snippet code/doc_src_qalgorithms.cpp 2

    This kind of code is for advanced users only; for most
    applications, a QMap- or QHash-based approach would work just as
    well:

    \snippet code/doc_src_qalgorithms.cpp 3

    \section1 Types of Iterators

    The algorithms have certain requirements on the iterator types
    they accept, and these are specified individually for each
    function. The compiler will produce an error if a requirement
    isn't met.

    \section2 Input Iterators

    An \e{input iterator} is an iterator that can be used for reading
    data sequentially from a container. It must provide the following
    operators: \c{==} and \c{!=} for comparing two iterators, unary
    \c{*} for retrieving the value stored in the item, and prefix
    \c{++} for advancing to the next item.

    The Qt containers' iterator types (const and non-const) are all
    input iterators.

    \section2 Output Iterators

    An output iterator is an iterator that can be used for
    writing data sequentially to a container or to some output
    stream. It must provide the following operators: unary \c{*} for
    writing a value (i.e., \c{*it = val}) and prefix \c{++} for
    advancing to the next item.

    The Qt containers' non-const iterator types are all output
    iterators.

    \section2 Forward Iterators

    A \e{forward iterator} is an iterator that meets the requirements
    of both input iterators and output iterators.

    The Qt containers' non-const iterator types are all forward
    iterators.

    \section2 Bidirectional Iterators

    A \e{bidirectional iterator} is an iterator that meets the
    requirements of forward iterators but that in addition supports
    prefix \c{--} for iterating backward.

    The Qt containers' non-const iterator types are all bidirectional
    iterators.

    \section2 Random Access Iterators

    The last category, \e{random access iterators}, is the most
    powerful type of iterator. It supports all the requirements of a
    bidirectional iterator, and supports the following operations:

    \table
    \row \li \c{i += n} \li advances iterator \c i by \c n positions
    \row \li \c{i -= n} \li moves iterator \c i back by \c n positions
    \row \li \c{i + n} or \c{n + i} \li returns the iterator for the item \c
       n positions ahead of iterator \c i
    \row \li \c{i - n} \li returns the iterator for the item \c n positions behind of iterator \c i
    \row \li \c{i - j} \li returns the number of items between iterators \c i and \c j
    \row \li \c{i[n]} \li same as \c{*(i + n)}
    \row \li \c{i < j} \li returns \c true if iterator \c j comes after iterator \c i
    \endtable

    QList and QVector's non-const iterator types are random access iterators.

    \section1 Qt and the STL Algorithms

    Historically, Qt used to provide functions which were direct equivalents of
    many STL algorithmic functions. Starting with Qt 5.0, you are instead
    encouraged to use directly the implementations available in the STL; most
    of the Qt ones have been deprecated (although they are still available to
    keep the old code compiling).

    \section2 Porting guidelines

    Most of the times, an application using the deprecated Qt algorithmic functions
    can be easily ported to use the equivalent STL functions. You need to

    \list 1
        \li add the \c{#include <algorithm>} preprocessor directive;
        \li replace the Qt functions with the STL counterparts, according to the table below.
    \endlist

    \table
    \header
        \li Qt function
        \li STL function
    \row
        \li qBinaryFind
        \li \c std::binary_search or \c std::lower_bound
    \row
        \li qCopy
        \li \c std::copy
    \row
        \li qCopyBackward
        \li \c std::copy_backward
    \row
        \li qEqual
        \li \c std::equal
    \row
        \li qFill
        \li \c std::fill
    \row
        \li qFind
        \li \c std::find
    \row
        \li qCount
        \li \c std::count
    \row
        \li qSort
        \li \c std::sort
    \row
        \li qStableSort
        \li \c std::stable_sort
    \row
        \li qLowerBound
        \li \c std::lower_bound
    \row
        \li qUpperBound
        \li \c std::upper_bound
    \row
        \li qLess
        \li \c std::less
    \row
        \li qGreater
        \li \c std::greater

    \endtable

    The only cases in which the port may not be straightforward is if the old
    code relied on template specializations of the qLess() and/or the qSwap()
    functions, which were used internally by the implementations of the Qt
    algorithmic functions, but are instead ignored by the STL ones.

    In case the old code relied on the specialization of the qLess() functor,
    then a workaround is explicitly passing an instance of the qLess() class
    to the STL function, for instance like this:

    \code
        std::sort(container.begin(), container.end(), qLess<T>());
    \endcode

    Instead, since it's not possible to pass a custom swapper functor to STL
    functions, the only workaround for a template specialization for qSwap() is
    providing the same specialization for \c std::swap().

    \sa {container classes}, <QtGlobal>
*/

/*! \fn OutputIterator qCopy(InputIterator begin1, InputIterator end1, OutputIterator begin2)
    \relates <QtAlgorithms>
    \deprecated

    Use \c std::copy instead.

    Copies the items from range [\a begin1, \a end1) to range [\a
    begin2, ...), in the order in which they appear.

    The item at position \a begin1 is assigned to that at position \a
    begin2; the item at position \a begin1 + 1 is assigned to that at
    position \a begin2 + 1; and so on.

    Example:
    \snippet code/doc_src_qalgorithms.cpp 4

    \sa qCopyBackward(), {input iterators}, {output iterators}
*/

/*! \fn BiIterator2 qCopyBackward(BiIterator1 begin1, BiIterator1 end1, BiIterator2 end2)
    \relates <QtAlgorithms>
    \deprecated

    Use \c std::copy_backward instead.

    Copies the items from range [\a begin1, \a end1) to range [...,
    \a end2).

    The item at position \a end1 - 1 is assigned to that at position
    \a end2 - 1; the item at position \a end1 - 2 is assigned to that
    at position \a end2 - 2; and so on.

    Example:
    \snippet code/doc_src_qalgorithms.cpp 5

    \sa qCopy(), {bidirectional iterators}
*/

/*! \fn bool qEqual(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2)
    \relates <QtAlgorithms>
    \deprecated

    Use \c std::equal instead.

    Compares the items in the range [\a begin1, \a end1) with the
    items in the range [\a begin2, ...). Returns \c true if all the
    items compare equal; otherwise returns \c false.

    Example:
    \snippet code/doc_src_qalgorithms.cpp 6

    This function requires the item type (in the example above,
    QString) to implement \c operator==().

    \sa {input iterators}
*/

/*! \fn void qFill(ForwardIterator begin, ForwardIterator end, const T &value)
    \relates <QtAlgorithms>
    \deprecated

    Use \c std::fill instead.

    Fills the range [\a begin, \a end) with \a value.

    Example:
    \snippet code/doc_src_qalgorithms.cpp 7

    \sa qCopy(), {forward iterators}
*/

/*! \fn void qFill(Container &container, const T &value)
    \relates <QtAlgorithms>
    \deprecated
    \overload

    Use \c std::fill instead.

    This is the same as qFill(\a{container}.begin(), \a{container}.end(), \a value);
*/

/*! \fn InputIterator qFind(InputIterator begin, InputIterator end, const T &value)
    \relates <QtAlgorithms>
    \deprecated

    Use \c std::find instead.

    Returns an iterator to the first occurrence of \a value in a
    container in the range [\a begin, \a end). Returns \a end if \a
    value isn't found.

    Example:
    \snippet code/doc_src_qalgorithms.cpp 8

    This function requires the item type (in the example above,
    QString) to implement \c operator==().

    If the items in the range are in ascending order, you can get
    faster results by using qLowerBound() or qBinaryFind() instead of
    qFind().

    \sa qBinaryFind(), {input iterators}
*/

/*! \fn void qFind(const Container &container, const T &value)
    \relates <QtAlgorithms>
    \deprecated
    \overload

    Use \c std::find instead.

    This is the same as qFind(\a{container}.constBegin(), \a{container}.constEnd(), \a value);
*/

/*! \fn void qCount(InputIterator begin, InputIterator end, const T &value, Size &n)
    \relates <QtAlgorithms>
    \deprecated

    Use \c std::count instead.

    Returns the number of occurrences of \a value in the range [\a begin, \a end),
    which is returned in \a n. \a n is never initialized, the count is added to \a n.
    It is the caller's responsibility to initialize \a n.

    Example:

    \snippet code/doc_src_qalgorithms.cpp 9

    This function requires the item type (in the example above,
    \c int) to implement \c operator==().

    \sa {input iterators}
*/

/*! \fn void qCount(const Container &container, const T &value, Size &n)
    \relates <QtAlgorithms>
    \deprecated
    \overload

    Use \c std::count instead.

    Instead of operating on iterators, as in the other overload, this function
    operates on the specified \a container to obtain the number of instances
    of \a value in the variable passed as a reference in argument \a n.
*/

/*! \fn void qSwap(T &var1, T &var2)
    \relates <QtAlgorithms>
    \deprecated

    Use \c std::swap instead.

    Exchanges the values of variables \a var1 and \a var2.

    Example:
    \snippet code/doc_src_qalgorithms.cpp 10
*/

/*! \fn void qSort(RandomAccessIterator begin, RandomAccessIterator end)
    \relates <QtAlgorithms>
    \deprecated

    Use \c std::sort instead.

    Sorts the items in range [\a begin, \a end) in ascending order
    using the quicksort algorithm.

    Example:
    \snippet code/doc_src_qalgorithms.cpp 11

    The sort algorithm is efficient on large data sets. It operates
    in \l {linear-logarithmic time}, O(\e{n} log \e{n}).

    This function requires the item type (in the example above,
    \c{int}) to implement \c operator<().

    If neither of the two items is "less than" the other, the items are
    taken to be equal. It is then undefined which one of the two
    items will appear before the other after the sort.

    \sa qStableSort(), {random access iterators}
*/

/*! \fn void qSort(RandomAccessIterator begin, RandomAccessIterator end, LessThan lessThan)
    \relates <QtAlgorithms>
    \deprecated
    \overload

    Use \c std::sort instead.

    Uses the \a lessThan function instead of \c operator<() to
    compare the items.

    For example, here's how to sort the strings in a QStringList
    in case-insensitive alphabetical order:

    \snippet code/doc_src_qalgorithms.cpp 12

    To sort values in reverse order, pass
    \l{qGreater()}{qGreater<T>()} as the \a lessThan parameter. For
    example:

    \snippet code/doc_src_qalgorithms.cpp 13

    If neither of the two items is "less than" the other, the items are
    taken to be equal. It is then undefined which one of the two
    items will appear before the other after the sort.

    An alternative to using qSort() is to put the items to sort in a
    QMap, using the sort key as the QMap key. This is often more
    convenient than defining a \a lessThan function. For example, the
    following code shows how to sort a list of strings case
    insensitively using QMap:

    \snippet code/doc_src_qalgorithms.cpp 14

    \sa QMap
*/

/*! \fn void qSort(Container &container)
    \relates <QtAlgorithms>
    \deprecated
    \overload

    Use \c std::sort instead.

    This is the same as qSort(\a{container}.begin(), \a{container}.end());
*/

/*!
    \fn void qStableSort(RandomAccessIterator begin, RandomAccessIterator end)
    \relates <QtAlgorithms>
    \deprecated

    Use \c std::stable_sort instead.

    Sorts the items in range [\a begin, \a end) in ascending order
    using a stable sorting algorithm.

    If neither of the two items is "less than" the other, the items are
    taken to be equal. The item that appeared before the other in the
    original container will still appear first after the sort. This
    property is often useful when sorting user-visible data.

    Example:
    \snippet code/doc_src_qalgorithms.cpp 15

    The sort algorithm is efficient on large data sets. It operates
    in \l {linear-logarithmic time}, O(\e{n} log \e{n}).

    This function requires the item type (in the example above,
    \c{int}) to implement \c operator<().

    \sa qSort(), {random access iterators}
*/

/*!
    \fn void qStableSort(RandomAccessIterator begin, RandomAccessIterator end, LessThan lessThan)
    \relates <QtAlgorithms>
    \deprecated
    \overload

    Use \c std::stable_sort instead.

    Uses the \a lessThan function instead of \c operator<() to
    compare the items.

    For example, here's how to sort the strings in a QStringList
    in case-insensitive alphabetical order:

    \snippet code/doc_src_qalgorithms.cpp 16

    Note that earlier versions of Qt allowed using a lessThan function that took its
    arguments by non-const reference. From 4.3 and on this is no longer possible,
    the arguments has to be passed by const reference or value.

    To sort values in reverse order, pass
    \l{qGreater()}{qGreater<T>()} as the \a lessThan parameter. For
    example:

    \snippet code/doc_src_qalgorithms.cpp 17

    If neither of the two items is "less than" the other, the items are
    taken to be equal. The item that appeared before the other in the
    original container will still appear first after the sort. This
    property is often useful when sorting user-visible data.
*/

/*!
    \fn void qStableSort(Container &container)
    \relates <QtAlgorithms>
    \deprecated
    \overload

    Use \c std::stable_sort instead.

    This is the same as qStableSort(\a{container}.begin(), \a{container}.end());
*/

/*! \fn RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
    \relates <QtAlgorithms>
    \deprecated

    Use \c std::lower_bound instead.

    Performs a binary search of the range [\a begin, \a end) and
    returns the position of the first occurrence of \a value. If no
    such item is found, returns the position where it should be
    inserted.

    The items in the range [\a begin, \e end) must be sorted in
    ascending order; see qSort().

    Example:
    \snippet code/doc_src_qalgorithms.cpp 18

    This function requires the item type (in the example above,
    \c{int}) to implement \c operator<().

    qLowerBound() can be used in conjunction with qUpperBound() to
    iterate over all occurrences of the same value:

    \snippet code/doc_src_qalgorithms.cpp 19

    \sa qUpperBound(), qBinaryFind()
*/

/*!
    \fn RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
    \relates <QtAlgorithms>
    \deprecated
    \overload

    Use \c std::lower_bound instead.

    Uses the \a lessThan function instead of \c operator<() to
    compare the items.

    Note that the items in the range must be sorted according to the order
    specified by the \a lessThan object.
*/

/*!
    \fn void qLowerBound(const Container &container, const T &value)
    \relates <QtAlgorithms>
    \deprecated
    \overload

    Use \c std::lower_bound instead.

    For read-only iteration over containers, this function is broadly equivalent to
    qLowerBound(\a{container}.begin(), \a{container}.end(), value). However, since it
    returns a const iterator, you cannot use it to modify the container; for example,
    to insert items.
*/

/*! \fn RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
    \relates <QtAlgorithms>
    \deprecated

    Use \c std::upper_bound instead.

    Performs a binary search of the range [\a begin, \a end) and
    returns the position of the one-past-the-last occurrence of \a
    value. If no such item is found, returns the position where the
    item should be inserted.

    The items in the range [\a begin, \e end) must be sorted in
    ascending order; see qSort().

    Example:
    \snippet code/doc_src_qalgorithms.cpp 20

    This function requires the item type (in the example above,
    \c{int}) to implement \c operator<().

    qUpperBound() can be used in conjunction with qLowerBound() to
    iterate over all occurrences of the same value:

    \snippet code/doc_src_qalgorithms.cpp 21

    \sa qLowerBound(), qBinaryFind()
*/

/*!
    \fn RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
    \relates <QtAlgorithms>
    \deprecated
    \overload

    Use \c std::upper_bound instead.

    Uses the \a lessThan function instead of \c operator<() to
    compare the items.

    Note that the items in the range must be sorted according to the order
    specified by the \a lessThan object.
*/

/*!
    \fn void qUpperBound(const Container &container, const T &value)
    \relates <QtAlgorithms>
    \deprecated
    \overload

    Use \c std::upper_bound instead.

    This is the same as qUpperBound(\a{container}.begin(), \a{container}.end(), \a value);
*/


/*! \fn RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
    \relates <QtAlgorithms>
    \deprecated

    Use \c std::binary_search or \c std::lower_bound instead.

    Performs a binary search of the range [\a begin, \a end) and
    returns the position of an occurrence of \a value. If there are
    no occurrences of \a value, returns \a end.

    The items in the range [\a begin, \a end) must be sorted in
    ascending order; see qSort().

    If there are many occurrences of the same value, any one of them
    could be returned. Use qLowerBound() or qUpperBound() if you need
    finer control.

    Example:
    \snippet code/doc_src_qalgorithms.cpp 22

    This function requires the item type (in the example above,
    QString) to implement \c operator<().

    \sa qLowerBound(), qUpperBound(), {random access iterators}
*/

/*! \fn RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
    \relates <QtAlgorithms>
    \deprecated
    \overload

    Use \c std::binary_search or \c std::lower_bound instead.

    Uses the \a lessThan function instead of \c operator<() to
    compare the items.

    Note that the items in the range must be sorted according to the order
    specified by the \a lessThan object.
*/

/*!
    \fn void qBinaryFind(const Container &container, const T &value)
    \relates <QtAlgorithms>
    \deprecated
    \overload

    Use \c std::binary_search or \c std::lower_bound instead.

    This is the same as qBinaryFind(\a{container}.begin(), \a{container}.end(), \a value);
*/


/*!
    \fn void qDeleteAll(ForwardIterator begin, ForwardIterator end)
    \relates <QtAlgorithms>

    Deletes all the items in the range [\a begin, \a end) using the
    C++ \c delete operator. The item type must be a pointer type (for
    example, \c{QWidget *}).

    Example:
    \snippet code/doc_src_qalgorithms.cpp 23

    Notice that qDeleteAll() doesn't remove the items from the
    container; it merely calls \c delete on them. In the example
    above, we call clear() on the container to remove the items.

    This function can also be used to delete items stored in
    associative containers, such as QMap and QHash. Only the objects
    stored in each container will be deleted by this function; objects
    used as keys will not be deleted.

    \sa {forward iterators}
*/

/*!
    \fn void qDeleteAll(const Container &c)
    \relates <QtAlgorithms>

    \overload

    This is the same as qDeleteAll(\a{c}.begin(), \a{c}.end()).
*/

/*! \fn LessThan qLess()
    \relates <QtAlgorithms>
    \deprecated

    Use \c std::less instead.

    Returns a functional object, or functor, that can be passed to qSort()
    or qStableSort().

    Example:

    \snippet code/doc_src_qalgorithms.cpp 24

    \sa {qGreater()}{qGreater<T>()}
*/

/*! \fn LessThan qGreater()
    \relates <QtAlgorithms>
    \deprecated

    Use \c std::greater instead.

    Returns a functional object, or functor, that can be passed to qSort()
    or qStableSort().

    Example:

    \snippet code/doc_src_qalgorithms.cpp 25

    \sa {qLess()}{qLess<T>()}
*/


/*!
    \fn uint qPopulationCount(quint8 v)
    \relates <QtAlgorithms>
    \since 5.2

    Returns the number of bits set in \a v. This number is also called
    the Hamming Weight of \a v.
 */

/*!
    \fn uint qPopulationCount(quint16 v)
    \relates <QtAlgorithms>
    \since 5.2
    \overload
 */

/*!
    \fn uint qPopulationCount(quint32 v)
    \relates <QtAlgorithms>
    \since 5.2
    \overload
 */

/*!
    \fn uint qPopulationCount(quint64 v)
    \relates <QtAlgorithms>
    \since 5.2
    \overload
 */

/*!
    \fn uint qCountTrailingZeroBits(quint8 v)
    \relates <QtAlgorithms>
    \since 5.6

    Returns the number of consecutive zero bits in \a v, when searching from the LSB.
    For example, qCountTrailingZeroBits(1) returns 0 and qCountTrailingZeroBits(8) returns 3.
 */

/*!
    \fn uint qCountTrailingZeroBits(quint16 v)
    \relates <QtAlgorithms>
    \since 5.6
    \overload
 */

/*!
    \fn uint qCountTrailingZeroBits(quint32 v)
    \relates <QtAlgorithms>
    \since 5.6
    \overload
 */

/*!
    \fn uint qCountTrailingZeroBits(quint64 v)
    \relates <QtAlgorithms>
    \since 5.6
    \overload
 */

/*!
    \fn uint qCountLeadingZeroBits(quint8 v)
    \relates <QtAlgorithms>
    \since 5.6

    Returns the number of consecutive zero bits in \a v, when searching from the MSB.
    For example, qCountLeadingZeroBits(quint8(1)) returns 7 and
    qCountLeadingZeroBits(quint8(8)) returns 4.
 */

/*!
    \fn uint qCountLeadingZeroBits(quint16 v)
    \relates <QtAlgorithms>
    \since 5.6

    Returns the number of consecutive zero bits in \a v, when searching from the MSB.
    For example, qCountLeadingZeroBits(quint16(1)) returns 15 and
    qCountLeadingZeroBits(quint16(8)) returns 12.
 */

/*!
    \fn uint qCountLeadingZeroBits(quint32 v)
    \relates <QtAlgorithms>
    \since 5.6

    Returns the number of consecutive zero bits in \a v, when searching from the MSB.
    For example, qCountLeadingZeroBits(quint32(1)) returns 31 and
    qCountLeadingZeroBits(quint32(8)) returns 28.
 */

/*!
    \fn uint qCountLeadingZeroBits(quint64 v)
    \relates <QtAlgorithms>
    \since 5.6

    Returns the number of consecutive zero bits in \a v, when searching from the MSB.
    For example, qCountLeadingZeroBits(quint64(1)) returns 63 and
    qCountLeadingZeroBits(quint64(8)) returns 60.
 */