intern

package
v0.0.0-...-e3597af Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2016 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Intern

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

Intern is a mapping from strings to ints. It isn't thread safe. Appropriate handling of race conditions is the responsibility of users.

func Load

func Load(r io.Reader) (*Intern, error)

Load loads the saved data to Intern.

func New

func New() *Intern

New creates a new Intern instance.

func (*Intern) Get

func (i *Intern) Get(s string) int

Get returns an ID for a string. If the string was not registered, this method registers the string and returns an ID. This method is idempotent.

func (*Intern) GetOrZero

func (i *Intern) GetOrZero(s string) int

GetOrZero returns an ID for a string if the string is already registered. If the string is not registered this method returns zero,

func (*Intern) Save

func (i *Intern) Save(w io.Writer) error

Save saves the current state of Intern.

Jump to

Keyboard shortcuts

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