rac
Class ALRSRACFactory.LRSRAContainer<T>

java.lang.Object
  extended by rac.ALRSRACFactory.LRSRAContainer<T>
All Implemented Interfaces:
IRAContainer<T>
Enclosing class:
ALRSRACFactory<T>

protected class ALRSRACFactory.LRSRAContainer<T>
extends java.lang.Object
implements IRAContainer<T>

Implements a general-purpose restricted access container using an LRStruct. How? The next item to remove is always at the front of the list of contained objects. This is invariant! Insertion is, however, delegated to a strategy routine; and this strategy is provided to the container. This strategy varies to implement the desired kind of container, e.g., queue vs. stack. This inner class is protected so that classes derived from its factory can reuse it to create other kinds of restricted access container.


Field Summary
private  IAlgo<T,LRStruct<T>,T> _insertStrategy
           
private  LRStruct<T> _lrs
           
 
Constructor Summary
ALRSRACFactory.LRSRAContainer(IAlgo<T,LRStruct<T>,T> strategy)
           
 
Method Summary
 void clear()
          Empty the container.
 IList<T> elements(IListFactory<T> fact)
          Return an immutable list of all elements in the container.
<R,P> R
execute(IRACVisitor<T,R,P> v, P... inp)
          Extensibility hook to accept a visitor algorithm.
 T get()
          Remove the next item from the container and return it.
 boolean isFull()
          Return TRUE if the container is full; otherwise, return FALSE.
 T peek()
          Return the next element in this IRAContainer withour removing it.
 void put(T input)
          Add an item to the container.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_insertStrategy

private IAlgo<T,LRStruct<T>,T> _insertStrategy

_lrs

private LRStruct<T> _lrs
Constructor Detail

ALRSRACFactory.LRSRAContainer

public ALRSRACFactory.LRSRAContainer(IAlgo<T,LRStruct<T>,T> strategy)
Method Detail

clear

public void clear()
Empty the container.

Specified by:
clear in interface IRAContainer<T>

isFull

public boolean isFull()
Return TRUE if the container is full; otherwise, return FALSE. This implementation can hold an arbitrary number of objects. Thus, always return false.

Specified by:
isFull in interface IRAContainer<T>

elements

public IList<T> elements(IListFactory<T> fact)
Return an immutable list of all elements in the container.

Specified by:
elements in interface IRAContainer<T>
Parameters:
fact - for manufacturing an IList.

get

public T get()
Remove the next item from the container and return it.

Specified by:
get in interface IRAContainer<T>

put

public void put(T input)
Add an item to the container.

Specified by:
put in interface IRAContainer<T>
Parameters:
input - the Object to be added to this IRAContainer.

peek

public T peek()
Return the next element in this IRAContainer withour removing it.

Specified by:
peek in interface IRAContainer<T>

execute

public <R,P> R execute(IRACVisitor<T,R,P> v,
                       P... inp)
Extensibility hook to accept a visitor algorithm.

Specified by:
execute in interface IRAContainer<T>
Parameters:
v - The visitor to execute
inp - An arbitrary input parameter for the visitor
Returns:
The return value of the calculation performed by the visitor.