slist

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: Artistic-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type List

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

List is goroutine safe slice

func New

func New[T any](len, cap int) *List[T]

func (*List[T]) Append

func (p *List[T]) Append(data ...T)

func (*List[T]) Clear

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

func (*List[T]) Clone

func (p *List[T]) Clone() (data []T)

func (*List[T]) First

func (p *List[T]) First() (ret T, ok bool)

First return the first element of p if p.Len=0, then ok is false

func (*List[T]) Get

func (p *List[T]) Get(i int) T

func (*List[T]) GetDefault

func (p *List[T]) GetDefault(i int, v T) T

GetDefault return the value place at position i when i doesn't exist in list, then return v without panic

func (*List[T]) Last

func (p *List[T]) Last() (ret T, ok bool)

Last return the last element of p if p.Len=0, then ok is false

func (*List[T]) Len

func (p *List[T]) Len() int

func (*List[T]) Range

func (p *List[T]) Range(f func(index int, item T) bool)

Range iter element of p with f if f return false, then break the range note: do not call any p's function inside f, otherwise will occur deadlock

func (*List[T]) Remove

func (p *List[T]) Remove(i int, num int)

Remove removes elements which index from i to i+num if i is -1 will remove the last element if num is -1 will remove all elements which index after i example: Remove(-1, 1) will remove the last element

func (*List[T]) Set

func (p *List[T]) Set(i int, d T)

Jump to

Keyboard shortcuts

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