de.rwth.utils
Class Position

java.lang.Object
  |
  +--de.rwth.utils.Position

public class Position
extends java.lang.Object

Describes positions in a tree as sequence of child selection indices from the root.

Version:
$Id: Position.java,v 1.2 2002/09/17 06:53:53 mohnen Exp $
Author:
Markus Mohnen

Inner Class Summary
 class Position.Entry
          Describes a single child selection index;
 
Field Summary
protected  java.util.Stack stack
          The representation of the position.
 
Constructor Summary
Position()
          Creates a new Position instance.
 
Method Summary
 boolean empty()
          Checks if the Position has no entries.
 Position.Entry get(int i)
          Returns the element at the specified index (0 for beginning).
 boolean isBelow(Position p)
          Checks if this position is below another position p.
 java.util.Iterator iterator()
          Returns an iterator over the entries in this position in proper sequence.
 Position.Entry peek()
          Looks at the object at the top of this position without removing it.
 Position.Entry pop()
          Removes the entry at the top of this posotion and returns that entry.
 void push(java.lang.Object o, int i)
          Creates a new Entry and pushes it onto the top of this position.
 void push(Position.Entry e)
          Pushes an entry onto the top of this position.
 int size()
          Returns the number of components.
 java.lang.String toShortString()
          Creates a short string representation by omitting the objects in the entries.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

stack

protected java.util.Stack stack
The representation of the position.
Constructor Detail

Position

public Position()
Creates a new Position instance.
Method Detail

empty

public boolean empty()
Checks if the Position has no entries.
Returns:
a boolean value

peek

public Position.Entry peek()
Looks at the object at the top of this position without removing it.
Returns:
an Entry value

size

public int size()
Returns the number of components.
Returns:
an int value

push

public void push(Position.Entry e)
Pushes an entry onto the top of this position.
Parameters:
e - an Entry value

push

public void push(java.lang.Object o,
                 int i)
Creates a new Entry and pushes it onto the top of this position.
Parameters:
o - an Object value
i - an int value

pop

public Position.Entry pop()
Removes the entry at the top of this posotion and returns that entry.
Returns:
an Entry value

get

public Position.Entry get(int i)
Returns the element at the specified index (0 for beginning). If the position is less than zero, the positive index counts from the end of the position.
Parameters:
i - an int value: postion
Returns:
an Entry value

iterator

public java.util.Iterator iterator()
Returns an iterator over the entries in this position in proper sequence.
Returns:
an Iterator value

isBelow

public boolean isBelow(Position p)
Checks if this position is below another position p. This is the case iff p is a prefix of this position.
Parameters:
p - a Position value
Returns:
a boolean value

toShortString

public java.lang.String toShortString()
Creates a short string representation by omitting the objects in the entries.
Returns:
a String value

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object