pairslice

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pair

type Pair[K comparable, V any] struct {
	First  K
	Second V
}

Pair represents a key-value pair.

type PairSlice

type PairSlice[K comparable, V any] struct {
	// contains filtered or unexported fields
}

PairSlice represents a slice of key-value pairs.

func New

func New[K comparable, V any](capacity int) *PairSlice[K, V]

New creates a new instance of PairSlice with a specified capacity.

func (*PairSlice[K, V]) Append

func (ps *PairSlice[K, V]) Append(first K, second V)

Append adds the first and second to the end of the slice.

func (*PairSlice[K, V]) First

func (ps *PairSlice[K, V]) First() (K, V, bool)

First returns the first properties in the PairSlice. If the PairSlice is empty, it returns false.

func (*PairSlice[K, V]) Get

func (ps *PairSlice[K, V]) Get(index int) (K, V, bool)

Get returns the properties at the specified index. If the index is out of bounds, it returns false.

func (*PairSlice[K, V]) Last

func (ps *PairSlice[K, V]) Last() (K, V, bool)

Last returns the last properties in the PairSlice. If the PairSlice is empty, it returns false.

func (*PairSlice[K, V]) Len

func (ps *PairSlice[K, V]) Len() int

Len returns the number of elements in the PairSlice.

func (*PairSlice[K, V]) RemoveFirst

func (ps *PairSlice[K, V]) RemoveFirst()

RemoveFirst removes the first element from PairSlice.

func (*PairSlice[K, V]) RemoveLast

func (ps *PairSlice[K, V]) RemoveLast()

RemoveLast removes the last element from PairSlice.

Jump to

Keyboard shortcuts

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