An augmented sequence might be useful to add:
template <class entry>
struct aug_seq_full_entry : entry {
using val_t = bool; // not used
using key_t = typename entry::key_t;
using aug_t = typename entry::aug_t;
using entry_t = key_t;
static bool comp(const key_t& a, const key_t& b) { return true; }
static inline key_t get_key(const entry_t& e) { return e; }
static inline val_t get_val(const entry_t& e) { return 0; }
static inline void set_val(entry_t& e, const val_t& v) {}
};
template<class _Entry, class Balance=weight_balanced_tree>
using aug_seq =
aug_map_< aug_set_full_entry<_Entry>,
typename Balance::template
balance<aug_node<typename Balance::data, aug_set_full_entry<_Entry>>>>;
void test_aug_seq()
{
struct piece_entry
{
using key_t = string_view;
using aug_t = size_t;
static aug_t get_empty() { return 0; }
static aug_t from_entry(key_t k) { return k.size(); }
static aug_t combine(aug_t a, aug_t b) { return a + b; }
};
using piece_seq = aug_seq<piece_entry>;
using strv = piece_seq; //pam_seq<string_view>;
strv x1;
strv v1 = strv(string_view("hello, world"));
strv v2 = strv(string_view("; wassup"));
strv v3 = strv::join2(v1, v2);
strv::foreach_seq(v3, [&](auto x) {
cout << "- " << x << "\n";
});
cout << "\n total=" << v3.aug_val() << "\n";
}
An augmented sequence might be useful to add: