dsutils

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: MIT Imports: 0 Imported by: 1

Documentation

Overview

Author: Alex Lewtschuk

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureUnique

func EnsureUnique[Element comparable](slice []Element) []Element

Ensures that any slice passed to the function contains no duplicate values in the slice. Returns a slice that holds all unique values in the original slice. Utilizes a pseudo-set by creating a map holding only index values and an empty struct This usage of a map and empty struct reduces memory overhead as struct{}{} takes up no memory and map utilization ensures O(1) lookup speed

func Remove

func Remove[Element comparable](elementToDelete Element, slice []Element) []Element

Removes any occuences of the element you wish to delete from a slice Returns the slice with the element removed Utilizes the comparable constraint to ensure that the element type is comparable and that the elements are generics so any type can be used

Types

This section is empty.

Jump to

Keyboard shortcuts

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