private void copyScheduleIntoFrontier(final int minCapacity,final Iterator<Value> itr){
  backing.ensureCapacity(minCapacity);
  final Value[] a=backing.array();
  int nvertices=0;
  while (itr.hasNext()) {
    final Value v=itr.next();
    a[nvertices++]=v;
  }
  for (int i=nvertices; i < a.length; i++) {
    if (a[i] == null)     break;
    a[i]=null;
  }
  this.vertices=backing.slice(0,nvertices);
}

private void copyScheduleIntoFrontier ( final int minCapacity , final Iterator < Value > itr ) { backing . ensureCapacity ( minCapacity ) ; final Value [ ] a = backing . array ( ) ; int nvertices = 0 ; while ( itr . hasNext ( ) ) { final Value v = itr . next ( ) ; a [ nvertices ++ ] = v ; } for ( int i = nvertices ; i < a . length ; i ++ ) { if ( a [ i ] == null ) break ; a [ i ] = null ; } this . vertices = backing . slice ( 0 , nvertices ) ; }
copy the data from the iterator into the backing array and update the slice which provides our exposed view of the backing array .
