container

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InterfaceOf

func InterfaceOf(value interface{}) reflect.Type

InterfaceOf dereferences a pointer to an Interface type. It panics if value is not an pointer to an interface.

Types

type Applicator

type Applicator interface {
	// Maps dependencies in the Type map to each field in the struct
	// that is tagged with 'inject'. Returns an error if the injection
	// fails.
	Apply(interface{}) error
}

Applicator represents an interface for mapping dependencies to a struct.

type Injector

type Injector interface {
	Applicator
	Invoker
	TypeMapper
	// SetParent sets the parent of the injector. If the injector cannot find a
	// dependency in its Type map it will check its parent before returning an
	// error.
	SetParent(Injector)
}

Injector represents an interface for mapping and injecting dependencies into structs and function arguments.

func NewInjector

func NewInjector() Injector

New returns a new Injector.

type Invoker

type Invoker interface {
	// Invoke attempts to call the interface{} provided as a function,
	// providing dependencies for function arguments based on Type. Returns
	// a slice of reflect.Value representing the returned values of the function.
	// Returns an error if the injection fails.
	Invoke(interface{}) ([]reflect.Value, error)
}

Invoker represents an interface for calling functions via reflection.

type List added in v0.1.2

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

变长双向链表

func NewList added in v0.1.2

func NewList() *List

获得一个变长链表指针

func (*List) Back added in v0.1.2

func (this *List) Back() *list.Element

获取表位指针

func (*List) BackAll added in v0.1.2

func (this *List) BackAll() []interface{}

从链表尾获取所有数据(不删除)

func (*List) BackItem added in v0.1.2

func (this *List) BackItem() interface{}

获取链表尾值(不删除)

func (*List) BatchPopBack added in v0.1.2

func (this *List) BatchPopBack(max int) []interface{}

批量从链表尾端出栈数据项(删除)

func (*List) BatchPopFront added in v0.1.2

func (this *List) BatchPopFront(max int) []interface{}

批量从链表头端出栈数据项(删除)

func (*List) BatchPushFront added in v0.1.2

func (this *List) BatchPushFront(vs []interface{})

批量往链表头入栈数据项

func (*List) Front added in v0.1.2

func (this *List) Front() *list.Element

获取表头指针

func (*List) FrontAll added in v0.1.2

func (this *List) FrontAll() []interface{}

从链表头获取所有数据(不删除)

func (*List) FrontItem added in v0.1.2

func (this *List) FrontItem() interface{}

获取链表头值(不删除)

func (*List) InsertAfter added in v0.1.2

func (this *List) InsertAfter(v interface{}, mark *list.Element) *list.Element

在list 中元素mark之后插入一个值为v的元素,并返回该元素,如果mark不是list中元素,则list不改变。

func (*List) InsertBefore added in v0.1.2

func (this *List) InsertBefore(v interface{}, mark *list.Element) *list.Element

在list 中元素mark之前插入一个值为v的元素,并返回该元素,如果mark不是list中元素,则list不改变。

func (*List) Len added in v0.1.2

func (this *List) Len() int

获取链表长度

func (*List) PopBack added in v0.1.2

func (this *List) PopBack() interface{}

从链表尾端出栈数据项(删除)

func (*List) PopBackAll added in v0.1.2

func (this *List) PopBackAll() []interface{}

批量从链表尾端依次获取所有数据(删除)

func (*List) PopFront added in v0.1.2

func (this *List) PopFront() interface{}

从链表头端出栈数据项(删除)

func (*List) PopFrontAll added in v0.1.2

func (this *List) PopFrontAll() []interface{}

批量从链表头端依次获取所有数据(删除)

func (*List) PushBack added in v0.1.2

func (this *List) PushBack(v interface{}) *list.Element

往链表尾入栈数据项

func (*List) PushFront added in v0.1.2

func (this *List) PushFront(v interface{}) *list.Element

往链表头入栈数据项

func (*List) Remove added in v0.1.2

func (this *List) Remove(e *list.Element) interface{}

删除数据项

func (*List) RemoveAll added in v0.1.2

func (this *List) RemoveAll()

删除所有数据项

type Map

type Map map[string]interface{}

Map stores objects

func (*Map) Delete

func (s *Map) Delete(key string)

func (*Map) Get

func (s *Map) Get(key string) interface{}

func (*Map) Set

func (s *Map) Set(key string, val interface{})

type TypeMapper

type TypeMapper interface {
	// Maps the interface{} value based on its immediate type from reflect.TypeOf.
	Map(interface{}) TypeMapper
	// Maps the interface{} value based on the pointer of an Interface provided.
	// This is really only useful for mapping a value as an interface, as interfaces
	// cannot at this time be referenced directly without a pointer.
	MapTo(interface{}, interface{}) TypeMapper
	// Provides a possibility to directly insert a mapping based on type and value.
	// This makes it possible to directly map type arguments not possible to instantiate
	// with reflect like unidirectional channels.
	Set(reflect.Type, reflect.Value) TypeMapper
	// Returns the Value that is mapped to the current type. Returns a zeroed Value if
	// the Type has not been mapped.
	Get(reflect.Type) reflect.Value
}

TypeMapper represents an interface for mapping interface{} values based on type.

Jump to

Keyboard shortcuts

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