Implementing a Relation abstract data type (ADT) using a (closed bucket) Hash Table data structure.
A Relation is essentially a generalization of a Map. Whereas a Map demands that each key is unique, a Relation allows for duplicate keys with different values and instead tests that a given key/value pair is unique. It's similar to a MultiMap but only allows for a single instance of a given key/value pair.
This repo contains an interface, Relation.java
, which declares the methods that characterise a Relation. This interface acts as a contract for implementing classes and uses generic typing.
HashRelation.java
is the class implementing Relation.java
with a Hash Table. It relies on a private static inner class, Node
, to generate buckets.
- Example class with main method
- J-Unit test cases