Skip to content

implement intrusive list - #1664

Open
LLirikkkk wants to merge 35 commits into
masterfrom
kkotliar/implement_intrusive_list
Open

implement intrusive list#1664
LLirikkkk wants to merge 35 commits into
masterfrom
kkotliar/implement_intrusive_list

Conversation

@LLirikkkk

Copy link
Copy Markdown
Contributor

No description provided.

@LLirikkkk LLirikkkk added this to the next milestone Jul 28, 2026
@LLirikkkk LLirikkkk self-assigned this Jul 28, 2026
@LLirikkkk LLirikkkk added runtime Feature related to runtime k2 Affects compiler or runtime in K2 mode kphp Affects compiler or runtime in default mode (not K2) labels Jul 28, 2026
@LLirikkkk
LLirikkkk requested a review from apolyakov July 29, 2026 09:05
@DrDet DrDet modified the milestones: 30.06.2026, next Jul 31, 2026
}

auto is_linked() const noexcept -> bool {
return m_prev != this;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a comment explaining why it's ok to only check m_prev here

};

template<typename T, typename... Tags>
auto make_list_node(T value) noexcept -> list_node<T, Tags...> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we don't need this one in public API. list_node's constructors are enough. What do you think?

Also, I think it's worth it to add an in-place constructor like:

template<typename... Args>
  explicit list_node(std::in_place_t, Args&&... args)
      : m_value{std::forward<Args>(args)...} {}

so we can eliminate redundant move in some cases

details::list_node_base* m_curr{nullptr};

explicit list_iterator(const details::list_node_base* node) noexcept
: m_curr{const_cast<details::list_node_base*>(node)} {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a comment justifying this const_cast

public:
using value_type = typename Node::value_type;
using size_type = size_t;
using difference_type = ptrdiff_t;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use std::ptrdiff_t as you do in the iterator

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can easily get rid of it. vk::intrusive::list is enough

@apolyakov apolyakov Jul 31, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. missing copyright header
  2. let's reorder includes here: take a look at zlib-functions.h for reference
  3. let's also add a test that covers list_node's default constructor

}

auto clear() noexcept -> void {
m_sentinel.unlink();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a comment that nodes keep technically linked after this operation?


struct default_tag {};

template<typename T, typename... Tags>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will happen if Tags have a duplicate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

k2 Affects compiler or runtime in K2 mode kphp Affects compiler or runtime in default mode (not K2) runtime Feature related to runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants