public static UniformPair<EventBean[]> flattenList(ArrayDeque<UniformPair<EventBean[]>> eventVector){
  if (eventVector.isEmpty()) {
    return null;
  }
  if (eventVector.size() == 1) {
    return eventVector.getFirst();
  }
  int totalNew=0;
  int totalOld=0;
  for (  UniformPair<EventBean[]> pair : eventVector) {
    if (pair != null) {
      if (pair.getFirst() != null) {
        totalNew+=pair.getFirst().length;
      }
      if (pair.getSecond() != null) {
        totalOld+=pair.getSecond().length;
      }
    }
  }
  if ((totalNew + totalOld) == 0) {
    return null;
  }
  EventBean[] resultNew=null;
  if (totalNew > 0) {
    resultNew=new EventBean[totalNew];
  }
  EventBean[] resultOld=null;
  if (totalOld > 0) {
    resultOld=new EventBean[totalOld];
  }
  int destPosNew=0;
  int destPosOld=0;
  for (  UniformPair<EventBean[]> pair : eventVector) {
    if (pair != null) {
      if (pair.getFirst() != null) {
        System.arraycopy(pair.getFirst(),0,resultNew,destPosNew,pair.getFirst().length);
        destPosNew+=pair.getFirst().length;
      }
      if (pair.getSecond() != null) {
        System.arraycopy(pair.getSecond(),0,resultOld,destPosOld,pair.getSecond().length);
        destPosOld+=pair.getSecond().length;
      }
    }
  }
  return new UniformPair<EventBean[]>(resultNew,resultOld);
}

public static UniformPair < EventBean [ ] > flattenList ( ArrayDeque < UniformPair < EventBean [ ] > > eventVector ) { if ( eventVector . isEmpty ( ) ) { return null ; } if ( eventVector . size ( ) == 1 ) { return eventVector . getFirst ( ) ; } int totalNew = 0 ; int totalOld = 0 ; for ( UniformPair < EventBean [ ] > pair : eventVector ) { if ( pair != null ) { if ( pair . getFirst ( ) != null ) { totalNew += pair . getFirst ( ) . length ; } if ( pair . getSecond ( ) != null ) { totalOld += pair . getSecond ( ) . length ; } } } if ( ( totalNew + totalOld ) == 0 ) { return null ; } EventBean [ ] resultNew = null ; if ( totalNew > 0 ) { resultNew = new EventBean [ totalNew ] ; } EventBean [ ] resultOld = null ; if ( totalOld > 0 ) { resultOld = new EventBean [ totalOld ] ; } int destPosNew = 0 ; int destPosOld = 0 ; for ( UniformPair < EventBean [ ] > pair : eventVector ) { if ( pair != null ) { if ( pair . getFirst ( ) != null ) { System . arraycopy ( pair . getFirst ( ) , 0 , resultNew , destPosNew , pair . getFirst ( ) . length ) ; destPosNew += pair . getFirst ( ) . length ; } if ( pair . getSecond ( ) != null ) { System . arraycopy ( pair . getSecond ( ) , 0 , resultOld , destPosOld , pair . getSecond ( ) . length ) ; destPosOld += pair . getSecond ( ) . length ; } } } return new UniformPair < EventBean [ ] > ( resultNew , resultOld ) ; }
flatten the vector of arrays to an array . return null if an empty vector was passed , else return an array containing all the events .
