mirror of
https://github.com/boostorg/container.git
synced 2026-07-08 05:20:49 +02:00
Add note saying that the algorithm is suboptimal
This commit is contained in:
@@ -27,6 +27,9 @@
|
||||
namespace boost {
|
||||
namespace container {
|
||||
|
||||
//! Note: This version is suboptimal only supports bidirectional iterators,
|
||||
//! as it relies on stable_partition_shift.
|
||||
//!
|
||||
//! Returns \c true if all elements satisfying \c pred appear before
|
||||
//! all elements that do not, i.e. the range [first, last) is
|
||||
//! partitioned with respect to \c pred.
|
||||
|
||||
@@ -34,30 +34,35 @@ template <class SegIter, class Predicate>
|
||||
SegIter segmented_partition_point_dispatch
|
||||
(SegIter first, SegIter last, Predicate pred, segmented_iterator_tag)
|
||||
{
|
||||
typedef segmented_iterator_traits<SegIter> traits;
|
||||
typename traits::segment_iterator scur = traits::segment(first);
|
||||
typename traits::segment_iterator slast = traits::segment(last);
|
||||
typename traits::local_iterator lcur;
|
||||
typedef segmented_iterator_traits<SegIter> traits;
|
||||
typedef typename traits::local_iterator local_iterator;
|
||||
typedef typename traits::segment_iterator segment_iterator;
|
||||
|
||||
segment_iterator scur = traits::segment(first);
|
||||
segment_iterator slast = traits::segment(last);
|
||||
|
||||
if(scur == slast) {
|
||||
lcur = boost::container::segmented_partition_point(traits::local(first), traits::local(last), pred);
|
||||
local_iterator lcur = boost::container::segmented_partition_point(traits::local(first), traits::local(last), pred);
|
||||
if(lcur != traits::local(last))
|
||||
return traits::compose(scur, lcur);
|
||||
}
|
||||
else {
|
||||
lcur = boost::container::segmented_partition_point(traits::local(first), traits::end(scur), pred);
|
||||
if(lcur != traits::end(scur))
|
||||
return traits::compose(scur, lcur);
|
||||
|
||||
for(++scur; scur != slast; ++scur) {
|
||||
lcur = boost::container::segmented_partition_point(traits::begin(scur), traits::end(scur), pred);
|
||||
if(lcur != traits::end(scur))
|
||||
{
|
||||
local_iterator lcur = boost::container::segmented_partition_point(traits::local(first), traits::end(scur), pred);
|
||||
if (lcur != traits::end(scur))
|
||||
return traits::compose(scur, lcur);
|
||||
}
|
||||
|
||||
lcur = boost::container::segmented_partition_point(traits::begin(scur), traits::local(last), pred);
|
||||
if(lcur != traits::local(last))
|
||||
return traits::compose(scur, lcur);
|
||||
for(++scur; scur != slast; ++scur) {
|
||||
local_iterator lcur = boost::container::segmented_partition_point(traits::begin(scur), traits::end(scur), pred);
|
||||
if(lcur != traits::end(scur))
|
||||
return traits::compose(scur, lcur);
|
||||
}
|
||||
{
|
||||
local_iterator lcur = boost::container::segmented_partition_point(traits::begin(scur), traits::local(last), pred);
|
||||
if (lcur != traits::local(last))
|
||||
return traits::compose(scur, lcur);
|
||||
}
|
||||
}
|
||||
return last;
|
||||
}
|
||||
@@ -76,6 +81,9 @@ segmented_partition_point_dispatch
|
||||
|
||||
} // namespace detail_algo
|
||||
|
||||
//! Note: This version is suboptimal only supports bidirectional iterators,
|
||||
//! as it relies on stable_partition_shift.
|
||||
//!
|
||||
//! Finds the partition point in [first, last): the first element
|
||||
//! for which \c pred returns false. The range must be partitioned
|
||||
//! with respect to \c pred.
|
||||
|
||||
@@ -89,13 +89,17 @@ template <class SegIt, class OuterIter, class Composer, class Pred>
|
||||
OuterIter stable_partition_scan(SegIt first, SegIt last, OuterIter result,
|
||||
Composer composer, Pred& pred, segmented_iterator_tag)
|
||||
{
|
||||
typedef segmented_iterator_traits<SegIt> traits;
|
||||
typedef typename traits::local_iterator local_iterator;
|
||||
typedef segmented_iterator_traits<SegIt> traits;
|
||||
typedef typename traits::local_iterator local_iterator;
|
||||
typedef typename traits::segment_iterator segment_iterator;
|
||||
typedef typename segmented_iterator_traits<local_iterator>::is_segmented_iterator is_local_seg_t;
|
||||
|
||||
typedef sp_chained_composer<Composer, traits> inner_composer_t;
|
||||
typename traits::segment_iterator scur = traits::segment(first);
|
||||
typename traits::segment_iterator slast = traits::segment(last);
|
||||
local_iterator lcur = traits::local(first);
|
||||
|
||||
segment_iterator scur = traits::segment(first);
|
||||
segment_iterator slast = traits::segment(last);
|
||||
local_iterator lcur = traits::local(first);
|
||||
|
||||
if(scur == slast) {
|
||||
inner_composer_t inner(composer, scur);
|
||||
result = stable_partition_scan(lcur, traits::local(last), result, inner, pred, is_local_seg_t());
|
||||
@@ -133,6 +137,9 @@ BidirIt segmented_stable_partition_dispatch (BidirIt first, BidirIt last, Pred p
|
||||
|
||||
} // namespace detail_algo
|
||||
|
||||
//! Note: This version is suboptimal only supports bidirectional iterators,
|
||||
//! as it relies on stable_partition_shift.
|
||||
//!
|
||||
//! Reorders elements in [first, last) so that elements satisfying
|
||||
//! \c pred come before those that do not, preserving relative order
|
||||
//! within each group. Returns an iterator to the partition point.
|
||||
|
||||
Reference in New Issue
Block a user