package completion

import (
	
	
)

// SuffixMatcher is a type managing suffixes for a given list of completions.
type SuffixMatcher struct {
	string
	pos int // Used to know if the saved suffix matcher is deprecated
}

// Add adds new suffixes to the matcher.
func ( *SuffixMatcher) ( ...rune) {
	if strings.Contains(.string, "*") || strings.Contains(string(), "*") {
		.string = "*"

		return
	}

	 := []rune(.string)

	for ,  := range  {
		if !strings.Contains(.string, string()) {
			 = append(, )
		}
	}

	sort.Sort(byRune())
	.string = string()
}

// Merge merges two suffix matchers.
func ( *SuffixMatcher) ( SuffixMatcher) {
	for ,  := range .string {
		.Add()
	}
}

// Matches returns true if the given string matches one of the suffixes.
func ( SuffixMatcher) ( string) bool {
	for ,  := range .string {
		if  == '*' || strings.HasSuffix(, string()) {
			return true
		}
	}

	return false
}

type byRune []rune

func ( byRune) () int           { return len() }
func ( byRune) (,  int)      { [], [] = [], [] }
func ( byRune) (,  int) bool { return [] < [] }