stack

package
v0.0.0-...-5c15ff0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStackOutOfBounds = errors.New("stack: out of bounds")
	ErrTileNotFound     = errors.New("could not find the given tile")
)

Functions

This section is empty.

Types

type Comparable

type Comparable[T any] interface {
	Equals(T) bool
}

type Stack

type Stack[T Comparable[T]] struct {
	// contains filtered or unexported fields
}

func New

func New[T Comparable[T]](tiles []T) Stack[T]

New creates new Stack and shuffles it using current time as seed. NODE: Input slice is not copied.

func NewOrdered

func NewOrdered[T Comparable[T]](tiles []T) Stack[T]

NewOrdered creates new Stack and maintains original order. NODE: Input slice is not copied.

func NewSeeded

func NewSeeded[T Comparable[T]](tiles []T, seed int64) Stack[T]

NewSeeded creates new Stack and shuffles it using the provided seed. NODE: Input slice is not copied.

func (Stack[T]) DeepClone

func (s Stack[T]) DeepClone() Stack[T]

func (Stack[T]) Get

func (s Stack[T]) Get(n int32) (T, error)

func (Stack[T]) GetRemaining

func (s Stack[T]) GetRemaining() []T

func (Stack[T]) GetRemainingTileCount

func (s Stack[T]) GetRemainingTileCount() int32

func (Stack[T]) GetTiles

func (s Stack[T]) GetTiles() []T

returns the original tiles slice (input to constructor), not a shuffled slice

func (Stack[T]) GetTotalTileCount

func (s Stack[T]) GetTotalTileCount() int32

func (*Stack[T]) MoveToTop

func (s *Stack[T]) MoveToTop(tile T) error

func (*Stack[T]) Next

func (s *Stack[T]) Next() (T, error)

func (Stack[T]) Peek

func (s Stack[T]) Peek() (T, error)

Jump to

Keyboard shortcuts

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