mirror of
https://github.com/Green-Sky/crdt_tests.git
synced 2025-12-06 09:36:35 +01:00
add text document to v3, planing v4
This commit is contained in:
@@ -80,7 +80,7 @@ struct List {
|
||||
//size_t _stat_find_with_hint{0};
|
||||
//size_t _stat_find_with_hint_hit{0};
|
||||
|
||||
std::optional<size_t> findActor(const ActorType& actor) const {
|
||||
[[nodiscard]] std::optional<size_t> findActor(const ActorType& actor) const {
|
||||
for (size_t i = 0; i < _actors.size(); i++) {
|
||||
if (_actors[i] == actor) {
|
||||
return i;
|
||||
@@ -89,7 +89,7 @@ struct List {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<size_t> findIdx(const ListIDInternal& list_id) const {
|
||||
[[nodiscard]] std::optional<size_t> findIdx(const ListIDInternal& list_id) const {
|
||||
extra_assert(verify());
|
||||
|
||||
for (size_t i = 0; i < _list_ids.size(); i++) {
|
||||
@@ -102,7 +102,7 @@ struct List {
|
||||
}
|
||||
|
||||
// search close to hint first
|
||||
std::optional<size_t> findIdx(const ListIDInternal& list_id, size_t hint) const {
|
||||
[[nodiscard]] std::optional<size_t> findIdx(const ListIDInternal& list_id, size_t hint) const {
|
||||
extra_assert(verify());
|
||||
|
||||
//_stat_find_with_hint++;
|
||||
@@ -140,7 +140,7 @@ struct List {
|
||||
return findIdx(list_id);
|
||||
}
|
||||
|
||||
std::optional<size_t> findIdx(const ListID& list_id) const {
|
||||
[[nodiscard]] std::optional<size_t> findIdx(const ListID& list_id) const {
|
||||
extra_assert(verify());
|
||||
|
||||
const auto actor_idx_opt = findActor(list_id.id);
|
||||
@@ -153,7 +153,7 @@ struct List {
|
||||
return findIdx(tmp_id);
|
||||
}
|
||||
|
||||
std::optional<size_t> findIdx(const ListID& list_id, size_t hint) const {
|
||||
[[nodiscard]] std::optional<size_t> findIdx(const ListID& list_id, size_t hint) const {
|
||||
extra_assert(verify());
|
||||
|
||||
const auto actor_idx_opt = findActor(list_id.id);
|
||||
@@ -369,12 +369,32 @@ struct List {
|
||||
return false;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool empty(void) const {
|
||||
return _list_ids.empty();
|
||||
}
|
||||
|
||||
[[nodiscard]] size_t size(void) const {
|
||||
return _list_ids.size();
|
||||
}
|
||||
|
||||
[[nodiscard]] ListIDInternal getIDInternal(size_t idx) const {
|
||||
return _list_ids.at(idx);
|
||||
}
|
||||
|
||||
[[nodiscard]] const ListID getID(size_t idx) const {
|
||||
return {_actors.at(_list_ids.at(idx).actor_idx), _list_ids.at(idx).seq};
|
||||
}
|
||||
|
||||
[[nodiscard]] const std::optional<ValueType>& getValue(size_t idx) const {
|
||||
return _list_data.at(idx).value;
|
||||
}
|
||||
|
||||
// returns the size of alive entries
|
||||
size_t getDocSize(void) const {
|
||||
[[nodiscard]] size_t getDocSize(void) const {
|
||||
return _doc_size;
|
||||
}
|
||||
|
||||
std::vector<ValueType> getArray(void) const {
|
||||
[[nodiscard]] std::vector<ValueType> getArray(void) const {
|
||||
std::vector<ValueType> array;
|
||||
for (const auto& e : _list_data) {
|
||||
if (e.value.has_value()) {
|
||||
|
||||
Reference in New Issue
Block a user