data

package
v1.2.18 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: AGPL-3.0 Imports: 11 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMarshalNil          = errors.New("object is nil")
	ErrMarshalType         = errors.New("invalid object type")
	ErrMarshalNoSize       = errors.New("missing size tag on field")
	ErrMarshalSizeMismatch = errors.New("size mismatch during unmarshal")
	ErrMarshalEmptyIntf    = errors.New("can't handle empty interface")
	ErrMarshalUnknownType  = errors.New("unknown field type")
	ErrMarshalMthdMissing  = errors.New("missing method")
	ErrMarshalFieldRef     = errors.New("field reference invalid")
	ErrMarshalMthdNumArg   = errors.New("method has more than one argument")
	ErrMarshalMthdArgType  = errors.New("method argument not a string")
	ErrMarshalMthdResult   = errors.New("invalid method result")
)

Errors

Functions

func Marshal

func Marshal(obj interface{}) ([]byte, error)

Marshal creates a byte array from a (reference to an) object.

func MarshalStream added in v1.2.15

func MarshalStream(wrt io.Writer, obj interface{}) error

MarshalStream writes an object instance to stream

func Unmarshal

func Unmarshal(obj interface{}, data []byte) error

Unmarshal reads a byte array to fill an object pointed to by 'obj'.

func UnmarshalStream added in v1.2.15

func UnmarshalStream(rdr io.Reader, obj interface{}, pending int) error

UnmarshalStream reads an object from strean.

Types

type BloomFilter

type BloomFilter struct {
	NumBits    uint32 `json:"numBits"`       // number of bits in filter
	NumIdx     uint8  `json:"numIdx"`        // number of indices
	NumIdxBits uint8  `json:"numIdxBits"`    // number of bits per index
	NumHash    uint8  `json:"numHash"`       // number of SHA256 hashes needed
	Bits       []byte `json:"bits" size:"*"` // bit storage
}

A BloomFilter is a space/time efficient set of unique entries. It can not enumerate its elements, but can check if an entry is contained in the set. The check always succeeds for a contained entry, but can create "false-positives" (entries not contained in the map give a positive result). By adjusting the number of bits in the BloomFilter and the number of indices generated for an entry, a BloomFilter can handle a given number of entries with a desired upper-bound for the false-positive rate.

func NewBloomFilter

func NewBloomFilter(numExpected int, falsePositiveRate float64) *BloomFilter

NewBloomFilter creates a new BloomFilter based on the upper-bounds for the number of entries and the "false-positive" rate.

func NewBloomFilterDirect

func NewBloomFilterDirect(numBits, numIdx int) *BloomFilter

NewBloomFilterDirect creates a new BloomFilter based on the number of bits in the filter and the number of indices to be used.

func (*BloomFilter) Add

func (bf *BloomFilter) Add(entry []byte)

Add an entry to the BloomFilter.

func (*BloomFilter) Combine added in v1.1.1

func (bf *BloomFilter) Combine(bf2 *BloomFilter) *BloomFilter

Combine merges two BloomFilters (of same kind) into a new one.

func (*BloomFilter) Contains

func (bf *BloomFilter) Contains(entry []byte) bool

Contains returns true if the BloomFilter contains the given entry, and false otherwise. If an entry was added to the set, this function will always return 'true'. It can return 'true' for entries not in the set ("false-positives").

func (*BloomFilter) SameKind added in v1.1.1

func (bf *BloomFilter) SameKind(bf2 *BloomFilter) bool

SameKind checks if two BloomFilter have the same parameters.

type IntStack

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

IntStack is an Integer-based Stack type and implementation.

func NewIntStack

func NewIntStack() *IntStack

NewIntStack instantiates a new integer-based Stack object.

func (*IntStack) IsTop

func (s *IntStack) IsTop(v int) bool

IsTop compares last element with given value.

func (*IntStack) Len

func (s *IntStack) Len() int

Len returns the number of elements on stack.

func (*IntStack) Peek

func (s *IntStack) Peek() (v int)

Peek at the last element pushed to stack without dropping it.

func (*IntStack) Pop

func (s *IntStack) Pop() (v int)

Pop last entry from stack and return it to caller.

func (*IntStack) Push

func (s *IntStack) Push(v int)

Push entry to stack.

type Stack

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

Stack for generic data types.

func NewStack

func NewStack() *Stack

NewStack instantiates a new generic Stack object.

func (*Stack) Len

func (s *Stack) Len() int

Len returns the number of elements on stack.

func (*Stack) Peek

func (s *Stack) Peek() (v interface{})

Peek at the last element pushed to stack without dropping it.

func (*Stack) Pop

func (s *Stack) Pop() (v interface{})

Pop last entry from stack and return it to caller.

func (*Stack) Push

func (s *Stack) Push(v interface{})

Push generic entry to stack.

type Vector

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

Vector data structure

func NewVector

func NewVector() *Vector

NewVector instantiates a new (empty) Vector object.

func (*Vector) Add

func (vec *Vector) Add(v interface{})

Add element to the end of the vector.

func (*Vector) At

func (vec *Vector) At(i int) (v interface{})

At return the indexed element from vector.

func (*Vector) Delete

func (vec *Vector) Delete(i int) (v interface{})

Delete indexed element from the vector.

func (*Vector) Drop

func (vec *Vector) Drop() (v interface{})

Drop the last element from the vector.

func (*Vector) Insert

func (vec *Vector) Insert(i int, v interface{})

Insert element at given position. Add 'nil' elements if index is beyond the end of the vector.

func (*Vector) Len

func (vec *Vector) Len() int

Len returns the number of elements in the vector.

Jump to

Keyboard shortcuts

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