stack

package
v1.172.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

* Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. * SPDX-License-Identifier: Apache-2.0

* Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. * SPDX-License-Identifier: Apache-2.0

* Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. * SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IStack

type IStack[T any] interface {
	// Push adds elements to the stack.
	Push(value ...T)
	// PushSequence adds elements to the stack.
	PushSequence(seq iter.Seq[T])
	// Pop removes and returns an element from the stack. Returns ok true if the stack is not empty.
	Pop() (element T, ok bool)
	// Peek returns the element at the top of the stack without removing it.
	Peek() (element T, ok bool)
	// IsEmpty states whether the stack is empty. Returns ok true if the stack is not empty.
	IsEmpty() bool
	// Clear clears all elements from the stack.
	Clear()
	// Values returns all the elements in the stack. The stack will be empty as a result.
	Values() iter.Seq[T]
	// Len returns the number of elements in the stack.
	Len() int
}

IStack specifies the behaviour of a last-in, first-out (LIFO) collection. it is inspired by the work of https://github.com/hayageek/threadsafe/ and https://github.com/golang-collections/collections

func NewStack

func NewStack[T any]() IStack[T]

NewStack returns a stack which is not thread safe

func NewThreadSafeStack

func NewThreadSafeStack[T any]() IStack[T]

NewThreadSafeStack returns a thread safe stack This is inspired from https://github.com/hayageek/threadsafe

type SafeStack

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

func (*SafeStack[T]) Clear

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

func (*SafeStack[T]) IsEmpty

func (s *SafeStack[T]) IsEmpty() bool

func (*SafeStack[T]) Len

func (s *SafeStack[T]) Len() int

func (*SafeStack[T]) Peek

func (s *SafeStack[T]) Peek() (T, bool)

func (*SafeStack[T]) Pop

func (s *SafeStack[T]) Pop() (T, bool)

func (*SafeStack[T]) Push

func (s *SafeStack[T]) Push(value ...T)

func (*SafeStack[T]) PushSequence

func (s *SafeStack[T]) PushSequence(seq iter.Seq[T])

func (*SafeStack[T]) Values

func (s *SafeStack[T]) Values() iter.Seq[T]

type Stack

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

func (*Stack[T]) Clear

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

func (*Stack[T]) IsEmpty

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

func (*Stack[T]) Len

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

func (*Stack[T]) Peek

func (s *Stack[T]) Peek() (element T, ok bool)

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() (element T, ok bool)

Pop the top item of the stack and return it

func (*Stack[T]) Push

func (s *Stack[T]) Push(value ...T)

func (*Stack[T]) PushSequence

func (s *Stack[T]) PushSequence(seq iter.Seq[T])

func (*Stack[T]) Values

func (s *Stack[T]) Values() iter.Seq[T]

Jump to

Keyboard shortcuts

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