@@ -48,7 +48,7 @@ public DoubleArray() {
4848 * @param primitiveArray a primitiveArray of any type
4949 */
5050 public DoubleArray (PrimitiveArray primitiveArray ) {
51- array = new double [8 ];
51+ array = new double [primitiveArray . size ()]; //exact size
5252 append (primitiveArray );
5353 }
5454
@@ -372,14 +372,20 @@ public void removeRange(int from, int to) {
372372 public void move (int first , int last , int destination ) {
373373 String errorIn = String2 .ERROR + " in DoubleArray.move:\n " ;
374374
375- Test .ensureTrue (first >= 0 ,
376- errorIn + "first (" + first + ") must be >= 0." );
377- Test .ensureTrue (last >= first && last <= size ,
378- errorIn + "last (" + last + ") must be >= first (" + first + ") and <= size (" + size + ")." );
379- Test .ensureTrue (destination >= 0 && destination <= size ,
380- errorIn + "destination (" + destination + ") must be between 0 and size (" + size + ")." );
381- Test .ensureTrue (destination <= first || destination >= last ,
382- errorIn + "destination (" + destination + ") must be <= first (" + first + ") or >= last (" + last + ")." );
375+ if (first < 0 )
376+ throw new RuntimeException (errorIn + "first (" + first + ") must be >= 0." );
377+ if (last < first || last > size )
378+ throw new RuntimeException (
379+ errorIn + "last (" + last + ") must be >= first (" + first +
380+ ") and <= size (" + size + ")." );
381+ if (destination < 0 || destination > size )
382+ throw new RuntimeException (
383+ errorIn + "destination (" + destination +
384+ ") must be between 0 and size (" + size + ")." );
385+ if (destination > first && destination < last )
386+ throw new RuntimeException (
387+ errorIn + "destination (" + destination + ") must be <= first (" +
388+ first + ") or >= last (" + last + ")." );
383389 if (first == last || destination == first || destination == last )
384390 return ; //nothing to do
385391 //String2.log("move first=" + first + " last=" + last + " dest=" + destination);
@@ -991,7 +997,9 @@ public PrimitiveArray makeIndices(IntArray indices) {
991997 int count = 0 ;
992998 while (iterator .hasNext ())
993999 unique [count ++] = iterator .next ();
994- Test .ensureEqual (nUnique , count , "DoubleArray.makeRankArray nUnique != count!" );
1000+ if (nUnique != count )
1001+ throw new RuntimeException ("DoubleArray.makeRankArray nUnique(" + nUnique +
1002+ ") != count(" + count + ")!" );
9951003
9961004 //sort them
9971005 Arrays .sort (unique );
0 commit comments