pair

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type B

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

B is used to handle the builder use case.

func Builder

func Builder[K, V any]() *B[K, V]

Builder is used to create a builder for creating Pair type.

func (*B[K, V]) Build

func (b *B[K, V]) Build() *Pair[K, V]

Build is used to get the built instance of the Pair type.

func (*B[K, V]) First

func (b *B[K, V]) First(f K) *B[K, V]

First is used to assign value to the first value in the pair.

func (*B[K, V]) Second

func (b *B[K, V]) Second(s V) *B[K, V]

Second is used to assign value to the second value in the pair.

type Pair

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

Pair is used to handle use cases where a pair of values have to be handled. For example, coordinates x and y.

func New

func New[K, V any](f K, s V) *Pair[K, V]

New is used to create a new object for the struct.

func NewFromCollection

func NewFromCollection[K any](l []K) *Pair[K, K]

NewFromCollection is used to create a new Pair from the given collection. The collection should contain exactly 2 elements, first element of which becomes first and second element becomes second. If the collection contains more or less than 2 elements, then it returns NIL Pair.

func (*Pair[K, _]) GetFirst

func (p *Pair[K, _]) GetFirst() K

GetFirst is used to get the first value.

func (*Pair[_, V]) GetSecond

func (p *Pair[_, V]) GetSecond() V

GetSecond is used to get the second value.

func (*Pair[K, _]) SetFirst

func (p *Pair[K, _]) SetFirst(f K)

SetFirst is used to get the first value.

func (*Pair[_, V]) SetSecond

func (p *Pair[_, V]) SetSecond(s V)

SetSecond is used to get the second value.

Jump to

Keyboard shortcuts

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