Beispiel #1
0
func (j *Judy1) ByCount(count uint64) (index uint64, found bool) {
	var ret C.Word_t = 0
	st := C.Judy1ByCount(C.Pcvoid_t(j.val), C.Word_t(count), &ret, nil)
	if st == 1 {
		found = true
		index = uint64(ret)
	}
	return
}
Beispiel #2
0
// Locate the Nth index that is present in the Judy1 array (Nth = 1 returns the first index present).
//
//   nth - nth index to find
//   returns uint64 - nth index (unless return false))
//           bool   - true if the search was successful, false if an index was not found
func (j *Judy1) ByCount(nth uint64) (uint64, bool) {
	var idx C.Word_t

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