GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::experimental::ranges::adjacent_find(3) C++ Standard Libary std::experimental::ranges::adjacent_find(3)

std::experimental::ranges::adjacent_find - std::experimental::ranges::adjacent_find


Defined in header <experimental/ranges/algorithm>
template< ForwardIterator I, Sentinel<I> S, class Proj =
ranges::identity,


IndirectRelation<projected<I, Proj>> Pred = ranges::equal_to<> > (1) (ranges TS)


I adjacent_find(I first, S last, Pred pred = Pred{}, Proj proj =
Proj{});
template< ForwardRange R, class Proj = ranges::identity,


IndirectRelation<projected<ranges::iterator_t<R>, Proj>> Pred =
ranges::equal_to<> > (2) (ranges TS)


ranges::safe_iterator_t<R> adjacent_find(R&& r, Pred pred = Pred{},
Proj proj = Proj{});


1) Searches the range [first, last) for two consecutive identical elements. Elements
are compared using pred after being projected with proj.
2) Same as (1), but uses r as the source range, as if using ranges::begin(r) as
first and ranges::end(r) as last.


Notwithstanding the declarations depicted above, the actual number and order of
template parameters for algorithm declarations is unspecified. Thus, if explicit
template arguments are used when calling an algorithm, the program is probably
non-portable.


first, last - the range of elements to examine
r - the range of elements to examine
pred - predicate to use to compare the projected elements
proj - projection to apply to the elements


An iterator to the first of the first pair of identical elements, that is, the first
iterator i such that both i and i + 1 are in the range [first, last) and
ranges::invoke(pred, ranges::invoke(proj, *i), ranges::invoke(proj, *(i + 1))) !=
false.


If no such elements are found, an iterator that compares equal to last is returned.


If the range is nonempty, exactly min((result-first)+1, (last-first)-1) applications
of the predicate where result is the return value, and at most twice as many
applications of the projection.


template< ForwardIterator I, Sentinel<I> S, class Proj = ranges::identity,
IndirectRelation<projected<I, Proj>> Pred = ranges::equal_to<> >
I adjacent_find(I first, S last, Pred pred = Pred{}, Proj proj = Proj{})
{
if (first == last) {
return first;
}
I next = first;
++next;
while(next != last) {
if (ranges::invoke(pred, ranges::invoke(proj, *first),
ranges::invoke(proj, *next))) {
return first;
}
++next;
++first;
}
return next;
}


This section is incomplete
Reason: no example


finds the first two adjacent items that are equal (or satisfy a given
adjacent_find predicate)
(function template)
unique removes consecutive duplicate elements in a range
(function template)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.