{"modulePath":"github.com/dexwolfers/gods","version":"v1.12.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package arraystack\n\nPackage arraystack implements a stack backed by array list.\n\nStructure is not thread safe.\n\nReference: [https://en.wikipedia.org/wiki/Stack\\_%28abstract\\_data\\_type%29#Array](https://en.wikipedia.org/wiki/Stack_%28abstract_data_type%29#Array)\n\n## Types\n\n```go\ntype Iterator struct {\n\t// contains filtered or unexported fields\n}\n```\nIterator returns a stateful iterator whose values can be fetched by an index.\n\n```go\nfunc (iterator *Iterator) Begin()\n```\nBegin resets the iterator to its initial state (one-before-first) Call Next() to fetch the first element if any.\n\n```go\nfunc (iterator *Iterator) End()\n```\nEnd moves the iterator past the last element (one-past-the-end). Call Prev() to fetch the last element if any.\n\n```go\nfunc (iterator *Iterator) First() bool\n```\nFirst moves the iterator to the first element and returns true if there was a first element in the container. If First() returns true, then first element's index and value can be retrieved by Index() and Value(). Modifies the state of the iterator.\n\n```go\nfunc (iterator *Iterator) Index() int\n```\nIndex returns the current element's index. Does not modify the state of the iterator.\n\n```go\nfunc (iterator *Iterator) Last() bool\n```\nLast moves the iterator to the last element and returns true if there was a last element in the container. If Last() returns true, then last element's index and value can be retrieved by Index() and Value(). Modifies the state of the iterator.\n\n```go\nfunc (iterator *Iterator) Next() bool\n```\nNext moves the iterator to the next element and returns true if there was a next element in the container. If Next() returns true, then next element's index and value can be retrieved by Index() and Value(). If Next() was called for the first time, then it will point the iterator to the first element if it exists. Modifies the state of the iterator.\n\n```go\nfunc (iterator *Iterator) Prev() bool\n```\nPrev moves the iterator to the previous element and returns true if there was a previous element in the container. If Prev() returns true, then previous element's index and value can be retrieved by Index() and Value(). Modifies the state of the iterator.\n\n```go\nfunc (iterator *Iterator) Value() interface{}\n```\nValue returns the current element's value. Does not modify the state of the iterator.\n\n```go\ntype Stack struct {\n\t// contains filtered or unexported fields\n}\n```\nStack holds elements in an array-list\n\n```go\nfunc New() *Stack\n```\nNew instantiates a new empty stack\n\n```go\nfunc (stack *Stack) Clear()\n```\nClear removes all elements from the stack.\n\n```go\nfunc (stack *Stack) Empty() bool\n```\nEmpty returns true if stack does not contain any elements.\n\n```go\nfunc (stack *Stack) FromJSON(data []byte) error\n```\nFromJSON populates the stack from the input JSON representation.\n\n```go\nfunc (stack *Stack) Iterator() Iterator\n```\nIterator returns a stateful iterator whose values can be fetched by an index.\n\n```go\nfunc (stack *Stack) Peek() (value interface{}, ok bool)\n```\nPeek returns top element on the stack without removing it, or nil if stack is empty. Second return parameter is true, unless the stack was empty and there was nothing to peek.\n\n```go\nfunc (stack *Stack) Pop() (value interface{}, ok bool)\n```\nPop removes top element on stack and returns it, or nil if stack is empty. Second return parameter is true, unless the stack was empty and there was nothing to pop.\n\n```go\nfunc (stack *Stack) Push(value interface{})\n```\nPush adds a value onto the top of the stack\n\n```go\nfunc (stack *Stack) Size() int\n```\nSize returns number of elements within the stack.\n\n```go\nfunc (stack *Stack) String() string\n```\nString returns a string representation of container\n\n```go\nfunc (stack *Stack) ToJSON() ([]byte, error)\n```\nToJSON outputs the JSON representation of the stack.\n\n```go\nfunc (stack *Stack) Values() []interface{}\n```\nValues returns all elements in the stack (LIFO order).\n\n","path":"github.com/dexwolfers/gods/stacks/arraystack","name":"arraystack","synopsis":"Package arraystack implements a stack backed by array list.","isRedistributable":true}
