示例#1
0
文件: set.go 项目: zaolab/sunnified
func NewSet(data ...interface{}) (li *Set) {
	li = &Set{
		list: NewList(),
		uniq: make(map[interface{}]bool),
	}

	li.ValueGetter = util.ValueGetter(li.list.getvalue)
	li.Extend(data)

	return
}
示例#2
0
文件: list.go 项目: zaolab/sunnified
func NewList(data ...interface{}) (li *List) {
	li = &List{
		list:    make([]interface{}, COMFORT_LEN),
		mutex:   &sync.RWMutex{},
		caplist: COMFORT_LEN,
		exlen:   COMFORT_LEN,
	}

	li.ValueGetter = util.ValueGetter(li.getvalue)
	li.Extend(data)

	return
}
示例#3
0
func NewDict(def interface{}, m ...map[interface{}]interface{}) (d *Dict) {
	d = &Dict{
		dict:  make(map[interface{}]interface{}),
		def:   def,
		mutex: &sync.RWMutex{},
	}
	d.ValueGetter = util.ValueGetter(d.getvalue)

	for _, mp := range m {
		d.Update(mp)
	}

	return
}
示例#4
0
func NewOrderedDict(def interface{}, m ...map[interface{}]interface{}) (d *OrderedDict) {
	d = &OrderedDict{
		prevchain: make(map[interface{}]*datachain),
		def:       def,
		mutex:     &sync.RWMutex{},
		headchain: &datachain{},
	}
	d.ValueGetter = util.ValueGetter(d.getvalue)

	for _, mp := range m {
		d.Update(mp)
	}

	return
}