diff options
Diffstat (limited to 'labb3/tiles/TileList.h')
| -rw-r--r-- | labb3/tiles/TileList.h | 53 |
1 files changed, 44 insertions, 9 deletions
diff --git a/labb3/tiles/TileList.h b/labb3/tiles/TileList.h index 10cfdfb..3b5081f 100644 --- a/labb3/tiles/TileList.h +++ b/labb3/tiles/TileList.h @@ -12,15 +12,50 @@ class TileList { public: - TileList(); // allocate an empty tile list - ~TileList(); // deallocate the tile list - void addTile(Tile tile); // add a tile to the tile list, possibly reallocating - void drawAll(QGraphicsScene *scene) const; // draw all tiles to `scene` - int indexOfTopTile(int x, int y) const; // return index of top tile at (x, y) - void lower(int x, int y); // move the top tile at (x, y) to the bottom - void raise(int x, int y); // move the bottom tile at (x, y) to the top - void remove(int x, int y); // remove the top tile at (x, y) - void removeAll(int x, int y); // remove all tiles at (x, y) + /* + * Create and allocate an empty tile list. + */ + TileList(); + + /* + * Deallocate the tile list. + */ + ~TileList(); + + /* + * Add `tile` to the tile list, possibly reallocating. O(1) amortized. + */ + void addTile(Tile tile); + + /* + * Draw all tiles to `scene`. O(n). + */ + void drawAll(QGraphicsScene *scene) const; + + /* + * Return the index of the top tile at (x, y). O(n). + */ + int indexOfTopTile(int x, int y) const; + + /* + * Move the top tile at (x, y) to the bottom. O(n). + */ + void lower(int x, int y); + + /* + * Move the bottom tile at (x, y) to the top. O(n). + */ + void raise(int x, int y); + + /* + * Remove the top tile at (x, y). O(n). + */ + void remove(int x, int y); + + /* + * Remove all tiles at (x, y). O(n^2). + */ + void removeAll(int x, int y); private: static const int INITIAL_SIZE = 10; // the initial size |
