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 (*Builder[T, E]) Cap ¶
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 ¶
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 ¶
Len returns the number of accumulated bytes; b.Len() == len(b.String()).
func (*Builder[T, E]) UnsafeString ¶
type Ordered ¶
type Ordered constraints.Ordered