idtable

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// UninitializedEntryID provides an invalid value for EntryID (since
	// its default value is valid). Entries removed from the table will be
	// set to this ID.
	UninitializedEntryID = EntryID{-1}
)

Functions

This section is empty.

Types

type Entry

type Entry interface {
	// SetID will set the id of an entry on a table when AddEntry() is
	// called. The id can be used in the GetEntry() and RemoveEntry() calls.
	SetID(id EntryID)
}

Entry is an interface for table entries

type EntryID

type EntryID struct {
	ID int
}

EntryID is a table entry identifier NB: we wrap this to get some type safety for the SetID() methof of the Entry interface

type Table

type Table struct {
	// contains filtered or unexported fields
}

Table is the id table

func New

func New() *Table

New allocates a new id table

func (*Table) AddEntry

func (t *Table) AddEntry(entry Entry)

AddEntry will add an entry to the table. The SetID() method will be called with the id for the entry.

func (*Table) GetEntry

func (t *Table) GetEntry(id EntryID) (Entry, error)

GetEntry returns an entry or an error

func (*Table) Len

func (t *Table) Len() int

Len returns the number of entries

func (*Table) RemoveEntry

func (t *Table) RemoveEntry(id EntryID) (Entry, error)

RemoveEntry removes an entry and returns it (or an error if entry does not exist) before returned, SetID(UninitializedEntryID) is called

Jump to

Keyboard shortcuts

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