MovieMan – wrapping up
Now that we've covered all of the language and standard library features we're going to cover, it's time to add the finishing touches to MovieMan. There are two modules that need to be modified: movieman.db
and movieman.menu.display
.
The db module
Open up $MOVIEMAN/source/movieman/db.d
. We'll start with fleshing out DBTable
. At the top of its declaration, add the highlighted line as follows:
T[] _items;
bool _sortRequired;
In order for the movies to display in a sensible order, they'll need to be sorted. We could perform the sort every time a movie is added or every time the movies are displayed. The problem with this is that sorting is going to become an expensive operation as more and more movies are added. There are different solutions to make it more efficient, but to keep things simple, we're only going to sort when it's actually needed. This is tracked by _sortRequired
. It should be set each time a new movie is added to the database, so the opOpAssign
member function...