sears.search.data
Class LoopIterator

java.lang.Object
  extended by sears.search.data.LoopIterator

public class LoopIterator
extends java.lang.Object

Manages ListOfRow structure with loop iteration


Constructor Summary
LoopIterator(ListOfRow aListOfRow)
          Instantiate a new object
 
Method Summary
 int getCurrentElement()
          SAFE METHOD, do not change iteration state
 int getFirstElement()
          SAFE METHOD, do not change iteration state
 int getIndexOfTheCurrentElement()
          SAFE METHOD, do not change iteration state
 int getLastElement()
          SAFE METHOD, do not change iteration state
 int getNextElement()
          Returns the next positive element of the list
 int getPreviousElement()
          Returns the previous positive element of the list
 int getTheNearestElementAfter(int row)
           
 int getTheNearestElementBefore(int row)
           Gets the nearest element before means:
gets the first smaller element before the element before the one given on parameters
if this element is not in the list, else it is return
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoopIterator

public LoopIterator(ListOfRow aListOfRow)
Instantiate a new object

Parameters:
aListOfRow - the list on which iterate
Throws:
java.lang.NullPointerException - if aListOfRow is null
Method Detail

getTheNearestElementBefore

public int getTheNearestElementBefore(int row)

Gets the nearest element before means:
gets the first smaller element before the element before the one given on parameters
if this element is not in the list, else it is return

Method's algorithm uses is the dichotomic search

Parameters:
row - the element
Returns:
row if it is in the list or the first smaller element before it
Throws:
java.lang.IllegalArgumentException - if row is out of the bounds of the elements contained in the list

getTheNearestElementAfter

public int getTheNearestElementAfter(int row)
Parameters:
row - the row
Returns:
the nearest element after
Throws:
java.lang.IllegalArgumentException - if row is out of the bounds of the elements contained in the list

getNextElement

public int getNextElement()
Returns the next positive element of the list

Returns:
the next element in the list, if the list is empty -1 is return

getPreviousElement

public int getPreviousElement()
Returns the previous positive element of the list

Returns:
the previous element in the list, if the list is empty -1 is return

getCurrentElement

public int getCurrentElement()
SAFE METHOD, do not change iteration state

Returns:
the current element

getFirstElement

public int getFirstElement()
SAFE METHOD, do not change iteration state

Returns:
the first element of the list

getLastElement

public int getLastElement()
SAFE METHOD, do not change iteration state

Returns:
the last element of the list

getIndexOfTheCurrentElement

public int getIndexOfTheCurrentElement()
SAFE METHOD, do not change iteration state

Returns:
the index of the current element in the list