pair

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: MIT Imports: 2 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractFirsts

func ExtractFirsts[A, B any](pairs []Pair[A, B]) []A

ExtractFirsts extracts all the first elements from the given slice of pairs.

Parameters:

  • pairs: The slice of pairs.

Returns:

  • []A: The slice of first elements.

func ExtractSeconds

func ExtractSeconds[A, B any](pairs []Pair[A, B]) []B

ExtractSeconds extracts all the second elements from the given slice of pairs.

Parameters:

  • pairs: The slice of pairs.

Returns:

  • []B: The slice of second elements.

Types

type Pair

type Pair[A, B any] struct {
	// The first value.
	First A

	// The second value.
	Second B
}

Pair is a pair of values.

func NewPair

func NewPair[A, B any](first A, second B) Pair[A, B]

NewPair creates a new pair.

Parameters:

  • first: The first value.
  • second: The second value.

Returns:

  • Pair[A, B]: The new pair.

func (Pair[A, B]) String

func (p Pair[A, B]) String() string

String implements the fmt.Stringer interface.

Jump to

Keyboard shortcuts

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