stack

package
v1.2.23 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Stack

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

Stack represents a reusable LIFO stack which is implemented using an array.

func NewStack

func NewStack[T any]() *Stack[T]

NewStack returns an empty stack

func (*Stack[T]) AsArray

func (p *Stack[T]) AsArray() []T

AsArray returns the contents of this stack as an array

func (*Stack[T]) Clear

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

Clear resets the heap to an empty state whilst retaining any allocated capacity.

func (*Stack[T]) IsEmpty

func (p *Stack[T]) IsEmpty() bool

IsEmpty checks whether or not there are still items on the stack

func (*Stack[T]) Len

func (p *Stack[T]) Len() uint

Len returns the number of items on the stack.

func (*Stack[T]) Peek

func (p *Stack[T]) Peek(offset uint) T

Peek at nth item from top of stack.

func (*Stack[T]) Pop

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

Pop the last item off the stack

func (*Stack[T]) Push

func (p *Stack[T]) Push(item T)

Push a new item onto the stack

func (*Stack[T]) PushAll

func (p *Stack[T]) PushAll(item []T)

PushAll pushes zero or more items onto the stack

func (*Stack[T]) Top

func (p *Stack[T]) Top() *T

Top peeks at the last item on the stack.

Jump to

Keyboard shortcuts

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