crushkv/crushmap/text_stack.go
Vasiliy Tolstov 24f641df0d initial rewrite
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-04-18 23:13:04 +03:00

39 lines
504 B
Go

package crushmap
type runeNode struct {
r rune
next *runeNode
}
type runeStack struct {
start *runeNode
}
func newRuneStack() runeStack {
return runeStack{}
}
func (s *runeStack) push(r rune) {
node := &runeNode{r: r}
if s.start == nil {
s.start = node
} else {
node.next = s.start
s.start = node
}
}
func (s *runeStack) pop() rune {
if s.start == nil {
return EOFRune
} else {
n := s.start
s.start = n.next
return n.r
}
}
func (s *runeStack) clear() {
s.start = nil
}