CS21: Counter

In class Nov 24

Implementing a Counter class

Write a class called Counter that keeps track of how often you see items.

The Counter class will store a list of lists such that each element of the list is an [item, count] pair (where the items are stored in sorted order). For example, the following list of lists counts how often the letters a-f were seen:

[['a', 5], ['b', 6], ['c', 1], ['d', 8], ['f', 2]]

Note that 'e' was never seen so it does not appear in the list.

The Counter class should have a constructor that takes no arguments and initializes the LoL to be empty.

It should also support the following methods:

You will almost certainly want to write two other methods to help:

When you're all done, write some tests to make sure that it works!