package matchfinder

import 

// A TextEncoder is an Encoder that produces a human-readable representation of
// the LZ77 compression. Matches are replaced with <Length,Distance> symbols.
type TextEncoder struct{}

func ( TextEncoder) () {}

func ( TextEncoder) ( []byte,  []byte,  []Match,  bool) []byte {
	 := 0
	for ,  := 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.
type NoMatchFinder struct{}

func ( NoMatchFinder) () {}

func ( NoMatchFinder) ( []Match,  []byte) []Match {
	return append(, 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.)
type AutoReset struct {
	MatchFinder
}

func ( AutoReset) ( []Match,  []byte) []Match {
	.Reset()
	return .MatchFinder.FindMatches(, )
}