O'Reilly logo

Java™ ME Game Programming, Second Edition by Ph.D. Martin J. Wells, Ph.D. John P. Flynt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using a RecordComparator Object

As mentioned previously, a comparator is an algorithm for ordering the items. An object of the RecordComparator type is used as the first argument to the RecordStore::enumerateRecords() method. In many cases, a sorting algorithm is not needed for an enumeration, because the order in which items are assigned to a RecordStore can be inspected iteratively with relative ease. On the other hand, at times being able to order items becomes essential. The RecordComparator interface in this respect becomes extremely helpful.

At the core of the interface is the compare() method. It is the only visible method in the RecordComparator interface. As shown in Table 8.4, this method takes two arguments, both arrays of the byte ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required