Product Documentation

c-treeDB API for C++ - Developers Guide

Previous Topic

Next Topic

CTRecord::AtPercentile

Find a record located at about the given percentile value.

Declaration

void CTRecord::AtPercentile(NINT percent);

Description

CTRecord::AtPercentile() reads the record located at, approximately, the given percentile value.

Percent indicates the percentile value. The valid values for percent are from 0 to 100, indicating 0% to 100%. CTRecord::AtPercentile() return CTDBRET_OK on success.

The record is located using the record handle current index. You may select a new current index by calling the CTRecord::SetDefaultIndex() method. The table must have at least one index to be able to use this function.

The record returned is an approximation location indicated by the percentile value passed to CTRecord::AtPercentile().

CTRecord::AtPercentile(), which is based on c-tree low level function KeyAtPercentile(), and it is very efficient since it does not traverse all of the key values in order to determine the record located at the specified percentile. However, CTRecord::AtPercentile() is only an approximation since it assumes that key values are uniformly distributed among all of the b-tree leaf nodes.

CTRecord::AtPercentile() may be used to support scroll bar positioning, found in many GUI windowing environments, in the cases when the position must be maintained in key sequential order.

Return

CTRecord::AtPercentile() throws a CTException exception object if no record cannot be located.

See "c-treeDB Errors and Return Values" for a complete listing of valid c-treeDB error codes and return values.

Example


pRec->Clear

pRec->AtPercentile(40);

See also

CTIndex::SetDefault()

TOCIndex