next up previous
Next: Spatial Data Structure Up: MeeshQuest Components Previous: MeeshQuest Components

Dictionary Data Structure

A dictionary data structure is one which is capable of storing objects in sorted order based on key such as a string or an integer. For instance, you might have several hundred City objects which consist of the name of the city, the latitude and longitude at which it is located, and the radius or expanse of the city limits. One way of storing these cities is to sort them by name; another is to store them in decreasing order by population; yet another is in increasing order by latitude. So, from a programming standpoint, you have the same objects, but represent them using different attributes and an appropriate comparator.

To manage a structure based on the names of cities, you would not need a comparator for cities; but, rather, since the keys are city names (strings), your comparator would need to handle strings. So to compare cities by name in Java 8.0, your comparator might look like this:

public class CityNameComparator implements Comparator<String> {
    public int compare (String s1, String s2) {
        // however you want to do string comparison
        return 
    }
}

In this project you'll create a dictionary of cities and attractions, with the entry associated with each of these items consisting of a unique item name, the unique location of the item, and other attributes which may be relevant to the MeeshQuest applications. You will generate two indexes into this data dictionary: one which accesses the cities by name, and the other which identifies the cities based on their coordinates.


next up previous
Next: Spatial Data Structure Up: MeeshQuest Components Previous: MeeshQuest Components
MM Hugue 2019-05-28