slicesx

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PushOrReplace

func PushOrReplace[T SliceHeapItem[T]](h *SliceHeap[T], item T)

func Unique

func Unique[T comparable](slice []T) []T

Unique returns a new slice containing only the unique values from the input slice. The function preserves the original order of elements.

Types

type SliceHeap

type SliceHeap[T SliceHeapItem[T]] []T

func (SliceHeap[T]) Len

func (h SliceHeap[T]) Len() int

func (SliceHeap[T]) Less

func (h SliceHeap[T]) Less(i, j int) bool

func (*SliceHeap[T]) Pop

func (h *SliceHeap[T]) Pop() any

func (*SliceHeap[T]) Push

func (h *SliceHeap[T]) Push(x any)

func (SliceHeap[T]) Swap

func (h SliceHeap[T]) Swap(i, j int)

type SliceHeapItem

type SliceHeapItem[T any] interface {
	Less(another T) bool
}

type SlicesPool

type SlicesPool[T any] struct {
	// contains filtered or unexported fields
}

func NewSlicesPool

func NewSlicesPool[T any](size int) *SlicesPool[T]

func (*SlicesPool[T]) Get

func (sp *SlicesPool[T]) Get(size int) *[]T

func (*SlicesPool[T]) Put

func (sp *SlicesPool[T]) Put(s *[]T)

Jump to

Keyboard shortcuts

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