Esempio n. 1
0
func (j *Judy1) Prev(index uint64) (prevIndex uint64, found bool) {
	index0 := C.Word_t(index)
	st := C.Judy1Prev(C.Pcvoid_t(j.val), &index0, nil)
	if st != 0 {
		prevIndex = uint64(index0)
		found = true
	}
	return
}
Esempio n. 2
0
// Search (exclusive) for the last index present that is less than the passed index.
// This is typically used to continue a reverse sorted-order scan of the indexes present in a Judy1 array.
//
//   index - search index
//   returns uint64 - value of the last index that is less than the passed index (only if bool return value is true)
//           bool   - true if the search was successful, false if an index was not found
func (j *Judy1) Prev(index uint64) (uint64, bool) {
	var idx C.Word_t = C.Word_t(index)

	if C.Judy1Prev(C.Pcvoid_t(j.array), &idx, nil) != 0 {
		return uint64(idx), true
	} else {
		return 0, false
	}
}