diff options
Diffstat (limited to 'c_litems.go')
-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 |