mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-04 10:34:55 +02:00
28 lines
453 B
Go
28 lines
453 B
Go
|
package utils
|
||
|
|
||
|
type StringStack struct {
|
||
|
stack []string
|
||
|
}
|
||
|
|
||
|
func (self *StringStack) Push(s string) {
|
||
|
self.stack = append(self.stack, s)
|
||
|
}
|
||
|
|
||
|
func (self *StringStack) Pop() string {
|
||
|
if len(self.stack) == 0 {
|
||
|
return ""
|
||
|
}
|
||
|
n := len(self.stack) - 1
|
||
|
last := self.stack[n]
|
||
|
self.stack = self.stack[:n]
|
||
|
return last
|
||
|
}
|
||
|
|
||
|
func (self *StringStack) IsEmpty() bool {
|
||
|
return len(self.stack) == 0
|
||
|
}
|
||
|
|
||
|
func (self *StringStack) Clear() {
|
||
|
self.stack = []string{}
|
||
|
}
|