A Java / Gradle TDD project. The demo class makes use of some Java 8 features i.e. Stream & Lambdas
Optimise lookup by Author & Title.
Internally this is a HashMap<String, Set<String>>
- key: author name
String
. This utilises the built in String hashing function to provide aO(n)
time complexity for lookups - value: set of titles
HashSet<String>
. This enables title entries to be removed withO(n)
complexity
Internally this is also a HashMap<String, Set<String>>
with keys and value reversed compared to the previous index.
- key: book title
String
. This utilises the built in String hashing function to provide aO(n)
time complexity for lookups - value: author name
HashSet<String>
. This enables name entries to be removed withO(n)
complexity
Each add operation will update both:
- Author to Titles Index
- Title to Authors Index
Each remove operation will also update both:
- Author to Titles Index
- Title to Authors Index
NOTE : Removing authors will also remove co-authors for the title