list

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ElemKey

func ElemKey(index uint64) []byte

Key for the elements of the list

func LengthKey

func LengthKey() []byte

Key for the length of the list

Types

type List

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

List defines an integer indexable mapper It panics when the element type cannot be (un/)marshalled by the codec

func NewList

func NewList(cdc *codec.Codec, store types.KVStore) List

NewList constructs new List

func (List) Delete

func (m List) Delete(index uint64)

Delete() deletes the element in the given position Other elements' indices are preserved after deletion Panics when the index is out of range

func (List) Get

func (m List) Get(index uint64, ptr interface{}) error

Get() returns the element by its index

func (List) Iterate

func (m List) Iterate(ptr interface{}, fn func(uint64) bool)

CONTRACT: No writes may happen within a domain while iterating over it.

func (List) Len

func (m List) Len() (res uint64)

Len() returns the length of the list The length is only increased by Push() and not decreased List dosen't check if an index is in bounds The user should check Len() before doing any actions

func (List) Push

func (m List) Push(value interface{})

Push() inserts the element to the end of the list It will increase the length when it is called

func (List) Set

func (m List) Set(index uint64, value interface{})

Set() stores the element to the given position Setting element out of range will break length counting Use Push() instead of Set() to append a new element

Jump to

Keyboard shortcuts

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