key

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2017 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package key contains a single Key interface. The key package was created to prevent cicular dependencies between "github.com/lleo/go-hamt" and either "github.com/lleo/go-hamt/hamt32" or "github.com/lleo/go-hamt/hamt64".

Additionally, the github.com/lleo/go-hamt/key provides a Base structure. The Base structure if added to a derivative key type will provide the Hamt30() and Hamt60() methods. Base needs to be populated by the derivative key constructor calling the Initialize([]byte) method.

Any key created using the Key interface must be read only after construction.

The key package is used by the functional HAMT variation in "github.com/lleo/go-hamt-functional".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

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

Base struct is intended to be the base struct of all structs that satisfy Key interface. It caches the calculated hash30 and hash60 generated when the method Initialize([]byte) is called.

func (*Base) Hash30

func (kb *Base) Hash30() uint32

Hash30 returns the uint32 that contains the 30bit hash value.

func (*Base) Hash60

func (kb *Base) Hash60() uint64

Hash60 returns the uint32 that contains the 60bit hash value.

func (*Base) Initialize

func (kb *Base) Initialize(bs []byte)

Initialize the Base part of any struct that has the Base struct embedded. will be called by the New() function of any descendant class.

k.Initialize(bs)

where k is interpreted as a *Base and bs is a unique []byte to calculate the 30bit hash from.

func (*Base) String

func (kb *Base) String() string

String provides a human readable form of the Base's hash30 and hash60 values. Both in raw integer and slash '/' separated integers of the 5 and 6 bit path values; for hash30 and hash60 respectively.

type Key

type Key interface {
	String() string // ISA/statisfies fmt.Stringer interface
	Equals(Key) bool
	Hash30() uint32
	Hash60() uint64
}

Key interface descibes the methods any struct needs to implement to be used in either the github.com/lleo/go-hamt or github.com/lleo/go-hamt-functional packages.

type KeyVal

type KeyVal struct {
	Key Key
	Val interface{}
}

KeyVal is a simple struct used to transfer lists ([]KeyVal) from one function to another.

func (KeyVal) String

func (kv KeyVal) String() string

Jump to

Keyboard shortcuts

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