102namespace lis_detail {
103template <
typename T,
class Compare>
106 size_t lo = 0, hi =
tails.size();
109 const size_t mid = lo + (hi - lo) / 2;
118template <
typename T,
class Compare>
121 size_t lo = 0, hi =
tails.size();
124 const size_t mid = lo + (hi - lo) / 2;
148template <
typename T,
class Compare = Aleph::less<T>>
150 Compare
cmp = Compare())
152 const size_t n = seq.
size();
166 for (
size_t i = 0; i < n; ++i)
170 if (lo ==
tails.size())
172 tails.append(seq[i]);
181 parent(i) = lo > 0 ?
tail_idx[lo - 1] : std::numeric_limits<size_t>::max();
190 result(
k - 1) = seq[idx];
211template <
typename T,
class Compare = Aleph::less<T>>
214 const size_t n = seq.
size();
221 for (
size_t i = 0; i < n; ++i)
225 if (lo ==
tails.size())
226 tails.append(seq[i]);
248template <
typename T,
class Compare = Aleph::less<T>>
250 Compare
cmp = Compare())
252 const size_t n = seq.
size();
263 for (
size_t i = 0; i < n; ++i)
267 if (pos ==
tails.size())
269 tails.append(seq[i]);
278 parent(i) = pos > 0 ?
tail_idx[pos - 1] : std::numeric_limits<size_t>::max();
281 const size_t len =
tails.size();
284 for (
size_t k = len;
k > 0; --
k)
286 result(
k - 1) = seq[idx];
Standard functor implementations and comparison objects.
size_t size_t int32_t value
Simple dynamic array with automatic resizing and functional operations.
static Array create(size_t n)
Create an array with n logical elements.
constexpr size_t size() const noexcept
Return the number of elements stored in the stack.
void reserve(size_t cap)
Reserves cap cells into the array.
int cmp(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
size_t lower_bound_pos(const Array< T > &tails, const T &value, Compare cmp)
size_t upper_bound_pos(const Array< T > &tails, const T &value, Compare cmp)
Main namespace for Aleph-w library functions.
LIS_Result< T > longest_nondecreasing_subsequence(const Array< T > &seq, Compare cmp=Compare())
Compute the Longest Non-Decreasing Subsequence.
std::decay_t< typename HeadC::Item_Type > T
LIS_Result< T > longest_increasing_subsequence(const Array< T > &seq, Compare cmp=Compare())
Compute the Longest Increasing Subsequence (strictly increasing).
size_t lis_length(const Array< T > &seq, Compare cmp=Compare())
Compute only the length of the LIS (no reconstruction).
Result of a Longest Increasing Subsequence computation.
Array< T > subsequence
One optimal subsequence found.
size_t length
Length of the resulting subsequence.
Dynamic array container with automatic resizing.