March 2019
Intermediate to advanced
336 pages
9h 9m
English
The New method on the Stack class creates a dynamic array of elements. The Stack class has the count and array pointer of elements. The code snippet with the Stack class definition and the New method is as follows:
// NewStack returns a new stack.func (stack *Stack) New() { stack.elements = make(*Element[] elements,0)}// Stack is a basic LIFO stack that resizes as needed.type Stack struct { elements []*Element elementCount int}
Read now
Unlock full access