public ArrayList<T> addAll(ArrayList<T> elist,int uptoIndex){
  if (uptoIndex > elist.size()) {
    log.error("uptoIndex is greater than elist size .. aborting addAll");
    return elist;
  }
  for (int index=0; index < uptoIndex; index++) {
    T e=elist.get(index);
    if (e != null) {
      elist.set(index,add(e));
    }
  }
  return elist;
}

public ArrayList < T > addAll ( ArrayList < T > elist , int uptoIndex ) { if ( uptoIndex > elist . size ( ) ) { log . error ( "uptoIndex is greater than elist size .. aborting addAll" ) ; return elist ; } for ( int index = 0 ; index < uptoIndex ; index ++ ) { T e = elist . get ( index ) ; if ( e != null ) { elist . set ( index , add ( e ) ) ; } } return elist ; }
the basic idea here is that an arraylist has been passed in , which may or may not have a size bigger that the actual number of elements that are meant to be flushed to the circular buffer . thus the ' uptoindex ' parameter specifies the number of elements that need to be flushed starting from index 0 . note that after flushing , the circular buffer may return a memory unit ( of type t ) for reuse in the list , if the circular buffer popped off memory to preserve its circular nature . or it may just return null if nothing was popped off . either way , the list that is returned by this method , is of the same size as the list passed in , as arraylists can hold null elements . the only difference is that the list returned will have elements that reference old popped - off memory from the circular - buffer or null .
