Example #1
0
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
}
Example #2
0
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
}
Example #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
}
Example #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
}