collection

package
v0.0.0-...-4b56e16 Latest Latest
Warning

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

Go to latest
Published: May 11, 2017 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback func(item interface{}, key interface{}) interface{}

Callback is a function that will be accepted on iterate methods.

type Collection

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

Collection struct.

func New

func New() *Collection

New collection constructor.

func NewWithItems

func NewWithItems(items map[interface{}]interface{}) *Collection

NewWithItems to init collection with the set of items.

func (*Collection) All

func (c *Collection) All() []interface{}

All returns collection values.

func (*Collection) Count

func (c *Collection) Count() int

Count values in the map.

func (*Collection) Delete

func (c *Collection) Delete(key interface{})

Delete value.

func (*Collection) Foreach

func (c *Collection) Foreach() <-chan Item

Foreach iterates through collection via a channel. Returns Item struct for every iteration.

func (*Collection) Get

func (c *Collection) Get(key interface{}) interface{}

Get value.

func (*Collection) Has

func (c *Collection) Has(key interface{}) bool

Has value.

func (*Collection) Keys

func (c *Collection) Keys() []interface{}

Keys returns collection keys.

func (*Collection) Map

func (c *Collection) Map(callback Callback) *Collection

Map iterates through collection, applying callback function on every item. Returns new instance.

func (*Collection) Set

func (c *Collection) Set(key interface{}, value interface{})

Set value.

func (*Collection) Transform

func (c *Collection) Transform(callback Callback)

Transform iterates through collection, applying callback function on every item. Rather then Map method, transform changes collection itself.

type Item

type Item struct {
	Key   interface{}
	Value interface{}
}

Item structure used while iterating collection.

Jump to

Keyboard shortcuts

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