container

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

type Queue[T any] struct {
	// contains filtered or unexported fields
}

Queue represents a FIFO list.

func (*Queue[T]) Dequeue

func (q *Queue[T]) Dequeue() T

Dequeue removes the first element from the queue and returns it (or panics if the queue is empty).

func (*Queue[T]) Enqueue

func (q *Queue[T]) Enqueue(i T)

Enqueue adds another elements to the end of the queue.

func (*Queue[T]) Peek

func (q *Queue[T]) Peek() T

Peek returns the first element from the queue (or panics if the queue is empty).

func (*Queue[T]) Size

func (q *Queue[T]) Size() int

Size returns the number of elements contained in the queue.

type Stack

type Stack[T any] []T

Stack represents a LIFO list.

func (*Stack[T]) Clear

func (s *Stack[T]) Clear()

Clear removes all elements from the stack.

func (*Stack[T]) Peek

func (s *Stack[T]) Peek() T

Peek returns the last element of the stack (or panics if the stack is empty).

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() T

Pop removes the last element of the stack and returns it (or panics if the stack is empty).

func (*Stack[T]) Push

func (s *Stack[T]) Push(i T)

Push adds a new element to the stack.

func (*Stack[T]) PushAll

func (s *Stack[T]) PushAll(i ...T)

PushAll adds several new elements to the stack.

func (*Stack[T]) Size

func (s *Stack[T]) Size() int

Size returns the number of elements in the stack.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL