background image
C H A P T E R 1 1
Data Storage and Retrieval
11-46
Using Newton Data Storage Objects
internationalized index: cursor methods such as
Next
and
Prev
return entries in
the internationally-indexed order.
Queries on Descending Indexes
11
Even though queries and cursors based on descending order indexes work just like
normal queries and cursors, their behavior can seem confusing if you forget that it
is a function of index order. It is always helpful to remember the following points
when working with queries and cursors--especially when using descending indexes:
The "beginning" and "end" of a range of index values is a function of index
key order.
The cursor navigates entries in index key order.
This section provides examples of the behavior of cursors that use descending
indexes. These examples are based on a soup containing the entries shown in the
following code fragment; although this example uses string values, any kind of
index key value may be sorted in descending order.
{data: "able", ...};
{data: "axe", ...};
{data: "name", ...};
{data: "noun", ...};
Soup indexes normally sort string data in ascending alphabetical order; for example,
"able"
,
"axe"
,
"name"
,
"noun"
. A descending index sorts the same data in
reverse alphabetical order; for example,
"noun"
,
"name"
,
"axe"
,
"able"
.
Figure 11-6 depicts the reversed ordering that a descending index provides, with
examples of cursor behavior that is a function of index ordering.
Figure 11-6
Cursor operations on descending index
Descending key order
cursor:Reset();
cursor:GoToKey("az");
cursor:GoToKey("a");
Valid subrange
Z
"noun"
"name"
"az"
"axe"
"able"
A
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна