ListIterator iter = children.listIterator (); SimpleSchedStream prevChild = null;
{ ListIterator iter = children.listIterator (); while (iter.hasNext ()) { SimpleSchedStream child = (SimpleSchedStream) iter.next (); child.computeSchedule (); } }         Map numExecutionsForInit = new HashMap (); { int consumedByPrev = 0;   ListIterator iter = children.listIterator (children.size ());  while (iter.hasPrevious ()) {  SimpleSchedStream child = (SimpleSchedStream) iter.previous (); ASSERT (child);   int producesPerIter = child.getProduction (); int numItersInit; if (producesPerIter != 0) {   numItersInit = (consumedByPrev + producesPerIter - 1) / producesPerIter; } else {     ASSERT (consumedByPrev == 0);    numItersInit = 0; }    numExecutionsForInit.put (child, new Integer (numItersInit));    consumedByPrev = numItersInit * child.getConsumption () + (child.getPeekConsumption () - child.getConsumption ()) + child.getInitDataCount (); } }        { ListIterator iter = children.listIterator ();  while (iter.hasNext ()) { SimpleSchedStream child = (SimpleSchedStream) iter.next (); ASSERT (child);   initSchedule.add (child.getInitSchedule ());   Integer numExecutions = (Integer)numExecutionsForInit.get (child); ASSERT (numExecutions);  int n = numExecutions.intValue (); for ( ; n > 0 ; n--) { initSchedule.add (child.getSteadySchedule ()); } } }      if (!children.isEmpty ()) {  SimpleSchedStream firstChild = (SimpleSchedStream) children.get (0); ASSERT (firstChild);   int initData = firstChild.getInitDataCount ();   int fillData = ((Integer)numExecutionsForInit.get (firstChild)).intValue () * firstChild.getConsumption ();   initDataCount = initData + fillData; } else { initDataCount = 0; }     { ListIterator iter = children.listIterator ();  while (iter.hasNext ()) { SimpleSchedStream child = (SimpleSchedStream) iter.next (); ASSERT (child);  BigInteger numExecutions = child.getNumExecutions ();   while (numExecutions.signum () != 0) { steadySchedule.add (child.getSteadySchedule ()); numExecutions = numExecutions.subtract (BigInteger.ONE); } }  }           if (!children.isEmpty ()) { ListIterator iter = children.listIterator (); SimpleSchedStream prevChild = (SimpleSchedStream) iter.next (); ASSERT (prevChild);  while (iter.hasNext ()) { SimpleSchedStream child = (SimpleSchedStream) iter.next (); ASSERT (child);    BigInteger steadyStateProd = child.getNumExecutions ().multiply (BigInteger.valueOf (child.getConsumption ()));   BigInteger initProdSize; { int prod = ((Integer)numExecutionsForInit.get (prevChild)).intValue () * prevChild.getProduction (); initProdSize = BigInteger.valueOf (prod); }   BigInteger initConsumeSize; { int initConsume = child.getInitDataCount (); int fillConsume = ((Integer)numExecutionsForInit.get (child)).intValue () * child.getConsumption (); initConsumeSize = BigInteger.valueOf (initConsume + fillConsume); }  BigInteger bufferSize = initProdSize.max (initProdSize.subtract (initConsumeSize).add (steadyStateProd)); scheduler.schedule.setBufferSize (prevChild, child, bufferSize);  prevChild = child; } }   /*
    public void computeSchedule ()    {        // make sure that this the first call to computeSchedule        {            ASSERT (steadySchedule == null && initSchedule == null);            steadySchedule = new LinkedList ();            initSchedule = new LinkedList ();        }        List children = getChildren ();        ListIterator iter = children.listIterator ();        SimpleSchedStream prevChild = null;        while (iter.hasNext ())        {            // get the child            SimpleSchedStream child = (SimpleSchedStream) iter.next ();            ASSERT (child);            // initialize the child's schedule            child.computeSchedule ();            // can't quite handle peeking yet!            ASSERT (child.getPeekConsumption () == child.getConsumption ());            Object childSchedule;            childSchedule = child.getSteadySchedule ();            ASSERT (childSchedule);            BigInteger numExecutions = child.getNumExecutions ();            ASSERT (numExecutions != null && numExecutions.signum () == 1);            // calculate the size of the buffer necessary            if (prevChild != null)            {                // compute a simple size of the buffer                BigInteger consumesSize = BigInteger.valueOf (child.getConsumption ());                BigInteger bufferSize = consumesSize.multiply (numExecutions);                // correct for possible peeking:                if (child.getPeekConsumption () != child.getConsumption ())                {                    // first simply extend the buffer size by enough push amounts                    // to accomodate the entire peek sequence                    int extraPeekSize = child.getPeekConsumption () - child.getConsumption ();                    int pushSize = child.getProduction ();                    ASSERT (pushSize != 0);                    int extraPushes = (extraPeekSize + (pushSize - 1)) / pushSize;                    bufferSize = bufferSize.add (BigInteger.valueOf (extraPushes * pushSize));                }                scheduler.schedule.setBufferSize (prevChild.getStreamObject (), child.getStreamObject (), bufferSize);            }            // enter all the appropriate sub-schedules into the schedule            while (numExecutions.signum () != 0)            {                steadySchedule.add (childSchedule);                numExecutions = numExecutions.subtract (BigInteger.ONE);            }            prevChild = child;        }    }