public static EventBean[] flatten(ArrayDeque<EventBean[]> eventVector){
  if (eventVector.isEmpty()) {
    return null;
  }
  if (eventVector.size() == 1) {
    return eventVector.getFirst();
  }
  int totalElements=0;
  for (  EventBean[] arr : eventVector) {
    if (arr != null) {
      totalElements+=arr.length;
    }
  }
  if (totalElements == 0) {
    return null;
  }
  EventBean[] result=new EventBean[totalElements];
  int destPos=0;
  for (  EventBean[] arr : eventVector) {
    if (arr != null) {
      System.arraycopy(arr,0,result,destPos,arr.length);
      destPos+=arr.length;
    }
  }
  return result;
}

public static EventBean [ ] flatten ( ArrayDeque < EventBean [ ] > eventVector ) { if ( eventVector . isEmpty ( ) ) { return null ; } if ( eventVector . size ( ) == 1 ) { return eventVector . getFirst ( ) ; } int totalElements = 0 ; for ( EventBean [ ] arr : eventVector ) { if ( arr != null ) { totalElements += arr . length ; } } if ( totalElements == 0 ) { return null ; } EventBean [ ] result = new EventBean [ totalElements ] ; int destPos = 0 ; for ( EventBean [ ] arr : eventVector ) { if ( arr != null ) { System . arraycopy ( arr , 0 , result , destPos , arr . length ) ; destPos += arr . length ; } } return result ; }
flatten the vector of arrays to an array . return null if an empty vector was passed , else return an array containing all the events .
