]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/algorithm/doc/is_partitioned.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / algorithm / doc / is_partitioned.qbk
CommitLineData
7c673cae
FG
1[/ File is_partitioned.qbk]
2
3[section:is_partitioned is_partitioned ]
4
5[/license
6Copyright (c) 2010-2012 Marshall Clow
7
8Distributed under the Boost Software License, Version 1.0.
9(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10]
11
12The header file 'is_partitioned.hpp' contains two variants of a single algorithm, `is_partitioned`. The algorithm tests to see if a sequence is partitioned according to a predicate; in other words, all the items in the sequence that satisfy the predicate are at the beginning of the sequence.
13
14The routine `is_partitioned` takes a sequence and a predicate. It returns true if the sequence is partitioned according to the predicate.
15
16`is_partitioned` come in two forms; the first one takes two iterators to define the range. The second form takes a single range parameter, and uses Boost.Range to traverse it.
17
18
19[heading interface]
20
21The function `is_partitioned` returns true if the items in the sequence are separated according to their ability to satisfy the predicate. There are two versions; one takes two iterators, and the other takes a range.
22
23``
24template<typename InputIterator, typename Predicate>
25 bool is_partitioned ( InputIterator first, InputIterator last, Predicate p );
26template<typename Range, typename Predicate>
27 bool is_partitioned ( const Range &r, Predicate p );
28``
29
30[heading Examples]
31
32Given the container `c` containing `{ 0, 1, 2, 3, 14, 15 }`, then
33``
34bool isOdd ( int i ) { return i % 2 == 1; }
35bool lessThan10 ( int i ) { return i < 10; }
36
37is_partitioned ( c, isOdd ) --> false
38is_partitioned ( c, lessThan10 ) --> true
39is_partitioned ( c.begin (), c.end (), lessThan10 ) --> true
40is_partitioned ( c.begin (), c.begin () + 3, lessThan10 ) --> true
41is_partitioned ( c.end (), c.end (), isOdd ) --> true // empty range
42``
43
44[heading Iterator Requirements]
45
46`is_partitioned` works on all iterators except output iterators.
47
48[heading Complexity]
49
50Both of the variants of `is_partitioned` run in ['O(N)] (linear) time; that is, they compare against each element in the list once. If the sequence is found to be not partitioned at any point, the routine will terminate immediately, without examining the rest of the elements.
51
52[heading Exception Safety]
53
54Both of the variants of `is_partitioned` take their parameters by value or const reference, and do not depend upon any global state. Therefore, all the routines in this file provide the strong exception guarantee.
55
56[heading Notes]
57
58* The iterator-based version of the routine `is_partitioned` is also available as part of the C++11 standard.
59
60* `is_partitioned` returns true for empty ranges, no matter what predicate is passed to test against.
61
62[endsect]
63
64[/ File is_partitioned.qbk
65Copyright 2011 Marshall Clow
66Distributed under the Boost Software License, Version 1.0.
67(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
68]
69