diff --git a/src/util/IntrusiveHashSet.hxx b/src/util/IntrusiveHashSet.hxx index 69603ab1c..9b7c38ac3 100644 --- a/src/util/IntrusiveHashSet.hxx +++ b/src/util/IntrusiveHashSet.hxx @@ -300,21 +300,22 @@ public: * * @param bucket the bucket returned by insert_check() */ - constexpr void insert_commit(bucket_iterator bucket, reference item) noexcept { + constexpr bucket_iterator insert_commit(bucket_iterator bucket, + reference item) noexcept { ++counter; /* using insert_after() so the new item gets inserted at the front of the bucket list */ - GetBucket(ops.get_key(item)).insert_after(bucket, item); + return GetBucket(ops.get_key(item)).insert_after(bucket, item); } /** * Insert a new item without checking whether the key already * exists. */ - constexpr void insert(reference item) noexcept { + constexpr bucket_iterator insert(reference item) noexcept { ++counter; - GetBucket(ops.get_key(item)).push_front(item); + return GetBucket(ops.get_key(item)).push_front(item); } constexpr bucket_iterator erase(bucket_iterator i) noexcept { diff --git a/src/util/IntrusiveList.hxx b/src/util/IntrusiveList.hxx index 6b0ab25a3..2604cd6af 100644 --- a/src/util/IntrusiveList.hxx +++ b/src/util/IntrusiveList.hxx @@ -507,12 +507,12 @@ 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); } /** @@ -520,8 +520,10 @@ public: * * @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"); @@ -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); } /**