code: def add(self, item):
          
          self._check_index()
          # Possibly truncate the history up to the current point.
          self._history = self._history[:self._index + 1]
          # Append the item
          self._history.append(item)
          # Increment the index.
          self._index += 1
          self._check_index()
          # Check that the current element is what was provided to the function.
          assert id(self.current_item) == id(item)
docs: Add an item in the history.