List of Common Data Structures
Java and LensKit provide a number of data structures and utilities that you will likely find useful. They include:
- Map and its implementation HashMap
- List and its implementation ArrayList
- Collections provides useful things like
- Vectors provides useful LensKit math utilities
- fastutil provides the efficient primitive data structures we use in
Vectorsand many other places in LensKit.
Java provides standard implementations of common collection types, such as maps and lists. However, due to historical compatibility considerations in the design of the Java language, these are not very efficient when storing lists or maps of numbers (e.g. longs, ints, and doubles). The Fastutil library provides collection types that are optimized for numbers and other primitives. There is a separate type (and set of implementations) for each combination of content types, following a consistent naming pattern:
Long2DoubleMapis an optimized refinement of
Map<Long,Double>. Use the
Long2DoubleOpenHashMapimplementation instead of Java's
HashMap. LensKit also provides a memory-efficient read-only implementation accessible via
LongListis an optimized refinement of
Interfaces and classes exist for all primitive types, such as
Using Fastutil types saves quite a bit of memory, and it can also save significant computation time (although recent versions of Java decrease the time penalty for not using Fastutil).
The assignments are all configured to output
DEBUG-level log messages to log files under the
build directory when you run them via Gradle.
You can emit additional log messages using SLF4J
Logger objects. We have provided them on most classes you need to modify; if one is missing, you can add it at the top of the class:
private static final Logger logger = LoggerFactory.getLogger(MyClass.class);