list

package
v0.0.0-...-24ca9bf Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append[T any, E ~[]T](list E, item T) E

Append appends an item to the end of a list. This a redundant wrapper around the built-in append and is used for testing purposes.

func Insert

func Insert[T comparable, E ~[]T](list E, item T, pos int) E

Insert is a generic slice operation that inserts an item at position pos. If pos is invalid, item is appended to the end of the list.

func InsertSorted

func InsertSorted[T constraints.Ordered, E ~[]T](list E, s T) E

InsertSorted inserts s into the list in sorted order.

func Remove

func Remove[T constraints.Ordered, E ~[]T](slice E, pos int) E

Types

type Builder

type Builder[T Ordered, E ~[]T] struct {
	// contains filtered or unexported fields
}

A Builder is used to efficiently build a list of Ordered objects using Write methods. It minimizes memory copying. The zero value is ready to use. Do not copy a non-zero Builder.

func New

func New[T Ordered, E ~[]T](list E) *Builder[T, E]

func (*Builder[T, E]) Cap

func (b *Builder[T, E]) Cap() int

Cap returns the capacity of the builder's underlying byte slice. It is the total space allocated for the string being built and includes any bytes already written.

func (*Builder[T, E]) Grow

func (b *Builder[T, E]) Grow(n int)

Grow grows b's capacity, if necessary, to guarantee space for another n bytes. After Grow(n), at least n bytes can be written to b without another allocation. If n is negative, Grow panics.

func (*Builder[T, E]) Len

func (b *Builder[T, E]) Len() int

Len returns the number of accumulated bytes; b.Len() == len(b.String()).

func (*Builder[T, E]) Reset

func (b *Builder[T, E]) Reset()

Reset resets the Builder to be empty.

func (*Builder[T, E]) String

func (b *Builder[T, E]) String() string

String returns the accumulated string.

func (*Builder[T, E]) UnsafeString

func (b *Builder[T, E]) UnsafeString() string

func (*Builder[T, E]) Write

func (b *Builder[T, E]) Write(p E) (int, error)

Write appends the contents of p to b's buffer. Write always returns len(p), nil.

type Ordered

type Ordered constraints.Ordered

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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