'Add `key` as an item to this OrderedSet, then return its index.
If `key` is already in the OrderedSet, return the index it already
had.'

def add(self, key):

    index = self.map.get(key)
    if (index is None):
        self.map[key] = index = len(self.items)
        self.items.append(key)
    return index
