/**
   * Works on top of PositionalContainer method replaceElement(Position, Object) and
   * InspectableContainer method contains().
   */
  public void swapElements(Position a, Position b) throws InvalidAccessorException {

    // Require that both of the swappees be in this container
    if ((!this.contains(a)) || (!this.contains(b)))
      throw new InvalidAccessorException("Positions do not belong to this container");

    Object aelt = a.element();
    replaceElement(a, b.element());
    replaceElement(b, aelt);
  }
Exemple #2
0
 public String stringfor(Position p) {
   return "" + p.element();
 }
Exemple #3
0
 /**
  * @param pos Position for which string representation is desired
  * @return verbose string representation of <code>pos</code>
  */
 public static String stringfor(Position pos) {
   if (pos == null) return "null position";
   else return "Position with element " + pos.element();
 }