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

Function RandomStack

Go/Chapter 3/stack/stack.go:57–64  ·  view source on GitHub ↗

* Get a random stack of N elements with data in range (min, max) */

(N, min, max int)

Source from the content-addressed store, hash-verified

55}
56/* Get a random stack of N elements with data in range (min, max) */
57func RandomStack(N, min, max int) *Stack {
58 rand.Seed( time.Now().UTC().UnixNano() ) // seed so that you get new stack every time
59 s := new(Stack)
60 for i := 0; i < N; i++ {
61 s.Push(RandIntBetween(min, max))
62 }
63 return s
64}
65
66func (s *Stack) String() string {
67 temporaryStack := new(Stack)

Callers

nothing calls this directly

Calls 2

RandIntBetweenFunction · 0.70
PushMethod · 0.45

Tested by

no test coverage detected