Skip to content

Commit

Permalink
util/Intrusive*: insertion methods return an iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Sep 16, 2023
1 parent b98dbcc commit 354a5bc
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/util/IntrusiveList.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -507,21 +507,23 @@ public:
return result;
}

void push_front(reference t) noexcept {
insert(begin(), t);
iterator push_front(reference t) noexcept {
return insert(begin(), t);
}

void push_back(reference t) noexcept {
insert(end(), t);
iterator push_back(reference t) noexcept {
return insert(end(), t);
}

/**
* Insert a new item before the given position.
*
* @param p a valid iterator (end() is allowed)for this list
* describing the position where to insert
*
* @return an iterator to the new item
*/
void insert(iterator p, reference t) noexcept {
iterator insert(iterator p, reference t) noexcept {
static_assert(!constant_time_size ||
GetHookMode() < IntrusiveHookMode::AUTO_UNLINK,
"Can't use auto-unlink hooks with constant_time_size");
Expand All @@ -538,17 +540,19 @@ public:
IntrusiveListNode::Connect(new_node, existing_node);

++counter;

return iterator_to(t);
}

/**
* Like insert(), but insert after the given position.
*/
void insert_after(iterator p, reference t) noexcept {
iterator insert_after(iterator p, reference t) noexcept {
if constexpr (options.zero_initialized)
if (head.next == nullptr)
head = {&head, &head};

insert(std::next(p), t);
return insert(std::next(p), t);
}

/**
Expand Down

0 comments on commit 354a5bc

Please sign in to comment.