1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
package fmi
type sMatch struct {
query []byte
start, end int
mismatches int
}
// Stack struct
type Stack []sMatch
// Empty tell if it is empty
func (s Stack) Empty() bool {
return len(s) == 0
}
// Peek return the last element
func (s Stack) Peek() sMatch {
return s[len(s)-1]
}
// Put puts element to stack
func (s *Stack) Put(i sMatch) {
(*s) = append((*s), i)
}
// Pop pops element from the stack
func (s *Stack) Pop() sMatch {
d := (*s)[len(*s)-1]
(*s) = (*s)[:len(*s)-1]
return d
}
|