MCPcopy Create free account
hub / github.com/copernet/copernicus / Swap

Function Swap

util/stack.go:106–120  ·  view source on GitHub ↗
(s *Stack, other *Stack)

Source from the content-addressed store, hash-verified

104}
105
106func Swap(s *Stack, other *Stack) {
107 if s.Size() == 0 && other.Size() == 0 {
108 return
109 }
110 if other.Size() == 0 {
111 other.array = s.array[:s.Size()]
112 s.array = make([]interface{}, 0)
113 }
114 if s.Size() == 0 {
115 s.array = other.array[:other.Size()]
116 other.array = make([]interface{}, 0)
117 }
118 s.array, other.array = other.array, s.array
119
120}
121
122func (s *Stack) Copy() *Stack {
123 bak := make([]interface{}, s.Size())

Callers 1

TestSwapStackFunction · 0.85

Calls 1

SizeMethod · 0.45

Tested by 1

TestSwapStackFunction · 0.68