func (array *Array) RemoveValue(value interface{}) (e interface{}, err error) {
	index := array.Index(value)
	if index != -1 {
		e, err = array.Remove(index)
	}
	return
}
RemoveValue removes the specified element from the array
package zarray
import (
	"errors"
	"fmt"
)
type Array struct {
	data []interface{}
	size int
}
var ERR_ILLEGAL_INDEX = errors.New("illegal index")
func New(capacity ...int) (array *Array) {
	if len(capacity) >= 1 && capacity[0] != 0 {
		array = &Array{
			data: make([]interface{}, capacity[0]),
			size: 0,
		}
	} else {
		array = &Array{
			data: make([]interface{}, 10),
			size: 0,
		}
	}
	return
}
func Copy(arr interface{}) (array *Array, err error) {
	data, ok := arr.([]interface{})
	if ok {
		l := len(data)
		array = New(l)
		for i := 0; i < l; i++ {
			array.Push(data[i])
		}
	} else {
		err = errors.New("type of error")
	}
	return
}
func (array *Array) checkIndex(index int) (bool, int) {
	size := array.size
	if index < 0 || index >= size {
		return true, size
	}
	return false, size
}
func (array *Array) resize(capacity int) {
	newArray := make([]interface{}, capacity)
	for i := 0; i < array.size; i++ {
		newArray[i] = array.data[i]
	}
	array.data = newArray
}
func (array *Array) CapLength() int {
	return cap(array.data)
}
func (array *Array) Length() int {
	return array.size
}
func (array *Array) IsEmpty() bool {
	return array.size == 0
}
func (array *Array) Unshift(value interface{}) error {
	return array.Add(0, value)
}
func (array *Array) Push(values ...interface{}) {
	for i := 0; i < len(values); i++ {
		_ = array.Add(array.size, values[i])
	}
}
func (array *Array) Add(index int, value interface{}) (err error) {
	if index < 0 || index > array.size {
		err = errors.New("sdd failed. Require index >= 0 and index <= size")
		return
	}
	capLen := array.CapLength()
	if array.size == capLen {
		array.resize(capLen * 2)
	}
	for i := array.size - 1; i >= index; i-- {
		array.data[i+1] = array.data[i]
	}
	array.data[index] = value
	array.size++
	return
}
func (array *Array) Map(fn func(interface{}) interface{}) *Array {
	values, _ := Copy(array.data)
	for i := 0; i < values.Length(); i++ {
		value, _ := values.Get(i)
		_ = values.Set(i, fn(value))
	}
	return values
}
func (array *Array) Get(index int, def ...interface{}) (value interface{}, err error) {
	if r, _ := array.checkIndex(index); r {
		err = ERR_ILLEGAL_INDEX
		if dValue, dErr := GetInterface(def, 0, nil); dErr == nil {
			value = dValue
		}
		return
	}
	value = array.data[index]
	return
}
func (array *Array) Set(index int, value interface{}) (err error) {
	if r, _ := array.checkIndex(index); r {
		return ERR_ILLEGAL_INDEX
	}
	array.data[index] = value
	return
}
func (array *Array) Contains(value interface{}) bool {
	for i := 0; i < array.size; i++ {
		if array.data[i] == value {
			return true
		}
	}
	return false
}
func (array *Array) Index(value interface{}) int {
	for i := 0; i < array.size; i++ {
		if array.data[i] == value {
			return i
		}
	}
	return -1
}
func (array *Array) Remove(index int, l ...int) (value []interface{}, err error) {
	r, size := array.checkIndex(index)
	if r {
		err = ERR_ILLEGAL_INDEX
		return
	}
	removeL := 1
	if len(l) > 0 && l[0] > 1 {
		removeL = l[0]
	}
	value = make([]interface{}, removeL)
	copy(value, array.data[index:index+removeL])
	for i := index + removeL; i < array.size; i++ {
		array.data[i-removeL] = array.data[i]
		array.data[i] = nil
	}
	array.size = size - removeL
	capLen := array.CapLength()
	if array.size == capLen/4 && capLen/2 != 0 {
		array.resize(capLen / 2)
	}
	return
}
func (array *Array) Shift() (interface{}, error) {
	return array.Remove(0)
}
func (array *Array) Pop() (interface{}, error) {
	return array.Remove(array.size - 1)
}