cardlist

package
v0.0.0-...-b5b985d Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CardList

type CardList struct {
	// contains filtered or unexported fields
}

CardList is an attempt to represent a queue of cards using a linked list.

func NewCardList

func NewCardList() *CardList

NewCardList returns a simple empty list.

func NewCardListFromSlice

func NewCardListFromSlice(cards []*card.Card) *CardList

NewCardListFromSlice accepts a slice of cards and constructs a list which is returned.

func NewStandardCardList

func NewStandardCardList() *CardList

NewStandardCardList constructs a 52 card deck.

func (*CardList) Head

func (cl *CardList) Head() (*card.Card, error)

Head returns the head card from the list without popping it, otherwise returns error.

func (*CardList) Len

func (cl *CardList) Len() int

Len returns the length of the list.

func (*CardList) PopCard

func (cl *CardList) PopCard() (*card.Card, error)

PopCard pops the head card from the list if it exists, otherwise returns error.

func (*CardList) PopCardIndex

func (cl *CardList) PopCardIndex(index int) (*card.Card, error)

PopCardIndex pops a card at a specified index, otherwise returns error.

func (*CardList) PushCard

func (cl *CardList) PushCard(c *card.Card)

PushCard pushes a card to the head of the list.

func (*CardList) Shuffle

func (cl *CardList) Shuffle()

Shuffle randomly arranges the ordering of elements of the list.

func (*CardList) Slice

func (cl *CardList) Slice() []*card.Card

func (*CardList) String

func (cl *CardList) String() string

String returns a string representing the list.

type CardListNode

type CardListNode struct {
	// contains filtered or unexported fields
}

func NewCardListNode

func NewCardListNode(c *card.Card) *CardListNode

NewCardListNode constructs a new CardListNode from a Card.

Jump to

Keyboard shortcuts

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