76 using size_type = label_t;
77 using difference_type = std::ptrdiff_t;
79 using const_reference =
Semantic const&;
81 using const_pointer =
Semantic const*;
83 using const_iterator =
Semantic const*;
84 using reverse_iterator = std::reverse_iterator<iterator>;
85 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
89 static constexpr std::size_t N_H = 1 + (N - 1) / 2;
94 std::unique_ptr<Semantic[]> semantics;
101 for (offset_t i{}; i != N; ++i) {
102 set(i, other.begin(i), other.end(i));
112 semantics = std::move(other.semantics);
119 for (offset_t i{}; i != N; ++i) {
120 set(i, other.begin(i), other.end(i));
131 [[nodiscard]]
static constexpr std::size_t semanticSize() {
return N; }
133 [[nodiscard]] size_type semanticAllocSize()
const
135 return empty() ? 0 : semanticSize() + N_H;
145 semantic::resizeLazy<N>(semantics, parent.size(
index));
146 auto first = parent.begin(
index);
147 auto last = parent.end(
index);
148 for (offset_t i = 0; N != i; ++i) {
149 std::copy(first, last, begin(i));
158 [[nodiscard]]
bool isPrunable()
const
160 auto first = cbegin(0);
162 for (offset_t i = 1; N != i; ++i) {
163 if (!std::equal(first, last, cbegin(i), cend(i))) {
188 iterator begin()
noexcept {
return semantic::begin<N>(semantics); }
190 const_iterator begin()
const noexcept {
return semantic::begin<N>(semantics); }
192 const_iterator cbegin()
const noexcept {
return begin(); }
194 iterator end()
noexcept {
return semantic::end<N>(semantics); }
196 const_iterator end()
const noexcept {
return semantic::end<N>(semantics); }
198 const_iterator cend()
const noexcept {
return end(); }
204 reverse_iterator rbegin()
noexcept {
return std::make_reverse_iterator(end()); }
206 const_reverse_iterator rbegin()
const noexcept
208 return std::make_reverse_iterator(end());
211 const_reverse_iterator crbegin()
const noexcept {
return rbegin(); }
213 reverse_iterator rend()
noexcept {
return std::make_reverse_iterator(begin()); }
215 const_reverse_iterator rend()
const noexcept
217 return std::make_reverse_iterator(begin());
220 const_reverse_iterator crend()
const noexcept {
return rend(); }
228 return semantic::begin<N>(semantics,
index);
231 const_iterator begin(offset_t
const index)
const noexcept
233 return semantic::begin<N>(semantics,
index);
236 const_iterator cbegin(offset_t
const index)
const noexcept {
return begin(
index); }
240 return semantic::end<N>(semantics,
index);
243 const_iterator end(offset_t
const index)
const noexcept
245 return semantic::end<N>(semantics,
index);
248 const_iterator cend(offset_t
const index)
const noexcept {
return end(
index); }
254 reverse_iterator rbegin(offset_t
const index)
noexcept
256 return std::make_reverse_iterator(end(
index));
259 const_reverse_iterator rbegin(offset_t
const index)
const noexcept
261 return std::make_reverse_iterator(end(
index));
264 const_reverse_iterator crbegin(offset_t
const index)
const noexcept
266 return rbegin(
index);
269 reverse_iterator rend(offset_t
const index)
noexcept
271 return std::make_reverse_iterator(begin(
index));
274 const_reverse_iterator rend(offset_t
const index)
const noexcept
276 return std::make_reverse_iterator(begin(
index));
279 const_reverse_iterator crend(offset_t
const index)
const noexcept
288 [[nodiscard]]
bool empty()
const noexcept {
return semantic::empty<N>(semantics); }
290 [[nodiscard]]
bool empty(offset_t
const index)
const
292 return semantic::empty<N>(semantics,
index);
299 [[nodiscard]] size_type size()
const {
return semantic::size<N>(semantics); }
301 [[nodiscard]] size_type size(offset_t
const index)
const
303 return semantic::size<N>(semantics,
index);
306 [[nodiscard]] std::array<size_type, N> sizes()
const
308 return semantic::sizes<N>(semantics);
316 void resizeLazy(std::array<size_type, N>
const& new_sizes)
318 semantic::resizeLazy<N>(semantics, new_sizes);
325 [[nodiscard]] std::size_t offset(offset_t
const index)
const
327 return semantic::offset<N>(semantics,
index);
334 void clear()
noexcept { semantic::clear<N>(semantics); }
336 void clear(offset_t
const index) { semantic::clear<N>(semantics,
index); }
344 semantic::resizeLazy<N>(this->semantics, semantics.size());
345 auto first = std::begin(semantics);
346 auto last = std::end(semantics);
347 for (offset_t i = 0; N != i; ++i) {
348 std::copy(first, last, begin(i));
354 semantic::resize<N>(this->semantics,
index, semantics.size());
355 std::copy(std::begin(semantics), std::end(semantics), begin(
index));
358 template <
class InputIt>
359 void set(offset_t
index, InputIt first, InputIt last)
387 void insert(label_t label, value_t value)
389 semantic::insert<N>(semantics, label, value);
392 void insert(offset_t
index, label_t label, value_t value)
394 semantic::insert<N>(semantics,
index, label, value);
397 template <
class InputIt,
398 typename = std::enable_if_t<std::is_base_of_v<
399 std::input_iterator_tag,
400 typename std::iterator_traits<InputIt>::iterator_category>>>
401 void insert(InputIt first, InputIt last)
403 semantic::insert<N>(semantics, first, last);
406 template <
class InputIt,
407 typename = std::enable_if_t<std::is_base_of_v<
408 std::input_iterator_tag,
409 typename std::iterator_traits<InputIt>::iterator_category>>>
410 void insert(offset_t
index, InputIt first, InputIt last)
412 semantic::insert<N>(semantics,
index, first, last);
419 void insertOrAssign(label_t label, value_t value)
421 semantic::insertOrAssign<N>(semantics, label, value);
424 void insertOrAssign(offset_t
index, label_t label, value_t value)
426 semantic::insertOrAssign<N>(semantics,
index, label, value);
429 template <
class UnaryFunction,
430 class = std::enable_if_t<std::is_invocable<UnaryFunction, Semantic>::value>>
431 void insertOrAssign(label_t label, UnaryFunction f)
433 semantic::insertOrAssign<N>(semantics, label, f);
436 template <
class UnaryFunction,
437 class = std::enable_if_t<std::is_invocable<UnaryFunction, Semantic>::value>>
438 void insertOrAssign(offset_t
index, label_t label, UnaryFunction f)
440 semantic::insertOrAssign<N>(semantics,
index, label, f);
444 template <
class InputIt,
445 typename = std::enable_if_t<std::is_base_of_v<
446 std::input_iterator_tag,
447 typename std::iterator_traits<InputIt>::iterator_category>>>
448 void insertOrAssign(InputIt first, InputIt last)
450 semantic::insertOrAssign<N>(semantics, first, last);
454 template <
class InputIt,
455 typename = std::enable_if_t<std::is_base_of_v<
456 std::input_iterator_tag,
457 typename std::iterator_traits<InputIt>::iterator_category>>>
458 void insertOrAssign(offset_t
index, InputIt first, InputIt last)
460 semantic::insertOrAssign<N>(semantics,
index, first, last);
465 template <
class InputIt,
class UnaryFunction,
466 class = std::enable_if_t<std::is_invocable<UnaryFunction, Semantic>::value>,
467 typename = std::enable_if_t<std::is_base_of_v<
468 std::input_iterator_tag,
469 typename std::iterator_traits<InputIt>::iterator_category>>>
470 void insertOrAssign(InputIt first, InputIt last, UnaryFunction f)
472 semantic::insertOrAssign<N>(semantics, first, last, f);
476 template <
class InputIt,
class UnaryFunction,
477 class = std::enable_if_t<std::is_invocable<UnaryFunction, Semantic>::value>,
478 typename = std::enable_if_t<std::is_base_of_v<
479 std::input_iterator_tag,
480 typename std::iterator_traits<InputIt>::iterator_category>>>
481 void insertOrAssign(offset_t
index, InputIt first, InputIt last, UnaryFunction f)
483 semantic::insertOrAssign<N>(semantics,
index, first, last, f);
491 void assign(SemanticRange range, value_t value)
493 assign(semantics, SemanticRangeSet{range}, value);
496 void assign(SemanticRangeSet
const& ranges, value_t value)
498 semantic::assign<N>(semantics, ranges, value);
501 template <
class UnaryFunction,
502 class = std::enable_if_t<std::is_invocable<UnaryFunction, Semantic>::value>>
503 void assign(SemanticRange range, UnaryFunction f)
505 assign(SemanticRangeSet{range}, f);
508 template <
class UnaryFunction,
509 class = std::enable_if_t<std::is_invocable<UnaryFunction, Semantic>::value>>
510 void assign(SemanticRangeSet
const& ranges, UnaryFunction f)
512 semantic::assign<N>(semantics, ranges, f);
515 template <
class UnaryPredicate,
class UnaryFunction,
516 class = std::enable_if_t<std::is_invocable<UnaryFunction, Semantic>::value>,
517 class = std::enable_if_t<
std::is_invocable<UnaryPredicate, Semantic>::value>>
518 void assign(UnaryPredicate p, UnaryFunction f)
520 semantic::assign<N>(semantics, p, f);
524 void assign(offset_t
const index, SemanticRange range, value_t value)
526 assign(
index, SemanticRangeSet{range}, value);
529 void assign(offset_t
const index, SemanticRangeSet
const& ranges, value_t value)
531 semantic::assign<N>(semantics,
index, ranges, value);
534 template <
class UnaryFunction,
535 class = std::enable_if_t<std::is_invocable<UnaryFunction, Semantic>::value>>
536 void assign(offset_t
const index, SemanticRangeSet
const& ranges, UnaryFunction f)
538 semantic::assign<N>(semantics,
index, ranges, f);
541 template <
class UnaryFunction,
542 class = std::enable_if_t<std::is_invocable<UnaryFunction, Semantic>::value>>
543 void assign(offset_t
const index, SemanticRange range, UnaryFunction f)
545 assign(
index, SemanticRangeSet{range}, f);
548 template <
class UnaryPredicate,
class UnaryFunction,
549 class = std::enable_if_t<std::is_invocable<UnaryFunction, Semantic>::value>,
550 class = std::enable_if_t<
std::is_invocable<UnaryPredicate, Semantic>::value>>
551 void assign(offset_t const index, UnaryPredicate p, UnaryFunction f)
553 semantic::assign<N>(semantics,
index, p, f);
562 return semantic::erase<N>(semantics, pos, std::next(pos));
567 return semantic::erase<N>(semantics, pos, std::next(pos));
571 iterator erase(const_iterator first, const_iterator last)
573 return semantic::erase<N>(semantics, first, last);
576 size_type erase(label_t label) {
return semantic::erase<N>(semantics, label); }
578 size_type erase(SemanticRangeSet
const& ranges)
580 return semantic::erase<N>(semantics, ranges);
583 size_type erase(SemanticRange range) {
return erase(SemanticRangeSet{range}); }
585 size_type erase(offset_t
const index, label_t label)
587 return semantic::erase<N>(semantics,
index, label);
590 size_type erase(offset_t
const index, SemanticRangeSet
const& ranges)
592 return semantic::erase<N>(semantics,
index, ranges);
595 size_type erase(offset_t
const index, SemanticRange range)
597 return erase(
index, SemanticRangeSet{range});
604 template <
class UnaryPredicate,
605 class = std::enable_if_t<std::is_invocable<UnaryPredicate, Semantic>::value>>
606 size_type eraseIf(UnaryPredicate p)
608 return semantic::eraseIf<N>(semantics, p);
611 template <
class UnaryPredicate,
612 class = std::enable_if_t<std::is_invocable<UnaryPredicate, Semantic>::value>>
613 size_type eraseIf(SemanticRangeSet
const& ranges, UnaryPredicate p)
615 return semantic::eraseIf<N>(semantics, ranges, p);
618 template <
class UnaryPredicate,
619 class = std::enable_if_t<std::is_invocable<UnaryPredicate, Semantic>::value>>
620 size_type eraseIf(SemanticRange range, UnaryPredicate p)
622 return eraseIf(SemanticRangeSet{range}, p);
625 template <
class UnaryPredicate,
626 class = std::enable_if_t<std::is_invocable<UnaryPredicate, Semantic>::value>>
627 size_type eraseIf(offset_t
const index, UnaryPredicate p)
629 return semantic::eraseIf<N>(semantics,
index, p);
632 template <
class UnaryPredicate,
633 class = std::enable_if_t<std::is_invocable<UnaryPredicate, Semantic>::value>>
634 size_type eraseIf(offset_t
const index, SemanticRangeSet
const& ranges,
637 return semantic::eraseIf<N>(semantics,
index, ranges, p);
640 template <
class UnaryPredicate,
641 class = std::enable_if_t<std::is_invocable<UnaryPredicate, Semantic>::value>>
642 size_type eraseIf(offset_t
const index, SemanticRange range, UnaryPredicate p)
644 return eraseIf(
index, SemanticRangeSet{range}, p);
651 std::optional<Semantic> at(offset_t
index, label_t label)
const
653 return semantic::at<N>(semantics,
index, label);
660 std::optional<value_t> value(offset_t
index, label_t label)
const
662 return semantic::value<N>(semantics,
index, label);
669 size_type count(offset_t
index, label_t label)
const
671 return semantic::count<N>(semantics,
index, label);
678 const_iterator find(offset_t
index, label_t label)
const
680 return semantic::find<N>(semantics,
index, label);
687 bool contains(offset_t
index, label_t label)
const
689 return semantic::contains<N>(semantics,
index, label);
696 std::pair<const_iterator, const_iterator> equal_range(offset_t
index,
699 return semantic::equal_range<N>(semantics,
index, label);
706 [[nodiscard]] const_iterator lower_bound(offset_t
index, label_t label)
const
708 return semantic::lower_bound<N>(semantics,
index, label);
715 [[nodiscard]] const_iterator upper_bound(offset_t
index, label_t label)
const
717 return semantic::upper_bound<N>(semantics,
index, label);
724 [[nodiscard]]
bool all(offset_t
index, SemanticRange range)
const
726 return semantic::all<N>(semantics,
index, range);
729 [[nodiscard]]
bool all(offset_t
index, SemanticRangeSet
const& ranges)
const
731 return semantic::all<N>(semantics,
index, ranges);
734 template <
class UnaryPredicate>
735 [[nodiscard]]
bool all(offset_t
index, UnaryPredicate p)
const
737 return semantic::all<N>(semantics,
index, p);
740 template <
class UnaryPredicate>
741 [[nodiscard]]
bool all(offset_t
index, SemanticRange range, UnaryPredicate p)
const
743 return semantic::all<N>(semantics,
index, range, p);
746 template <
class UnaryPredicate>
747 [[nodiscard]]
bool all(offset_t
index, SemanticRangeSet
const& ranges,
748 UnaryPredicate p)
const
750 return semantic::all<N>(semantics,
index, ranges, p);
757 [[nodiscard]]
bool any(offset_t
index, SemanticRange range)
const
759 return semantic::any<N>(semantics,
index, range);
762 [[nodiscard]]
bool any(offset_t
index, SemanticRangeSet
const& ranges)
const
764 return semantic::any<N>(semantics,
index, ranges);
767 template <
class UnaryPredicate>
768 [[nodiscard]]
bool any(offset_t
index, UnaryPredicate p)
const
770 return semantic::any<N>(semantics,
index, p);
773 template <
class UnaryPredicate>
774 [[nodiscard]]
bool any(offset_t
index, SemanticRange range, UnaryPredicate p)
const
776 return semantic::any<N>(semantics,
index, range, p);
779 template <
class UnaryPredicate>
780 [[nodiscard]]
bool any(offset_t
index, SemanticRangeSet
const& ranges,
781 UnaryPredicate p)
const
783 return semantic::any<N>(semantics,
index, ranges, p);
790 [[nodiscard]]
bool none(offset_t
index, SemanticRange range)
const
792 return semantic::none<N>(semantics,
index, range);
795 [[nodiscard]]
bool none(offset_t
index, SemanticRangeSet
const& ranges)
const
797 return semantic::none<N>(semantics,
index, ranges);
800 template <
class UnaryPredicate>
801 [[nodiscard]]
bool none(offset_t
index, UnaryPredicate p)
const
803 return semantic::none<N>(semantics,
index, p);
806 template <
class UnaryPredicate>
807 [[nodiscard]]
bool none(offset_t
index, SemanticRange range, UnaryPredicate p)
const
809 return semantic::none<N>(semantics,
index, range, p);
812 template <
class UnaryPredicate>
813 [[nodiscard]]
bool none(offset_t
index, SemanticRangeSet
const& ranges,
814 UnaryPredicate p)
const
816 return semantic::none<N>(semantics,
index, ranges, p);
819 std::string toString()
const {
return semantic::toString<N>(semantics); }
820 std::string toString(offset_t
index)
const
822 return semantic::toString<N>(semantics,
index);
829 [[nodiscard]] std::size_t memoryUsage()
const
831 if (semantic::empty<N>(semantics)) {
834 auto sizes = semantic::sizes<N>(semantics);
835 auto s = std::accumulate(sizes.begin(), sizes.end(), N_H);
854 in.read(&s,
sizeof(s));
857 std::array<size_type, N> sizes{};
863 in.read(semantics.get(), memoryUsage());
876 auto cur_sizes = sizes();
877 auto new_sizes = temp.sizes();
878 for (std::size_t i{}; N != i; ++i) {
879 new_sizes[i] = rf[i] ? new_sizes[i] : cur_sizes[i];
882 resizeLazy(new_sizes);
884 for (std::size_t i{}; N != i; ++i) {
886 std::copy(temp.begin(i), temp.end(i), begin(i));
894 in.read(&s,
sizeof(s));
895 semantic::resize<N>(semantics, pos, s);
897 in.read(semantic::begin<N>(semantics, pos), memoryUsage(pos));
904 out.write(&s,
sizeof(s));
906 out.write(semantics.get(), memoryUsage());
917 std::uint64_t s = size(
index);
918 out.write(&s,
sizeof(s));
932 using size_type = label_t;
933 using difference_type = std::ptrdiff_t;
935 using const_reference =
Semantic const&;
937 using const_pointer =
Semantic const*;
939 using const_iterator =
Semantic const*;
940 using reverse_iterator = std::reverse_iterator<iterator>;
941 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
959 template <
class InputIt>
980 std::copy(std::begin(rhs), std::end(rhs), begin());
997 [[nodiscard]] const_pointer data()
const {
return empty() ? nullptr : data_.get() + 1; }
1003 iterator begin()
noexcept {
return empty() ? nullptr : data_.get() + 1; }
1005 const_iterator begin()
const noexcept {
return empty() ? nullptr : data_.get() + 1; }
1007 const_iterator cbegin()
const noexcept {
return begin(); }
1009 iterator end()
noexcept {
return empty() ? nullptr : data_.get() + allocSize(); }
1011 const_iterator end()
const noexcept
1013 return empty() ? nullptr : data_.get() + allocSize();
1016 const_iterator cend()
const noexcept {
return end(); }
1022 reverse_iterator rbegin()
noexcept {
return std::make_reverse_iterator(end()); }
1024 const_reverse_iterator rbegin()
const noexcept
1026 return std::make_reverse_iterator(end());
1029 const_reverse_iterator crbegin()
const noexcept {
return rbegin(); }
1031 reverse_iterator rend()
noexcept {
return std::make_reverse_iterator(begin()); }
1033 const_reverse_iterator rend()
const noexcept
1035 return std::make_reverse_iterator(begin());
1038 const_reverse_iterator crend()
const noexcept {
return rend(); }
1044 [[nodiscard]]
bool empty()
const noexcept {
return nullptr == data_; }
1050 [[nodiscard]] size_type size()
const {
return empty() ? 0 : data_[0].label; }
1052 [[nodiscard]]
static constexpr size_type maxSize()
noexcept
1054 return std::numeric_limits<label_t>::max();
1057 [[nodiscard]] size_type allocSize()
const {
return empty() ? 0 : size() + 1; }
1063 [[nodiscard]] std::optional<Semantic> at(label_t label)
const
1065 return semantic::at<1>(data_, 0, label);
1072 [[nodiscard]] std::optional<value_t> value(label_t label)
const
1074 return semantic::value<1>(data_, 0, label);
1081 [[nodiscard]] size_type count(label_t label)
const
1083 return semantic::count<1>(data_, 0, label);
1090 [[nodiscard]]
iterator find(label_t label)
1092 return semantic::find<1>(data_, 0, label);
1095 [[nodiscard]] const_iterator find(label_t label)
const
1097 return semantic::find<1>(data_, 0, label);
1104 [[nodiscard]]
bool contains(label_t label)
const
1106 return semantic::contains<1>(data_, 0, label);
1113 [[nodiscard]] std::pair<iterator, iterator> equal_range(label_t label)
1115 return semantic::equal_range<1>(data_, 0, label);
1118 [[nodiscard]] std::pair<const_iterator, const_iterator> equal_range(label_t label)
const
1120 return semantic::equal_range<1>(data_, 0, label);
1127 [[nodiscard]]
iterator lower_bound(label_t label)
1129 return semantic::lower_bound<1>(data_, 0, label);
1132 [[nodiscard]] const_iterator lower_bound(label_t label)
const
1134 return semantic::lower_bound<1>(data_, 0, label);
1141 [[nodiscard]]
iterator upper_bound(label_t label)
1143 return semantic::upper_bound<1>(data_, 0, label);
1146 [[nodiscard]] const_iterator upper_bound(label_t label)
const
1148 return semantic::upper_bound<1>(data_, 0, label);
1155 [[nodiscard]]
bool all(SemanticRange range)
const
1157 return all(SemanticRangeSet(range));
1160 [[nodiscard]]
bool all(SemanticRangeSet
const& ranges)
const
1162 return semantic::all<1>(data_, 0, ranges);
1165 template <
class UnaryPredicate>
1166 [[nodiscard]]
bool all(UnaryPredicate p)
const
1168 return semantic::all<1>(data_, 0, p);
1171 template <
class UnaryPredicate>
1172 [[nodiscard]]
bool all(SemanticRange range, UnaryPredicate p)
const
1174 return all(SemanticRangeSet(range), p);
1177 template <
class UnaryPredicate>
1178 [[nodiscard]]
bool all(SemanticRangeSet
const& ranges, UnaryPredicate p)
const
1180 return semantic::all<1>(data_, 0, ranges, p);
1187 [[nodiscard]]
bool any(SemanticRange range)
const
1189 return any(SemanticRangeSet(range));
1192 [[nodiscard]]
bool any(SemanticRangeSet
const& ranges)
const
1194 return semantic::any<1>(data_, 0, ranges);
1197 template <
class UnaryPredicate>
1198 [[nodiscard]]
bool any(UnaryPredicate p)
const
1200 return semantic::any<1>(data_, 0, p);
1203 template <
class UnaryPredicate>
1204 [[nodiscard]]
bool any(SemanticRange range, UnaryPredicate p)
const
1206 return any(SemanticRangeSet(range), p);
1209 template <
class UnaryPredicate>
1210 [[nodiscard]]
bool any(SemanticRangeSet
const& ranges, UnaryPredicate p)
const
1212 return semantic::any<1>(data_, 0, ranges, p);
1219 [[nodiscard]]
bool none(SemanticRange range)
const
1221 return none(SemanticRangeSet(range));
1224 [[nodiscard]]
bool none(SemanticRangeSet
const& ranges)
const
1226 return semantic::none<1>(data_, 0, ranges);
1229 template <
class UnaryPredicate>
1230 [[nodiscard]]
bool none(UnaryPredicate p)
const
1232 return semantic::none<1>(data_, 0, p);
1235 template <
class UnaryPredicate>
1236 [[nodiscard]]
bool none(SemanticRange range, UnaryPredicate p)
const
1238 return none(SemanticRangeSet(range), p);
1241 template <
class UnaryPredicate>
1242 [[nodiscard]]
bool none(SemanticRangeSet
const& ranges, UnaryPredicate p)
const
1244 return semantic::none<1>(data_, 0, ranges, p);
1255 void clear()
noexcept { data_.reset(); }
1261 std::pair<iterator, bool> insert(
Semantic semantic)
1263 return insert(semantic.
label, semantic.value);
1266 std::pair<iterator, bool> insert(label_t label, value_t value)
1268 return semantic::insert<1>(data_, 0, label, value);
1271 std::pair<iterator, bool> insert(const_iterator hint,
Semantic semantic)
1273 return insert(hint, semantic.
label, semantic.value);
1276 std::pair<iterator, bool> insert(const_iterator hint, label_t label, value_t value)
1278 return semantic::insert<1>(data_, 0, hint, label, value);
1281 template <
class InputIt>
1282 void insert(InputIt first, InputIt last)
1284 semantic::insert<1>(data_, 0, first, last);
1287 void insert(std::initializer_list<Semantic> ilist)
1289 insert(std::cbegin(ilist), std::cend(ilist));
1296 std::pair<iterator, bool> insertOrAssign(
Semantic semantic)
1298 return insertOrAssign(semantic.
label, semantic.value);
1301 std::pair<iterator, bool> insertOrAssign(label_t label, value_t value)
1303 return semantic::insertOrAssign<1>(data_, 0, label, value);
1306 std::pair<iterator, bool> insertOrAssign(const_iterator hint,
Semantic semantic)
1308 return insertOrAssign(hint, semantic.
label, semantic.value);
1311 std::pair<iterator, bool> insertOrAssign(const_iterator hint, label_t label,
1314 return semantic::insertOrAssign<1>(data_, 0, hint, label, value);
1317 template <
class InputIt>
1318 void insertOrAssign(InputIt first, InputIt last)
1320 semantic::insertOrAssign<1>(data_, 0, first, last);
1323 void insertOrAssign(std::initializer_list<Semantic> ilist)
1325 insertOrAssign(std::cbegin(ilist), std::cend(ilist));
1332 template <
class UnaryFunction,
1333 class = std::enable_if_t<std::is_invocable<UnaryFunction, Semantic>::value>>
1334 void insertOrAssign(label_t label, UnaryFunction f)
1336 semantic::insertOrAssign<1>(data_, 0, label, f);
1340 template <
class InputIt,
class UnaryFunction,
1341 class = std::enable_if_t<std::is_invocable<UnaryFunction, Semantic>::value>>
1342 void insertOrAssign(InputIt first, InputIt last, UnaryFunction f)
1344 semantic::insertOrAssign<1>(data_, 0, first, last, f);
1347 template <
class UnaryFunction,
1348 class = std::enable_if_t<std::is_invocable<UnaryFunction, Semantic>::value>>
1349 void insertOrAssign(std::initializer_list<label_t> ilist, UnaryFunction f)
1351 insertOrAssign(std::cbegin(ilist), std::cend(ilist), f);
1358 void assign(SemanticRange range, value_t value)
1360 assign(SemanticRangeSet{range}, value);
1363 void assign(SemanticRangeSet
const& ranges, value_t value)
1365 semantic::assign<1>(data_, 0, ranges, value);
1368 template <
class UnaryFunction,
1369 class = std::enable_if_t<std::is_invocable<UnaryFunction, Semantic>::value>>
1370 void assign(SemanticRange range, UnaryFunction f)
1372 semantic::assign<1>(data_, 0, SemanticRangeSet{range}, f);
1375 template <
class UnaryPredicate>
1376 void assign(UnaryPredicate p, value_t value)
1378 assign(p, [value](
auto) {
return value; });
1381 template <
class UnaryFunction,
1382 class = std::enable_if_t<std::is_invocable<UnaryFunction, Semantic>::value>>
1383 void assign(SemanticRangeSet
const& ranges, UnaryFunction f)
1385 semantic::assign<1>(data_, 0, ranges, f);
1388 template <
class UnaryPredicate,
class UnaryFunction,
1389 class = std::enable_if_t<std::is_invocable<UnaryFunction, Semantic>::value>>
1390 void assign(UnaryPredicate p, UnaryFunction f)
1392 semantic::assign<1>(data_, 0, p, f);
1401 return semantic::erase<1>(data_, pos, std::next(pos));
1404 iterator erase(
iterator pos) {
return semantic::erase<1>(data_, pos, std::next(pos)); }
1406 iterator erase(const_iterator first, const_iterator last)
1408 return semantic::erase<1>(data_, first, last);
1411 size_type erase(label_t label) {
return semantic::erase<1>(data_, 0, label); }
1413 size_type erase(SemanticRangeSet
const& ranges)
1415 return semantic::erase<1>(data_, 0, ranges);
1418 size_type erase(SemanticRange range) {
return erase(SemanticRangeSet{range}); }
1424 template <
class UnaryPredicate>
1425 size_type eraseIf(UnaryPredicate p)
1427 return semantic::eraseIf<1>(data_, 0, p);
1430 template <
class UnaryPredicate>
1431 size_type eraseIf(SemanticRangeSet
const& ranges, UnaryPredicate p)
1433 return semantic::eraseIf<1>(data_, 0, ranges, p);
1436 template <
class UnaryPredicate>
1437 size_type eraseIf(SemanticRange range, UnaryPredicate p)
1439 return eraseIf(SemanticRangeSet{range}, p);
1446 void swap(
SemanticSet& other)
noexcept { std::swap(data_, other.data_); }
1448 std::string toString()
const {
return semantic::toString<1>(data_); }
1455 [[nodiscard]]
pointer data() {
return empty() ? nullptr : data_.get() + 1; }
1461 void resize(size_type size)
1466 }
else if (this->size() == size) {
1470 pointer p_cur = data_.release();
1475 throw std::bad_alloc();
1479 data_[0].label =
static_cast<label_t
>(size);
1483 std::unique_ptr<Semantic[]> data_;