3 // Stack is a simple implementation of a LIFO stack for text events
9 // An Element which is stored in the Stack
15 // Len returns the stack's length
16 func (s *Stack) Len() int {
20 // Push a new element onto the stack
21 func (s *Stack) Push(value *TextEvent) {
22 s.Top = &Element{value, s.Top}
26 // Pop removes the top element from the stack and returns its value
27 // If the stack is empty, return nil
28 func (s *Stack) Pop() (value *TextEvent) {
30 value, s.Top = s.Top.Value, s.Top.Next
37 // Peek returns the top element of the stack without removing it
38 func (s *Stack) Peek() *TextEvent {