lrs.visitor
Class InsertInOrder<T>

java.lang.Object
  extended by lrs.visitor.InsertInOrder<T>
All Implemented Interfaces:
IAlgo<T,LRStruct<T>,T>

public class InsertInOrder<T>
extends java.lang.Object
implements IAlgo<T,LRStruct<T>,T>

Algorithm for inserting elements into an LRStruct in order.


Field Summary
private  java.util.Comparator<T> _order
           
 
Constructor Summary
InsertInOrder(java.util.Comparator<T> ord)
           
 
Method Summary
 LRStruct<T> emptyCase(LRStruct<T> host, T... n)
          Simply inserts the given parameter n at the front.
 LRStruct<T> nonEmptyCase(LRStruct<T> host, T... n)
          Based on the comparison between first and n, inserts at the front or recurs!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_order

private java.util.Comparator<T> _order
Constructor Detail

InsertInOrder

public InsertInOrder(java.util.Comparator<T> ord)
Method Detail

emptyCase

public LRStruct<T> emptyCase(LRStruct<T> host,
                             T... n)
Simply inserts the given parameter n at the front.

Specified by:
emptyCase in interface IAlgo<T,LRStruct<T>,T>
Parameters:
host - an empty LRStruct.
n - n[0] is an Object to be inserted in order into host, based on the given Comparator.
Returns:
LRStruct

nonEmptyCase

public LRStruct<T> nonEmptyCase(LRStruct<T> host,
                                T... n)
Based on the comparison between first and n, inserts at the front or recurs!

Specified by:
nonEmptyCase in interface IAlgo<T,LRStruct<T>,T>
Parameters:
host - a non-empty LRStruct.
n - n[0] is an Object to be inserted in order into host, based on the given Comparator.
Returns:
LRStruct