Source File
dedup_cursor.go
Belonging Package
src.elv.sh/pkg/cli/histutil
package histutilimport// NewDedupCursor returns a cursor that skips over all duplicate entries.func ( Cursor) Cursor {return &dedupCursor{, 0, nil, make(map[string]bool)}}type dedupCursor struct {c Cursorcurrent intstack []store.Cmdocc map[string]bool}func ( *dedupCursor) () {if .current < len(.stack)-1 {.current++return}for {.c.Prev(), := .c.Get()if != nil {.current = len(.stack)break}if !.occ[.Text] {.current = len(.stack).stack = append(.stack, ).occ[.Text] = truebreak}}}func ( *dedupCursor) () {if .current >= 0 {.current--}}func ( *dedupCursor) () (store.Cmd, error) {switch {case .current < 0:return store.Cmd{}, ErrEndOfHistorycase .current < len(.stack):return .stack[.current], nildefault:return .c.Get()}}
The pages are generated with Golds v0.2.8-preview. (GOOS=darwin GOARCH=arm64)