Open Woazboat opened 1 year ago
#ifndef EASTL_INTRUSIVE_SLIST_H
#define EASTL_INTRUSIVE_SLIST_H
namespace eastl {
template <typename T>
class intrusive_slist_node {
public:
T* next = nullptr;
};
template <typename T>
class intrusive_slist {
public:
using node_type = intrusive_slist_node<T>;
using value_type = T;
intrusive_slist() : head_(nullptr) {}
bool empty() const {
return head_ == nullptr;
}
void push_front(value_type* node) {
node->next = head_;
head_ = node;
}
value_type* pop_front() {
if (!head_) return nullptr;
value_type* node = head_;
head_ = head_->next;
return node;
}
class iterator {
public:
explicit iterator(value_type* node) : node_(node) {}
iterator& operator++() {
node_ = node_->next;
return *this;
}
value_type& operator*() const {
return *node_;
}
bool operator!=(const iterator& other) const {
return node_ != other.node_;
}
private:
value_type* node_;
};
iterator begin() { return iterator(head_); }
iterator end() { return iterator(nullptr); }
private:
value_type* head_;
};
} // namespace eastl
#endif // EASTL_INTRUSIVE_SLIST_H
Documentation and header files for
intrusive_slist
exist, but the implementation is missing. This isn't documented anywhere except in a comment in the (empty) test file forintrusive_slist
. Should either be implemented or disabled to prevent it from being used.