indexedset

package
v0.0.0-...-699f83c Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package indexedset provides a generic set that assigns a stable index to each unique key.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IndexedSet

type IndexedSet[K comparable] struct {
	// contains filtered or unexported fields
}

IndexedSet is a set that assigns a stable index to each unique key added to it.

func New

func New[K comparable](size int) *IndexedSet[K]

New returns a new IndexedSet instance.

func (*IndexedSet[K]) Add

func (s *IndexedSet[K]) Add(k K) int32

Add adds a key and returns its index in the set.

func (*IndexedSet[K]) AddSlice

func (s *IndexedSet[K]) AddSlice(ks []K) []int32

AddSlice adds all the keys from the slice and returns all the corresponding indexes.

func (*IndexedSet[K]) Size

func (s *IndexedSet[K]) Size() int

Size returns the number of entries in the set.

func (*IndexedSet[K]) Subset

func (s *IndexedSet[K]) Subset(indexes []int32) []K

Subset returns all the keys corresponding to the provided indexes.

func (*IndexedSet[K]) UniqueKeys

func (s *IndexedSet[K]) UniqueKeys() []K

UniqueKeys returns all the unique keys in the set, in insertion order. It returns a reference which should not be modifed by the caller (unless the caller is done with the IndexedSet completely)

Jump to

Keyboard shortcuts

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