{"modulePath":"github.com/hydroan/gst","version":"v0.0.0-20261124171847-1a2ba69f3af2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package arraystack\n\nPackage arraystack is a generic last-in, first-out stack backed by a slice. WithSafe makes a stack safe for concurrent use.\n\n## Types\n\n```go\ntype Option[E any] func(*Stack[E]) error\n```\nOption is funtional option type for configuring a Stack.\n\n```go\nfunc WithSafe[E any]() Option[E]\n```\nWithSafe creates a option that make the array-backed stack safe for concurrent use.\n\n```go\ntype Stack[E any] struct {\n\t// contains filtered or unexported fields\n}\n```\nStack represents a stack backed by a slice. The stack provides typical LIFO(last-in, first-out) behavior.\n\n```go\nfunc New[E any](ops ...Option[E]) (*Stack[E], error)\n```\nNew creates and initializes a empty stack. Options can be provided to customize the stack's properties (e.g., thread safety).\n\n```go\nfunc NewFromMapKeys[K comparable, V any](m map[K]V, ops ...Option[K]) (*Stack[K], error)\n```\nNewFromMapKeys creates and initializes a stack from the provided map keys. Options can be provided to customize the stack's properties (e.g., thread safety). Returns an empty stack if the provided map is nil or empty.\n\n```go\nfunc NewFromMapValues[K comparable, V any](m map[K]V, ops ...Option[V]) (*Stack[V], error)\n```\nNewFromMapValues creates a stack from the provided map values. Options can be provided to customize the stack's properties (e.g., thread safety). Returns an empty stack if the provided map is nil or empty.\n\n```go\nfunc NewFromSlice[E any](slice []E, ops ...Option[E]) (*Stack[E], error)\n```\nNewFromSlice creates and initializes a stack from the provided slice, the last element of the slice on top. Options can be provided to customize the stack's properties (e.g., thread safety).\n\n```go\nfunc (s *Stack[E]) Clear()\n```\nClear removes all elements from the stack.\n\n```go\nfunc (s *Stack[E]) Clone() *Stack[E]\n```\nClone returns a deep copy of the stack.\n\n```go\nfunc (s *Stack[E]) IsEmpty() bool\n```\nIsEmpty reports whether the stack has no elements.\n\n```go\nfunc (s *Stack[E]) Len() int\n```\nLen returns the number of elements currently in the stack.\n\n```go\nfunc (s *Stack[E]) MarshalJSON() ([]byte, error)\n```\nMarshalJSON marshals the stack into a JSON array, the top of the stack first, the order Values lists it in.\n\n```go\nfunc (s *Stack[E]) Peek() (E, bool)\n```\nPeek returns the top element of the stack without removing it. Returns the zero value of E and false if the stack is empty.\n\n```go\nfunc (s *Stack[E]) Pop() (E, bool)\n```\nPop removes and returns the top element of the stack. Returns the zero value of E and false if the stack is empty.\n\n```go\nfunc (s *Stack[E]) Push(e E)\n```\nPush adds an element to the top of the stack. The stack's size increases by one.\n\n```go\nfunc (s *Stack[E]) String() string\n```\nString returns a string representation of the stack.\n\n```go\nfunc (s *Stack[E]) UnmarshalJSON(data []byte) (err error)\n```\nUnmarshalJSON replaces the stack with the elements of a JSON array read in the order MarshalJSON writes: the first element ends up on top.\n\n```go\nfunc (s *Stack[E]) Values() []E\n```\nValues returns all elements in the stack in LIFO(last-in, first-out) order. If the stack is empty, it returns an empty slice (not nil).\n\n","path":"github.com/hydroan/gst/ds/stack/arraystack","name":"arraystack","synopsis":"Package arraystack is a generic last-in, first-out stack backed by a slice.","isRedistributable":true}
