moses.controlState
Class CSIterator

java.lang.Object
  |
  +--moses.controlState.CSIterator

public class CSIterator
extends java.lang.Object

This object is an iterator that allows iterations through all the terms of a list type or compound term (control state included). More general, it allows iteration through all the sub terms of a composed or list type term. It provides a (specialized) subset of a ListIterator interface methods, allowing direct access to the Term type sub terms. Implementation wise, it uses Vector.listIterator methods in an unsynchronized manner. This object should not be used in a multi-threaded context: While the iterator is being used, the source object (i.e. ControlState, list or composed term ) should only be modified through iterator's own methods, otherwise unpredictable behavior can happen.


Constructor Summary
CSIterator(moses.controlState.ControlState cs)
          This constructor creates an iterator from a ControlState object.
This method is only used by the internal implementation, is not intended to be used by a user programmer.
CSIterator(moses.controlState.Term list)
          This constructor creates an iterator from a Term object.
 
Method Summary
 void add(moses.controlState.Term t)
          Inserts the term t into the list, at the current iterating position, before the term that is to be returned by the next() method (see more at ListIterator).
This method is only used by the internal implementation, is not intended to be used by a user programmer.
 boolean hasNext()
          This method returns true if there are more elements to perform in this iterator.
 moses.controlState.Term next()
          This method returns the next element to perform in this iterator.
 void remove()
          Removes from the list the last element that was returned by next() method (see more at ListIterator).
 void set(moses.controlState.Term t)
          Replaces the last element that was returned by next() method with the argument element (see more at ListIterator).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSIterator

public CSIterator(moses.controlState.ControlState cs)
This constructor creates an iterator from a ControlState object.
This method is only used by the internal implementation, is not intended to be used by a user programmer.


CSIterator

public CSIterator(moses.controlState.Term list)
This constructor creates an iterator from a Term object. If the object is not composed nor list, then an empty iterator is returned.

Parameters:
list - represents the term object to be iterated through.
Method Detail

add

public void add(moses.controlState.Term t)
Inserts the term t into the list, at the current iterating position, before the term that is to be returned by the next() method (see more at ListIterator).
This method is only used by the internal implementation, is not intended to be used by a user programmer.

Parameters:
t - represents the term to be appended to the iterator object.

hasNext

public boolean hasNext()
This method returns true if there are more elements to perform in this iterator.

Returns:
true if there are more elements to perform in this iterator; false otherwise.

next

public moses.controlState.Term next()
This method returns the next element to perform in this iterator. (see more at ListIterator).

Returns:
the next element to perform in this iterator.

remove

public void remove()
Removes from the list the last element that was returned by next() method (see more at ListIterator).


set

public void set(moses.controlState.Term t)
Replaces the last element that was returned by next() method with the argument element (see more at ListIterator).

Parameters:
t - represents the new element to replace the current iteration item.