diff options
author | Joe <rbo@gmx.us> | 2024-01-08 20:20:20 +0100 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2024-01-08 20:20:20 +0100 |
commit | 4f42a45b5d0454cd1ca5cae2e7ed897bd63f708e (patch) | |
tree | 42a8fccdc094212485ca682340d9229e407cd12d /c_litems.go | |
parent | tmp (diff) | |
download | hardflip-4f42a45b5d0454cd1ca5cae2e7ed897bd63f708e.tar.gz hardflip-4f42a45b5d0454cd1ca5cae2e7ed897bd63f708e.tar.bz2 hardflip-4f42a45b5d0454cd1ca5cae2e7ed897bd63f708e.tar.xz hardflip-4f42a45b5d0454cd1ca5cae2e7ed897bd63f708e.tar.zst hardflip-4f42a45b5d0454cd1ca5cae2e7ed897bd63f708e.zip |
fix
Diffstat (limited to '')
-rw-r--r-- | c_litems.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/c_litems.go b/c_litems.go index 0a1acf0..df20520 100644 --- a/c_litems.go +++ b/c_litems.go @@ -80,6 +80,32 @@ func (litems *ItemsList) add_back(node *ItemsNode) { litems.last = last.next } +// removes an item node from the list and resets the ids +func (litems *ItemsList) del(item *ItemsNode) { + if litems.head == nil { + return + } + if litems.head == item { + litems.head = litems.head.next + litems.head.prev = nil + for curr := litems.head; curr != nil; curr = curr.next { + curr.ID -= 1 + } + return + } + curr := litems.head + for curr.next != nil && curr.next != item { + curr = curr.next + } + if curr.next == item { + curr.next = curr.next.next + curr.next.prev = curr + } + for curr := curr.next; curr != nil; curr = curr.next { + curr.ID -= 1 + } +} + // sets litems.curr to be used func (litems *ItemsList) sel(id int) { curr := litems.head |