Beispiel #1
0
func (this *OrderedDictIterator) Next(val ...interface{}) (ok bool) {
	this.mutex.RLock()
	defer this.mutex.RUnlock()

	if this.seek == nil {
		this.seek = this.headchain
	} else {
		this.seek = this.seek.next
	}

	if ok = this.seek != nil; ok {
		this.key = this.seek.key
		this.value = this.seek.value

		if lenval := len(val); lenval == 1 {
			util.MapValue(val[0], this.value)
		} else if lenval == 2 {
			util.MapValue(val[0], this.key)
			util.MapValue(val[1], this.value)
		}
	} else {
		this.key = nil
		this.value = nil
	}

	return
}
Beispiel #2
0
func (this *ListIterator) Next(val ...interface{}) (ok bool) {
	defer func() {
		if err := recover(); err != nil {
			ok = false
			this.seek = 0
			this.mutex.RLock()
			this.len = len(this.list)
			this.mutex.RUnlock()
		}
	}()

	if this.seek < this.len {
		ok = true

		this.mutex.RLock()
		defer this.mutex.RUnlock()
		this.curi = this.seek
		this.curval = this.list[this.seek]

		if lenval := len(val); lenval == 1 {
			util.MapValue(val[0], this.curval)
		} else if lenval == 2 {
			util.MapValue(val[0], this.curi)
			util.MapValue(val[1], this.curval)
		}

		this.seek++
	} else {
		this.curi = -1
		this.curval = nil
		this.seek = 0
	}

	return
}
Beispiel #3
0
func (this *QueueIterator) PopNext(val ...interface{}) (ok bool) {
	if this.curval, ok = this.queue.PullOk(); ok {
		this.curi++

		if lenval := len(val); lenval == 1 {
			util.MapValue(val[0], this.curval)
		} else if lenval == 2 {
			util.MapValue(val[0], this.curi)
			util.MapValue(val[1], this.curval)
		}
	} else {
		this.curi = -1
		this.curval = nil
		this.seek = nil
	}

	return
}
Beispiel #4
0
func (this *Context) MapResourceValue(name string, ref interface{}) (err error) {
	this.mutex.RLock()
	defer this.mutex.RUnlock()

	if val, ok := this.resource[name]; ok && ref != nil {
		return util.MapValue(ref, val)
	}

	return ErrResourceNotFound
}
Beispiel #5
0
func (this *DictIterator) Next(val ...interface{}) bool {
	if !this.initd {
		this.init()
	}

	keyval, ok := <-this.kvchan

	if !ok {
		this.curkv = [2]interface{}{nil, nil}
		this.initd = false
		return false
	}

	this.curkv = keyval

	if lenval := len(val); lenval == 1 {
		util.MapValue(val[0], keyval[1])
	} else if lenval == 2 {
		util.MapValue(val[0], keyval[0])
		util.MapValue(val[1], keyval[1])
	}

	return true
}
Beispiel #6
0
func (this *QueueIterator) Next(val ...interface{}) (ok bool) {
	this.mutex.RLock()
	defer this.mutex.RUnlock()

	if this.seek != nil {
		ok = true
		this.curi++
		this.curval = this.seek.data
		this.seek = this.seek.next

		if lenval := len(val); lenval == 1 {
			util.MapValue(val[0], this.curval)
		} else if lenval == 2 {
			util.MapValue(val[0], this.curi)
			util.MapValue(val[1], this.curval)
		}
	} else {
		this.curi = -1
		this.curval = nil
		this.seek = this.queue.head
	}

	return
}
Beispiel #7
0
func (this *List) MapValue(index int, value interface{}) (val interface{}) {
	if val = this.Get(index); val != nil && value != nil {
		util.MapValue(value, val)
	}
	return
}
Beispiel #8
0
func (this *Dict) MapValue(key interface{}, value interface{}) (val interface{}) {
	if val = this.Get(key); val != nil && value != nil {
		util.MapValue(value, val)
	}
	return
}