package matchfinderimport// A TextEncoder is an Encoder that produces a human-readable representation of// the LZ77 compression. Matches are replaced with <Length,Distance> symbols.typeTextEncoderstruct{}func ( TextEncoder) () {}func ( TextEncoder) ( []byte, []byte, []Match, bool) []byte { := 0for , := range {if .Unmatched > 0 { = append(, [:+.Unmatched]...) += .Unmatched }if .Length > 0 { = append(, []byte(fmt.Sprintf("<%d,%d>", .Length, .Distance))...) += .Length } }if < len() { = append(, [:]...) }return}// A NoMatchFinder implements MatchFinder, but doesn't find any matches.// It can be used to implement the equivalent of the standard library flate package's// HuffmanOnly setting.typeNoMatchFinderstruct{}func ( NoMatchFinder) () {}func ( NoMatchFinder) ( []Match, []byte) []Match {returnappend(, Match{Unmatched: len(), })}// AutoReset wraps a MatchFinder that can return references to data in previous// blocks, and calls Reset before each block. It is useful for (e.g.) using a// snappy Encoder with a MatchFinder designed for flate. (Snappy doesn't// support references between blocks.)typeAutoResetstruct {MatchFinder}func ( AutoReset) ( []Match, []byte) []Match { .Reset()return .MatchFinder.FindMatches(, )}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.