LRem removes the first count occurrences of elements equal to value from the list stored at key. The count argument influences the operation in the following ways: count > 0: Remove elements equal to value moving from head to tail. count < 0: Remove elements equal to value moving from tail to head.
(key string, count int, cmp func(r *core.Record) (bool, error))
| 363 | // count < 0: Remove elements equal to value moving from tail to head. |
| 364 | // count = 0: Remove all elements equal to value. |
| 365 | func (l *List) LRem(key string, count int, cmp func(r *core.Record) (bool, error)) error { |
| 366 | removeIndexes, err := l.GetRemoveIndexes(key, count, cmp) |
| 367 | if err != nil { |
| 368 | return err |
| 369 | } |
| 370 | |
| 371 | list := l.Items[key] |
| 372 | for _, idx := range removeIndexes { |
| 373 | list.Delete(idx) |
| 374 | } |
| 375 | |
| 376 | return nil |
| 377 | } |
| 378 | |
| 379 | // LTrim trim an existing list so that it will contain only the specified range of elements specified. |
| 380 | func (l *List) LTrim(key string, start, end int) error { |