stack

package
v1.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Collector added in v1.2.0

func Collector[T any]() seq.Collector[*Stack[T], T, *Stack[T]]

Types

type Stack

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

Stack implemented using Array.

func From added in v1.2.0

func From[T any](collection seq.Collection[T]) *Stack[T]

Constructing an Stack from other Collection.

func Make added in v1.2.0

func Make[T any](capacity int) *Stack[T]

Constructing an empty Stack with capacity.

func Of added in v1.2.0

func Of[T any](elements ...T) *Stack[T]

Constructing an Stack with variable-length parameters

func (*Stack[T]) AddLast added in v1.2.0

func (a *Stack[T]) AddLast(element T)

Add an element to the top of the stack.

func (*Stack[T]) Capacity added in v1.2.0

func (a *Stack[T]) Capacity() int

Return the capacity of stack.

func (*Stack[T]) Clear

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

Clears all elements, but does not reset the space.

func (*Stack[T]) Clone added in v1.2.0

func (a *Stack[T]) Clone() *Stack[T]

Return a new stack that copies all elements.

func (*Stack[T]) Count added in v1.2.0

func (a *Stack[T]) Count() int

Return the number of elements of stack.

func (*Stack[T]) Iterator added in v1.2.0

func (a *Stack[T]) Iterator() seq.Iterator[T]

Return the Iterator of stack.

func (*Stack[T]) Last added in v1.2.0

func (a *Stack[T]) Last() ref.Ref[T]

Return an element at the top of the stack, but does not remove it. Return None when the stack is empty.

func (*Stack[T]) RemoveLast added in v1.2.0

func (a *Stack[T]) RemoveLast() option.Option[T]

Remove an element from the top of the stack. Return None when the stack is empty.

func (*Stack[T]) Reserve added in v1.2.0

func (a *Stack[T]) Reserve(additional int)

Ensure that stack have enough space before expansion.

Jump to

Keyboard shortcuts

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