MCPcopy Create free account
hub / github.com/dbProjectRED/redimo.go / listNodeAtIndex

Method listNodeAtIndex

lists.go:232–256  ·  view source on GitHub ↗
(key string, index int64)

Source from the content-addressed store, hash-verified

230}
231
232func (c Client) listNodeAtIndex(key string, index int64) (node listNode, found bool, err error) {
233 side := Left
234 if index < 0 {
235 side = Right
236 index = -index - 1
237 }
238
239 node, found, err = c.listFindEnd(key, side)
240 i := int64(0)
241
242 for found {
243 if err != nil {
244 return
245 }
246
247 if i == index {
248 return node, true, nil
249 }
250
251 node, found, err = c.listGetByAddress(key, node.next(side))
252 i++
253 }
254
255 return node, false, nil
256}
257
258// LINSERT inserts the given element on the given side of the pivot element.
259func (c Client) LINSERT(key string, side LSide, pivot, element Value) (newLength int64, done bool, err error) {

Callers 2

LINDEXMethod · 0.95
LSETMethod · 0.95

Calls 3

listFindEndMethod · 0.95
listGetByAddressMethod · 0.95
nextMethod · 0.80

Tested by

no test coverage detected