public Set keySet() {
  return new MondoKey();
}
public Set entrySet() {
  return new MondoKey(2);
}
public Collection values() {
  return new MondoKey(1);
}

private class	MondoKey extends AbstractSet {
  private int myMapRevId;
  private int personality;
  public MondoKey() {
    myMapRevId = mapRevId ;
    personality = 0;
  }
  public MondoKey(int i) {
    if ( ( i < 0 ) || ( i > 2) )
      throw new UnsupportedOperationException("Only personalities 0-2 are supported");
    myMapRevId = mapRevId ;
    personality = i;
    // etc...
  }
  public Iterator iterator() {
    return new MondoIterator( myMapRevId, personality);
  }
  // etc...
}

private class MondoIterator implements Iterator {
  private int	personality;
  private int itId;

  MondoIterator(int myMapRevId, int p ) {
    itId = myMapRevId;
    personality = p;
    checkChange();
    // etc...
  }
  public boolean hasNext() {
    checkChange();
    // etc...
  }
  private void checkChange() {
    if( itId != mapRevId ) {
      throw new UnsupportedOperationException("Please don't change the keyset while iterating");
    }
  }
  public Object next() {
    checkChange();
    if(hasNext()) {
      KeyPair kp = (KeyPair) nextObject;
      Object theKey;
      switch (personality) {
	case 0: theKey = kp.getKey(); break;
	case 1: theKey = kp.getValue(); break;
	case 2: theKey = kp; break;
	default: throw new UnsupportedOperationException("Only personalities 0-2 are supported");
      }
      // etc...
    }
  }
}
