Documentation
¶
Overview ¶
Package list implements list data structures.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Queue ¶
type Queue[T any] interface { // Size returns the number of values in the queue. Size() int // IsEmpty returns true if the queue is empty. IsEmpty() bool // Enqueue adds a new value to the queue. Enqueue(T) // Dequeue removes a value from the queue. Dequeue() (T, bool) // Peek returns the next value in queue without removing it from the queue. Peek() (T, bool) // Contains returns true if a given value is already in the queue. Contains(T) bool }
Queue represents a queue abstract data type.
type SoftQueue ¶ added in v0.4.2
type SoftQueue[T any] interface { // Size returns the number of values in the queue. Size() int // IsEmpty returns true if the queue is empty. IsEmpty() bool // Enqueue inserts a new value to the queue. // It returns the index of the newly enqueued value in the queue. Enqueue(T) int // Dequeue deletes a value from the queue. // The deletion is soft and the entries remain in the queue. // Deleted entries are searchable using the Contains method. // The second return value is the index of the dequeued value in the queue. Dequeue() (T, int) // Peek returns the next value in queue without deleting it from the queue. // The second return value is the index of the peeked value in the queue. Peek() (T, int) // Contains returns true if a given value is either in the queue or deleted in the past. // If the value is found, its index in the queue is returned; otherwise, -1 is returned. Contains(T) int // Values returns the list of all values in the queue including the deleted ones. Values() []T }
SoftQueue represents the abstract data type for a queue with soft deletion.
type Stack ¶
type Stack[T any] interface { // Size returns the number of values on the stack. Size() int // IsEmpty returns true if the stack is empty. IsEmpty() bool // Enqueue adds a new value to the stack. Push(T) // Dequeue removes a value from the stack. Pop() (T, bool) // Peek returns the next value on stack without removing it from the stack. Peek() (T, bool) // Contains returns true if a given value is already on the stack. Contains(T) bool }
Stack represents a stack abstract data type.
Click to show internal directories.
Click to hide internal directories.