Exemplo n.º 1
0
func (sn *freeNode) flatten(ca ComparableArray, dataChunk mmm.MemChunk) ComparableArray {
	if sn == nil {
		return ca
	}

	ca = ((*freeNode)(unsafe.Pointer(sn.left))).flatten(ca, dataChunk)
	ca = ((*freeNode)(unsafe.Pointer(sn.right))).flatten(ca, dataChunk)

	return append(ca, dataChunk.Read(int(sn.id)).(Comparable))
}
Exemplo n.º 2
0
func (sn *freeNode) ascend(pivot Comparable, dataChunk mmm.MemChunk) Comparable {
	if sn == nil {
		return nil
	}

	data := dataChunk.Read(int(sn.id)).(Comparable)
	if pivot.Less(data) {
		return ((*freeNode)(unsafe.Pointer(sn.left))).ascend(pivot, dataChunk)
	} else if data.Less(pivot) {
		return ((*freeNode)(unsafe.Pointer(sn.right))).ascend(pivot, dataChunk)
	}

	return data
}