literary-screensaver icon indicating copy to clipboard operation
literary-screensaver copied to clipboard

Randomise quote for times with multiple quotes

Open disposedtrolley opened this issue 6 years ago • 0 comments

It would be good if the screensaver selected a random quote if a particular time has multiple quotes associated with it. Currently it always picks the first matching quote that’s found.

This change would require modifying the data structure the quotes are stored in to a hash map, where each key is a time and the corresponding value is an array of quotes. To obtain a quote, we would just need to access the key, and then pick a random element of the corresponding array bounded by its length.

This setup would also make finding the quote more efficient as we no longer need to iterate through the array to search.

disposedtrolley avatar Aug 16 '18 11:08 disposedtrolley