org.shapelogic.streams
Class BaseStream2<In0,In1,E>

java.lang.Object
  extended by org.shapelogic.streams.BaseStream2<In0,In1,E>
Type Parameters:
In0 -
In1 -
E -
All Implemented Interfaces:
java.util.Iterator<E>, Calc2<In0,In1,E>, CalcValue<E>, LazyCalc<E>, InputsStream2<In0,In1,E>, Stream<E>

public abstract class BaseStream2<In0,In1,E>
extends java.lang.Object
implements Stream<E>, InputsStream2<In0,In1,E>

BaseDeclarativeStreamInputs2 a Stream with 2 inputs. The idea is that you can do a calculation, with 2 input and 1 output. This could be used directly for a zip operation, but not if you need a Cartesian product. I need a Cartesian product operation what should that be defined as? I just need to override hasNext() and next(). This seem like the work for a mixin. I think that this seems like a good solution, I do not think that you need to store all the values in a Cartesian product. Do I need all the classes sequential, number and list? I think that if you do a zip you just need 2 Interators as input. For anything else you need a list input. Output that make sense: sequential, number and list. I think that maybe they can be sub classed from each other.

Author:
Sami Badawi

Field Summary
protected  boolean _dirty
           
protected  Stream<In0> _inputStream0
           
protected  Stream<In1> _inputStream1
           
protected  E _value
           
 
Constructor Summary
BaseStream2()
           
 
Method Summary
 Stream<In0> getInputStream0()
          Stream that this stream is connected to.
 Stream<In1> getInputStream1()
           
 E getValue()
          Starts a lazy calculation.
 boolean hasNext()
           
abstract  E invoke(In0 input0, In1 input1)
           
 boolean isDirty()
          When dirty is false that means that the calculated value can be used
 E next()
           
 void remove()
           
 void setup()
          Currently not super well define used for 2 purposes: Reset: called from the outside if you want to reuse it init: Called from the inside when calculation start to have everything setup maybe the semantic could work for both? TODO: This should be separated better.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_dirty

protected boolean _dirty

_inputStream0

protected Stream<In0> _inputStream0

_inputStream1

protected Stream<In1> _inputStream1

_value

protected E _value
Constructor Detail

BaseStream2

public BaseStream2()
Method Detail

getInputStream0

public Stream<In0> getInputStream0()
Description copied from interface: InputsStream2
Stream that this stream is connected to. What if the Range is of different type? I think that maybe I can relax this later.

Specified by:
getInputStream0 in interface InputsStream2<In0,In1,E>

getInputStream1

public Stream<In1> getInputStream1()
Specified by:
getInputStream1 in interface InputsStream2<In0,In1,E>

getValue

public E getValue()
Description copied from interface: CalcValue
Starts a lazy calculation. If dirty do calc() else return cached value. This should maybe be moved up in the hierarchy

Specified by:
getValue in interface CalcValue<E>

invoke

public abstract E invoke(In0 input0,
                         In1 input1)
Specified by:
invoke in interface Calc2<In0,In1,E>

isDirty

public boolean isDirty()
Description copied from interface: LazyCalc
When dirty is false that means that the calculated value can be used

Specified by:
isDirty in interface LazyCalc<E>

setup

public void setup()
Description copied from interface: LazyCalc
Currently not super well define used for 2 purposes: Reset: called from the outside if you want to reuse it init: Called from the inside when calculation start to have everything setup maybe the semantic could work for both? TODO: This should be separated better.

Specified by:
setup in interface LazyCalc<E>

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator<E>

next

public E next()
Specified by:
next in interface java.util.Iterator<E>

remove

public void remove()
Specified by:
remove in interface java.util.Iterator<E>


Copyright © 2008. All Rights Reserved.