8#include <pixie/permutations/sequence.h>
36template <
class T = std::uint64_t,
37 class Compare = std::less<>,
39 std::size_t StorageBits = 2048,
40 std::size_t Fanout = 8,
42 std::size_t ChunkBytes = 4096>
62 : compare_(std::move(compare)) {}
84 template <std::ranges::input_range Range>
86 constructible_from<T, std::ranges::range_rvalue_reference_t<Range>>
88 Compare compare = {}) {
90 auto it = std::ranges::begin(range);
91 const auto end = std::ranges::end(range);
92 for (; it != end; ++it) {
93 result.insert(T(std::ranges::iter_move(it)));
101 bool empty() const noexcept {
return sequence_.empty(); }
111 return sequence_[position];
124 return sequence_.lower_bound([&](
const T& v) {
return !compare_(v, key); });
137 return sequence_.lower_bound([&](
const T& v) {
return compare_(key, v); });
152 sequence_.insert_at(position, std::move(value));
164 const size_type nested = sequence_.memory_usage_bytes() -
sizeof(sequence_);
165 return nested > std::numeric_limits<size_type>::max() -
sizeof(*this)
166 ? std::numeric_limits<size_type>::max()
167 :
sizeof(*this) + nested;
172 [[no_unique_address]] Compare compare_;
Owning, move-only tree sequence with immutable element reads.
Definition sequence.h:74
typename Traits::const_reference const_reference
Definition sequence.h:108
Duplicate-preserving sorted sequence backed by PermutableSequence.
Definition sorted_sequence.h:43
SortedPermutableSequence & operator=(const SortedPermutableSequence &)=delete
Exclusive ownership disallows copy assignment.
T value_type
Stored value type.
Definition sorted_sequence.h:49
static SortedPermutableSequence from_range(Range &&range, Compare compare={})
Build a sorted owner by consuming values one at a time.
Definition sorted_sequence.h:87
bool empty() const noexcept
Return whether this owner is empty.
Definition sorted_sequence.h:101
SortedPermutableSequence(const SortedPermutableSequence &)=delete
Exclusive ownership disallows copying.
std::size_t size_type
Count and position type.
Definition sorted_sequence.h:53
SortedPermutableSequence(Compare compare={})
Construct empty with a comparator.
Definition sorted_sequence.h:61
SortedPermutableSequence & operator=(SortedPermutableSequence &&)=default
Replace ownership and comparator state by move.
typename sequence_type::const_reference const_reference
Immutable indexed result inherited from the sequence policy.
Definition sorted_sequence.h:51
SortedPermutableSequence(SortedPermutableSequence &&)=default
Move ownership and comparator state.
PermutableSequence< T, Storage, StorageBits, Fanout, Layout, ChunkBytes > sequence_type
Underlying owning sequence type.
Definition sorted_sequence.h:46
size_type memory_usage_bytes() const noexcept
Return explicit requested bytes owned by this wrapper.
Definition sorted_sequence.h:163
size_type lower_bound_index(const Key &key) const
Return the first position whose value is not ordered before key.
Definition sorted_sequence.h:123
size_type size() const noexcept
Return the number of sorted values.
Definition sorted_sequence.h:99
size_type upper_bound_index(const Key &key) const
Return the first position whose value is ordered after key.
Definition sorted_sequence.h:136
const_reference operator[](size_type position) const
Read one sorted zero-based value.
Definition sorted_sequence.h:110
size_type insert(T value)
Insert a value before existing equivalent values.
Definition sorted_sequence.h:150
ElementStorage
Compile-time element storage selection.
Definition permutable_sequence.h:23
LengthLayout
Representation of tree child lengths.
Definition sequence_options.h:14