@Test public void testConcatenation1() { ArrayDouble l1 = new ArrayDouble( new double[] {0, 1, 2, 3, 4} ); ArrayDouble l2 = new ArrayDouble( new double[] {5, 6, 7, 8, 9} ); ListDouble combined = ListDouble.concatenate( l1 , l2 ); for ( int i=0 ; i<9 ; i++ ) { assertThat( (int) combined.getDouble( i ) , equalTo( i ) ); } }
public static ListDouble concatenate( final ListNumber... lists ) { int size = 0; for ( ListNumber l : lists ) { size += l.size(); } final int sizeCopy = size; return new ListDouble() { @Override public int size() { return sizeCopy; } @Override public double getDouble( int index ) { if ( index < 0 || index >= size() ) { throw new IndexOutOfBoundsException( "Index out of bounds: " + index + ", size: " + size() ); } int startIdx = 0; for ( ListNumber l : lists ) { int endIdx = startIdx + l.size()-1; if ( startIdx <= index && index <= endIdx ) { return l.getDouble( index - startIdx ); } startIdx += l.size(); } return 0; } }; }
ListDouble implements ListNumber, CollectionDouble { public static ListDouble concatenate( final ListNumber... lists ) { int size = 0; for ( ListNumber l : lists ) { size += l.size(); } final int sizeCopy = size; return new ListDouble() { @Override public int size() { return sizeCopy; } @Override public double getDouble( int index ) { if ( index < 0 || index >= size() ) { throw new IndexOutOfBoundsException( "Index out of bounds: " + index + ", size: " + size() ); } int startIdx = 0; for ( ListNumber l : lists ) { int endIdx = startIdx + l.size()-1; if ( startIdx <= index && index <= endIdx ) { return l.getDouble( index - startIdx ); } startIdx += l.size(); } return 0; } }; } }
ListDouble implements ListNumber, CollectionDouble { public static ListDouble concatenate( final ListNumber... lists ) { int size = 0; for ( ListNumber l : lists ) { size += l.size(); } final int sizeCopy = size; return new ListDouble() { @Override public int size() { return sizeCopy; } @Override public double getDouble( int index ) { if ( index < 0 || index >= size() ) { throw new IndexOutOfBoundsException( "Index out of bounds: " + index + ", size: " + size() ); } int startIdx = 0; for ( ListNumber l : lists ) { int endIdx = startIdx + l.size()-1; if ( startIdx <= index && index <= endIdx ) { return l.getDouble( index - startIdx ); } startIdx += l.size(); } return 0; } }; }  }
ListDouble implements ListNumber, CollectionDouble { public static ListDouble concatenate( final ListNumber... lists ) { int size = 0; for ( ListNumber l : lists ) { size += l.size(); } final int sizeCopy = size; return new ListDouble() { @Override public int size() { return sizeCopy; } @Override public double getDouble( int index ) { if ( index < 0 || index >= size() ) { throw new IndexOutOfBoundsException( "Index out of bounds: " + index + ", size: " + size() ); } int startIdx = 0; for ( ListNumber l : lists ) { int endIdx = startIdx + l.size()-1; if ( startIdx <= index && index <= endIdx ) { return l.getDouble( index - startIdx ); } startIdx += l.size(); } return 0; } }; }  @Override IteratorDouble iterator(); @Override float getFloat(int index); @Override long getLong(int index); @Override int getInt(int index); @Override short getShort(int index); @Override byte getByte(int index); @Override void setDouble(int index, double value); @Override void setFloat(int index, float value); @Override void setLong(int index, long value); @Override void setInt(int index, int value); @Override void setShort(int index, short value); @Override void setByte(int index, byte value); static ListDouble concatenate( final ListNumber... lists ); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); }
ListDouble implements ListNumber, CollectionDouble { public static ListDouble concatenate( final ListNumber... lists ) { int size = 0; for ( ListNumber l : lists ) { size += l.size(); } final int sizeCopy = size; return new ListDouble() { @Override public int size() { return sizeCopy; } @Override public double getDouble( int index ) { if ( index < 0 || index >= size() ) { throw new IndexOutOfBoundsException( "Index out of bounds: " + index + ", size: " + size() ); } int startIdx = 0; for ( ListNumber l : lists ) { int endIdx = startIdx + l.size()-1; if ( startIdx <= index && index <= endIdx ) { return l.getDouble( index - startIdx ); } startIdx += l.size(); } return 0; } }; }  @Override IteratorDouble iterator(); @Override float getFloat(int index); @Override long getLong(int index); @Override int getInt(int index); @Override short getShort(int index); @Override byte getByte(int index); @Override void setDouble(int index, double value); @Override void setFloat(int index, float value); @Override void setLong(int index, long value); @Override void setInt(int index, int value); @Override void setShort(int index, short value); @Override void setByte(int index, byte value); static ListDouble concatenate( final ListNumber... lists ); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }