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 | 0d045754540ec413904c01892bbff423b80f4a1e (patch) | |
tree | 5c621ea2d746028f5a9adb54365cde8bcf773e9c /c_litems.go | |
parent | comparing pointers on a daily basis (diff) | |
download | hardflip-0d045754540ec413904c01892bbff423b80f4a1e.tar.gz hardflip-0d045754540ec413904c01892bbff423b80f4a1e.tar.bz2 hardflip-0d045754540ec413904c01892bbff423b80f4a1e.tar.xz hardflip-0d045754540ec413904c01892bbff423b80f4a1e.tar.zst hardflip-0d045754540ec413904c01892bbff423b80f4a1e.zip |
great
Diffstat (limited to '')
-rw-r--r-- | c_litems.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/c_litems.go b/c_litems.go index 68d7137..63338bd 100644 --- a/c_litems.go +++ b/c_litems.go @@ -109,18 +109,24 @@ func (item *ItemsNode) inc(jump int) *ItemsNode { if jump == 0 { return item } else if jump == 1 { - return item.next + if item.next != nil { + return item.next + } + return item } else if jump == -1 { - return item.prev + if item.prev != nil { + return item.prev + } + return item } new_item := item if jump > 0 { - for i := 0; new_item != nil && i < jump; i++ { + for i := 0; new_item.next != nil && i < jump; i++ { new_item = new_item.next } return new_item } - for i := 0; new_item != nil && i > jump; i-- { + for i := 0; new_item.prev != nil && i > jump; i-- { new_item = new_item.prev } return new_item |