{"modulePath":"github.com/hydroan/gst","version":"v0.0.0-20261124171847-1a2ba69f3af2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package arrayqueue\n\nPackage arrayqueue is a generic first-in, first-out queue backed by a slice. WithSafe makes a queue safe for concurrent use.\n\n## Types\n\n```go\ntype Option[E any] func(*Queue[E]) error\n```\n\n```go\nfunc WithSafe[E any]() Option[E]\n```\nWithSafe creates a Option that make the array-backed queue safe for concurrent use.\n\n```go\ntype Queue[E any] struct {\n\t// contains filtered or unexported fields\n}\n```\nQueue represents a queue backed by a slice. This queue implements the FIFO (first-in, first-out) behavior.\n\n```go\nfunc New[E any](ops ...Option[E]) (*Queue[E], error)\n```\nNew creates and initializes a empty queue. Options can be provided to customize the queue's properties (e.g., thread safety).\n\n```go\nfunc NewFromMapKeys[K comparable, V any](m map[K]V, ops ...Option[K]) (*Queue[K], error)\n```\nNewFromMapKeys creates and initializes a queue from the provided map keys. Options can be provided to customize the queue's properties (e.g., thread safety).\n\n```go\nfunc NewFromMapValues[K comparable, V any](m map[K]V, ops ...Option[V]) (*Queue[V], error)\n```\nNewFromMapValues creates and initializes a queue from the provided map values. Options can be provided to customize the queue's properties (e.g., thread safety).\n\n```go\nfunc NewFromSlice[E any](slice []E, ops ...Option[E]) (*Queue[E], error)\n```\nNewFromSlice creates and initializes a queue from the provided slice. Options can be provided to customize the queue's properties (e.g., thread safety).\n\n```go\nfunc (q *Queue[E]) Clear()\n```\nClear removes all elements from the queue.\n\n```go\nfunc (q *Queue[E]) Clone() *Queue[E]\n```\nClone returns a deep copy of the queue.\n\n```go\nfunc (q *Queue[E]) Dequeue() (E, bool)\n```\nDequeue removes first element of the queue. Returns zero value of element and false if queue is empty.\n\n```go\nfunc (q *Queue[E]) Enqueue(e E)\n```\nEnqueue adds a element to the end of the queue.\n\n```go\nfunc (q *Queue[E]) IsEmpty() bool\n```\nIsEmpty reports whether the queue has no element.\n\n```go\nfunc (q *Queue[E]) Len() int\n```\nLen returns the number of elements currently in the queue.\n\n```go\nfunc (q *Queue[E]) MarshalJSON() ([]byte, error)\n```\nMarshalJSON will marshal the queue into a JSON-based representation.\n\n```go\nfunc (q *Queue[E]) Peek() (E, bool)\n```\nPeek returns first element of the queue without remove it. Returns zero value of element and false if queue is empty.\n\n```go\nfunc (q *Queue[E]) String() string\n```\nString returns a string representation of the queue.\n\n```go\nfunc (q *Queue[E]) UnmarshalJSON(data []byte) error\n```\nUnmarshalJSON will unmarshal a JSON-based representation byte slice into the queue.\n\n```go\nfunc (q *Queue[E]) Values() []E\n```\nValues returns all elements in the queue in FIFO(first-in, first-out) order. If the queue is empty, it returns an empty slice (not nil).\n\n","path":"github.com/hydroan/gst/ds/queue/arrayqueue","name":"arrayqueue","synopsis":"Package arrayqueue is a generic first-in, first-out queue backed by a slice.","isRedistributable":true}
