Back to Arangodb

upper_bound

3rdParty/boost/1.78.0/libs/mpl/doc/refmanual/upper-bound.html

3.12.9.13.3 KB
Original Source

| Prev Next | Back Along | Up Home | Full TOC | Front Page / Algorithms / Querying Algorithms / upper_bound |

upper_bound

Synopsis

template<
      typename Sequence
    , typename T
    , typename Pred =[less](./less.html)<[\_1](./placeholders.html),[\_2](./placeholders.html)>
    >
struct[upper\_bound](./upper-bound.html){
    typedef_unspecified_type;
};

Description

Returns the last position in the sorted Sequence where T could be inserted without violating the ordering.

#include <[boost/mpl/upper\_bound.hpp](../../../../boost/mpl/upper_bound.hpp)>

Parameters

ParameterRequirementDescription
SequenceForward SequenceA sorted sequence to search in.
TAny typeA type to search a position for.
PredBinary Lambda ExpressionA search criteria.

Expression semantics

For any sorted Forward Sequence s, binary Lambda Expression pred, and arbitrary type x:

typedef[upper\_bound](./upper-bound.html)< s,x,pred >::type i;

| Return type: |

Forward Iterator

| | Semantics: |

i is the furthermost iterator in [begin<s>::type, end<s>::type) such that, for every iterator j in [begin<s>::type, i),

[apply](./apply.html)< pred, x,[deref](./deref.html)<j>::type >::type::value == false

|

Complexity

The number of comparisons is logarithmic: at most log2( size<s>::value ) + 1. If s is a Random Access Sequence then the number of steps through the range is also logarithmic; otherwise, the number of steps is proportional to size<s>::value.

Example

typedef[vector\_c](./vector-c.html)<int,1,2,3,3,3,5,8> numbers;
typedef[upper\_bound](./upper-bound.html)< numbers,[int\_](./int.html)<3> >::type iter;[BOOST\_MPL\_ASSERT\_RELATION](./assert-relation.html)(
      ([distance](./distance.html)<[begin](./begin.html)<numbers>::type,iter >::value), ==, 5
    );[BOOST\_MPL\_ASSERT\_RELATION](./assert-relation.html)([deref](./deref.html)<iter>::type::value, ==, 5 );

See also

Querying Algorithms, lower_bound, find, find_if, min_element

| Prev Next | Back Along | Up Home | Full TOC |

Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |