1package discoverychain
2
3type stringStack []string
4
5func (s stringStack) Len() int {
6	return len(s)
7}
8
9func (s *stringStack) Push(v string) {
10	*s = append(*s, v)
11}
12
13func (s *stringStack) Pop() (string, bool) {
14	if len(*s) == 0 {
15		return "", false
16	}
17
18	size := len(*s)
19
20	v := (*s)[size-1]
21	*s = (*s)[0 : size-1]
22	return v, true
23}
24
25func (s stringStack) Peek() (string, bool) {
26	if len(s) == 0 {
27		return "", false
28	}
29	return s[len(s)-1], true
30}
31
32// Items returns the underlying slice. The first thing Pushed onto the stack is
33// in the 0th slice position.
34func (s stringStack) Items() []string {
35	return s
36}
37