/** Return the k most accessed elements, for a given k;  O(k) time */
  public List top(int k) {
    if (k < 0 || k > size())
      throw new IllegalArgumentException("Invalid argument");
    List T = new NodeList(); // top-k list
    if (!isEmpty()) {
      Position p = fList.first();
      for (int i = 1; i < k; i++) {
	T.insertLast(value(p));
	p = fList.next(p);
      }
      T.insertLast(value(p));
    }
    return T;
  }
  /** An overridden toString method, for visualization purposes */
  public String toString() { return fList.toString(); }
  /** Helper method */
  protected Object value(Position p) { return ((Entry) p.element()).value(); }
  /** Helper method */
  protected Entry entry(Position p) { return (Entry) p.element(); }