]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/algorithm/doc/is_partitioned.qbk
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / algorithm / doc / is_partitioned.qbk
1 [/ File is_partitioned.qbk]
2
3 [section:is_partitioned is_partitioned ]
4
5 [/license
6 Copyright (c) 2010-2012 Marshall Clow
7
8 Distributed 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
12 The 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
14 The 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
21 The 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 ``
24 template<typename InputIterator, typename Predicate>
25 bool is_partitioned ( InputIterator first, InputIterator last, Predicate p );
26 template<typename Range, typename Predicate>
27 bool is_partitioned ( const Range &r, Predicate p );
28 ``
29
30 [heading Examples]
31
32 Given the container `c` containing `{ 0, 1, 2, 3, 14, 15 }`, then
33 ``
34 bool isOdd ( int i ) { return i % 2 == 1; }
35 bool lessThan10 ( int i ) { return i < 10; }
36
37 is_partitioned ( c, isOdd ) --> false
38 is_partitioned ( c, lessThan10 ) --> true
39 is_partitioned ( c.begin (), c.end (), lessThan10 ) --> true
40 is_partitioned ( c.begin (), c.begin () + 3, lessThan10 ) --> true
41 is_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
50 Both 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
54 Both 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
65 Copyright 2011 Marshall Clow
66 Distributed 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