A joke data structure, meant to be a drop-in replacement for any Map in Java.
A TrashMap
works just like any other Map
in Java: it maps keys to values. This data structure, however, is special
in that it uses trash analogies for the data storage. It's also intentionally inefficient.
TrashMap
is loosely based on the HashMap
design: items are stored in various "buckets" (here called TrashCans
),
which contain "entries" (PieceOfTrash
). The main difference is that I wanted to have my trashcans named after different
types of trash, so there are very few of them. As a result, there are intentionally many items stored in each TrashCan
, whereas in a
HashMap
, the storage of multiple entries in one bucket is avoided as much as possible.
The TrashCan
which a given key-value pair will go into is determined by algorithms in the Trashifier
class.
For maximum trash analogy realism, the TrashCan
is implemented as a stack, and it must be "dug" through in a very inefficient
manner to get to the particular piece of trash that the user is looking for.
MIT