slices

package
v0.1.26 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: MIT Imports: 1 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterNonNil added in v0.1.26

func FilterNonNil[T Pointer](elems []T) []T

FilterNonNil removes all nil elements from the given slice of elements.

This function assumes that the receiver is not nil and that the receiver is not empty.

Returns:

  • []T: The slice of elements with all nils removed.

func MergeEquals added in v0.1.26

func MergeEquals[T interface {
	Equals(other T) bool
}](elems1, elems2 []T) []T

MergeEquals removes all duplicate elements from the given slices of elements using the Equals method.

Parameters:

  • elems1: The first slice of elements.
  • elems2: The second slice of elements.

Returns:

  • []T: The slice of elements with all duplicates removed.

func UniqueEquals added in v0.1.26

func UniqueEquals[T interface {
	Equals(other T) bool
}](elems []T) []T

UniqueEquals removes all duplicate elements from the given slice of elements using the Equals method.

Parameters:

  • elems: The slice of elements.

Returns:

  • []T: The slice of elements with all duplicates removed.

Types

type Pointer added in v0.1.26

type Pointer interface {
	// IsNil checks if the pointer is nil.
	//
	// Returns:
	//   - bool: True if the pointer is nil, false otherwise.
	IsNil() bool
}

Pointer is an interface for a pointer.

Jump to

Keyboard shortcuts

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