-- A link associated with two bi-linkable pieces


class
  LINK

  inherit 
    COMPARABLE

  creation 
    make
 
feature 

 make (a_in, b_in : DESIGN_PORTAL; i : INTEGER) is
  require
    a_: a_in /= Void
    b_: b_in /= Void
    others: a_in /= b_in
  do
    a := a_in
    b := b_in
    id := i
  end

  has_piece (x : DESIGN_PORTAL) : BOOLEAN is
  do
    if x = a or x = b then 
      Result := TRUE
    end
  end

  get_other (x : DESIGN_PORTAL) : DESIGN_PORTAL is
  require
    is_there: x = a or x = b
  do 
  if x = a then
    Result := b
  else
    Result := a
  end
  ensure
    Result /= x
    Result = a or Result = b
  end

-- for total ordering...
  infix "<" (other: like Current): BOOLEAN is
  do
    Result := (id < other.id)
  end

  a : DESIGN_PORTAL
  b : DESIGN_PORTAL
	
  id : INTEGER

end -- class LINK

