MCPcopy Index your code
hub / github.com/careercup/ctci / String

Method String

Go/Chapter 3/stack/stack.go:66–82  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

64}
65
66func (s *Stack) String() string {
67 temporaryStack := new(Stack)
68 var buffer bytes.Buffer
69 for (s.size > 0) {
70 data, _ := s.Pop()
71 temporaryStack.Push(data)
72 buffer.WriteString(fmt.Sprintf("[%v]", data))
73 buffer.WriteString(" -> ")
74 }
75 buffer.WriteString(" BOTTOM ")
76 /* push elements back to the stack*/
77 for (temporaryStack.size > 0) {
78 data, _ := temporaryStack.Pop()
79 s.Push(data)
80 }
81 return buffer.String()
82}

Callers

nothing calls this directly

Calls 3

PopMethod · 0.95
PushMethod · 0.95
StringMethod · 0.65

Tested by

no test coverage detected