add 2 unittests
Validate Operations / validate-operations (push) Failing after 8m9s

fix bugs
This commit is contained in:
NiccoloN
2026-04-16 18:01:38 +02:00
parent 197c38f9ca
commit a903e30859
9 changed files with 336 additions and 58 deletions
+12 -15
View File
@@ -31,9 +31,7 @@ public:
bool isLinked() const { return owner_ != nullptr; }
Label getOrderLabel() const { return label; }
friend bool operator<(const LabeledListNode& lft, const LabeledListNode& rgt){
return lft.label < rgt.label;
}
friend bool operator<(const LabeledListNode& lft, const LabeledListNode& rgt) { return lft.label < rgt.label; }
private:
const void* owner_ = nullptr;
@@ -79,17 +77,17 @@ public:
auto it = node->getIterator();
if (it == list->nodes_.begin())
return nullptr;
return *std::prev(it);
return &*std::prev(it);
}
static const NodeT* previous(const NodeT* node) {
if (!node || !owner(node))
return nullptr;
const auto* list = owner(node);
auto it = node->getIterator();
auto it = const_cast<NodeT*>(node)->getIterator();
if (it == list->nodes_.begin())
return nullptr;
return *std::prev(it);
return &*std::prev(it);
}
static NodeT* next(NodeT* node) {
@@ -99,29 +97,29 @@ public:
auto it = std::next(node->getIterator());
if (it == list->nodes_.end())
return nullptr;
return *it;
return &*it;
}
static const NodeT* next(const NodeT* node) {
if (!node || !owner(node))
return nullptr;
const auto* list = owner(node);
auto it = std::next(node->getIterator());
auto it = std::next(const_cast<NodeT*>(node)->getIterator());
if (it == list->nodes_.end())
return nullptr;
return *it;
return &*it;
}
bool contains(const NodeT* node) const { return node && node->owner_ == this; }
Label getOrderLabel(const NodeT* node) const {
assert(contains(node) && "node must belong to this list");
return node->label_;
return node->label;
}
bool comesBefore(const NodeT* lhs, const NodeT* rhs) const {
assert(contains(lhs) && contains(rhs) && "nodes must belong to this list");
return lhs->label_ < rhs->label_;
return lhs->label < rhs->label;
}
void pushFront(NodeT* node) { insertBefore(front(), node); }
@@ -152,7 +150,7 @@ public:
assert(contains(node) && "node must belong to this list");
nodes_.remove(*node);
node->owner_ = nullptr;
node->label_ = 0;
node->label = 0;
--size_;
}
@@ -190,15 +188,14 @@ public:
}
Iterator begin() { return nodes_.begin(); }
Iterator end() { return nodes_.end(); }
RIterator rbegin() { return nodes_.rbegin(); }
RIterator rend() { return nodes_.rend(); }
private:
static const LabeledList* owner(const NodeT* node) { return node->owner_; }
static LabeledList* owner(NodeT* node) { return node->owner_; }
static const LabeledList* owner(const NodeT* node) { return static_cast<const LabeledList*>(node->owner_); }
static LabeledList* owner(NodeT* node) { return static_cast<LabeledList*>(const_cast<void*>(node->owner_)); }
static Label lowerLabel(const NodeT* node) { return node ? node->label : kLowerSentinel; }
static Label upperLabel(const NodeT* node) { return node ? node->label : kUpperSentinel; }