dd0e8eec14
* copyright headers for agent folder * Ignore test data files * fix proto files and remove headers in agent/uiserver folder * ignore deep-copy files
40 lines
676 B
Go
40 lines
676 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package discoverychain
|
|
|
|
type stringStack []string
|
|
|
|
func (s stringStack) Len() int {
|
|
return len(s)
|
|
}
|
|
|
|
func (s *stringStack) Push(v string) {
|
|
*s = append(*s, v)
|
|
}
|
|
|
|
func (s *stringStack) Pop() (string, bool) {
|
|
if len(*s) == 0 {
|
|
return "", false
|
|
}
|
|
|
|
size := len(*s)
|
|
|
|
v := (*s)[size-1]
|
|
*s = (*s)[0 : size-1]
|
|
return v, true
|
|
}
|
|
|
|
func (s stringStack) Peek() (string, bool) {
|
|
if len(s) == 0 {
|
|
return "", false
|
|
}
|
|
return s[len(s)-1], true
|
|
}
|
|
|
|
// Items returns the underlying slice. The first thing Pushed onto the stack is
|
|
// in the 0th slice position.
|
|
func (s stringStack) Items() []string {
|
|
return s
|
|
}
|