November 2018
Intermediate to advanced
300 pages
7h 42m
English
Last, but not least, the data model can be created on the fly and held in memory. A database can be created from an array of preferences, which will hold user ratings for a set of items.
We can proceed as follows. First, we create a FastByIdMap hash map of preference arrays, PreferenceArray, which stores an array of preferences:
FastByIDMap <PreferenceArray> preferences = new FastByIDMap <PreferenceArray> ();
Next, we can create a new preference array for a user that will hold their ratings. The array must be initialized with a size parameter that reserves that many slots in the memory:
PreferenceArray prefsForUser1 = new GenericUserPreferenceArray (10);
Next, we set the user ID for the current preference at the position ...