Skip to content

Add doubly-linked list to qpi#806

Merged
fnordspace merged 8 commits intoqubic:developfrom
fnordspace:feature/2026-03-06-qpiLinkedList
Apr 13, 2026
Merged

Add doubly-linked list to qpi#806
fnordspace merged 8 commits intoqubic:developfrom
fnordspace:feature/2026-03-06-qpiLinkedList

Conversation

@fnordspace
Copy link
Copy Markdown
Contributor

Adds LinkedList<T, L> to the QPI — a doubly-linked list with fixed capacity L (must be power of 2).

  • O(1) addHead, addTail, insertBefore, insertAfter, remove
  • Bidirectional traversal via headIndex/tailIndex + nextElementIndex/prevElementIndex
  • Removed nodes are immediately recycled via a free list (no cleanup() needed)
  • replace() for in-place value updates, reset() to reinitialize
  • Occupied-flags bitmap for isEmptySlot() checks

…l traversal

Doubly-linked list with fixed capacity (power-of-2), immediate node recycling
via free list, and lazy allocation. Includes 32 unit tests covering all operations.
@fnordspace fnordspace self-assigned this Mar 25, 2026
@fnordspace fnordspace added the enhancement New feature or request label Mar 25, 2026
@fnordspace fnordspace added this to qubic Mar 25, 2026
@fnordspace fnordspace moved this to 👀 In review in qubic Mar 25, 2026
Comment thread doc/contracts.md
Comment thread src/contract_core/qpi_linked_list_impl.h Outdated
Comment thread src/contracts/qpi.h
Copy link
Copy Markdown
Contributor

@philippwerner philippwerner left a comment

Choose a reason for hiding this comment

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

Overall, this looks good to me. The only issue I see is the initialization (see my response to Franziska's comment above) that we should either address in the code (auto-init if population is 0) or in the documentation + maybe contract checking tool (make sure that reset() is called in INITIALIZE).

Comment thread src/contracts/qpi.h
Comment thread src/contracts/qpi.h
@fnordspace fnordspace merged commit 360a25c into qubic:develop Apr 13, 2026
1 check passed
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in qubic Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

4 participants