zarray

package
v0.1.33 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2020 License: MIT Imports: 2 Imported by: 15

Documentation

Overview

Package zarray provides array operations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetInterface

func GetInterface(arr []interface{}, index int, def ...interface{}) (value interface{}, err error)

GetInterface 获取 []interface{} 对应 index 位置的元素

Types

type Array

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

Array 数组的插入、删除、按照下标随机访问操作,数据是interface类型的

func Copy

func Copy(arr interface{}) (array *Array, err error)

Copy 复制一个数组

func New

func New(capacity ...int) (array *Array)

New 数组初始化内存

func (*Array) Add

func (array *Array) Add(index int, value interface{}) (err error)

Set 在 index 位置,插入元素

func (*Array) CapLength

func (array *Array) CapLength() int

CapLength 获取数组容量

func (*Array) Clear

func (array *Array) Clear()

Clear 清空数组

func (*Array) Contains

func (array *Array) Contains(value interface{}) bool

Contains 查找数组中是否有元素

func (*Array) Format

func (array *Array) Format() (format string)

Format 输出数列

func (*Array) Get

func (array *Array) Get(index int, def ...interface{}) (value interface{}, err error)

Get 获取对应 index 位置的元素

func (*Array) Index

func (array *Array) Index(value interface{}) int

Index 通过索引查找数组,索引范围[0,n-1](未找到,返回 -1)

func (*Array) IsEmpty

func (array *Array) IsEmpty() bool

IsEmpty 判断数组是否为空

func (*Array) Length

func (array *Array) Length() int

Length 获取数组长度

func (*Array) Map added in v0.0.17

func (array *Array) Map(fn func(interface{}) interface{}) *Array

ForEcho 遍历生成新数组

func (*Array) Pop

func (array *Array) Pop() (interface{}, error)

Pop 删除末尾元素

func (*Array) Push

func (array *Array) Push(values ...interface{})

Push 向数组尾插入元素

func (*Array) Raw

func (array *Array) Raw() []interface{}

Raw 原始数组

func (*Array) Remove

func (array *Array) Remove(index int, l ...int) (value []interface{}, err error)

Remove 删除 index 位置的元素,并返回

func (*Array) RemoveValue

func (array *Array) RemoveValue(value interface{}) (e interface{}, err error)

RemoveValue 从数组中删除指定元素

func (*Array) Set

func (array *Array) Set(index int, value interface{}) (err error)

Set 修改 index 位置的元素

func (*Array) Shift

func (array *Array) Shift() (interface{}, error)

Shift 删除数组首个元素

func (*Array) Unshift

func (array *Array) Unshift(value interface{}) error

Unshift 向数组头插入元素

type DefData added in v0.1.32

type DefData map[string]interface{}

func (DefData) Bool added in v0.1.32

func (kv DefData) Bool(name string, defaultValue bool) bool

func (DefData) Float64 added in v0.1.32

func (kv DefData) Float64(name string, defaultValue float64) float64

func (DefData) FuncSingle added in v0.1.32

func (kv DefData) FuncSingle(name string, defaultValue func()) func()

func (DefData) Int added in v0.1.32

func (kv DefData) Int(name string, defaultValue int) int

func (DefData) String added in v0.1.32

func (kv DefData) String(name string, defaultValue string) string

Jump to

Keyboard shortcuts

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