LRange returns the specified elements of the list stored at key [start,end]
(key string, start, end int)
| 282 | |
| 283 | // LRange returns the specified elements of the list stored at key [start,end] |
| 284 | func (l *List) LRange(key string, start, end int) ([]*core.Record, error) { |
| 285 | size, err := l.Size(key) |
| 286 | if err != nil || size == 0 { |
| 287 | return nil, err |
| 288 | } |
| 289 | |
| 290 | start, end, err = checkBounds(start, end, size) |
| 291 | if err != nil { |
| 292 | return nil, err |
| 293 | } |
| 294 | |
| 295 | var res []*core.Record |
| 296 | allRecords := l.Items[key].All() |
| 297 | for i, item := range allRecords { |
| 298 | if i >= start && i <= end { |
| 299 | res = append(res, item) |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | return res, nil |
| 304 | } |
| 305 | |
| 306 | // GetRemoveIndexes returns a slice of indices to be removed from the list based on the count |
| 307 | func (l *List) GetRemoveIndexes(key string, count int, cmp func(r *core.Record) (bool, error)) ([][]byte, error) { |