CPSC 170 Sub Post Lab 10
Two-dimensional Map
Due Before Class on Friday, April 1st

The post lab 10 assignment is to compare the frame rate of games that use an ArrayList and a Map for sprite storage. Storing sprites in an ArrayList is simple, you have done it in multiple previous assignments. Storing sprites in a Map is different because each sprite needs a key to access them. In order to speed up access operation the key should be based on where a sprite is located, so that when rendering the game sprites that are off screen are not retrieved. However, sprites have two values that specify their location, x and y. Therefore, you will need to create a map where two keys map to one value, or a two-dimensional map.

The file Map2D.java contains the outline for a two-dimensional map. It has many of the same methods as the map class that you created in lab. The major difference is that instead of containing a list of keys and values, the two-dimensional map contains a list of lists of keys and values. Each sub-list contains keys with equivalent first dimensions (in the case of sprites this would be the x coordinate). The sub-lists are stored in a sorted list by their first dimension values. For this assignment the sub-lists do not have to be sorted.

Complete the methods of the Map2D class as specified in the comments. Use the JUnit testing file Map2DTest.java to test your code and use Checkstyle to verify formatting.

Submission: Tar and submit your code on the course Inquire site.