@Override protected String toString(Object array, int index) { return ForNonArrayType.DOUBLE.toString(Array.getDouble(array, index)); } },
protected String arrayToString(Object o) { int len = Array.getLength(o); Class c = o.getClass().getComponentType(); String res = "[ "; for (int i = 0; i < len; i++) { if ( c == byte.class ) res+=Array.getByte(o,i); if ( c == boolean.class ) res+=Array.getBoolean(o, i); if ( c == char.class ) res+=Array.getChar(o, i); if ( c == short.class ) res+=Array.getShort(o, i); if ( c == int.class ) res+=Array.getInt(o, i); if ( c == long.class ) res+=Array.getLong(o, i); if ( c == float.class ) res+=Array.getFloat(o, i); if ( c == double.class ) res+=Array.getDouble(o, i); if ( i < len-1) res+=","; } res += " ]"; return res; }
if (i != 0) string.append(' '); String s = format.format(Array.getDouble(o, i)); string.append(s.equals("-0") ? "0" : s);
protected String arrayToString(Object o) { int len = Array.getLength(o); Class c = o.getClass().getComponentType(); String res = "[ "; for (int i = 0; i < len; i++) { if ( c == byte.class ) res+=Array.getByte(o,i); if ( c == boolean.class ) res+=Array.getBoolean(o, i); if ( c == char.class ) res+=Array.getChar(o, i); if ( c == short.class ) res+=Array.getShort(o, i); if ( c == int.class ) res+=Array.getInt(o, i); if ( c == long.class ) res+=Array.getLong(o, i); if ( c == float.class ) res+=Array.getFloat(o, i); if ( c == double.class ) res+=Array.getDouble(o, i); if ( i < len-1) res+=","; } res += " ]"; return res; }
out.writeIntPacked(length); for ( int i = 0; i < length; i++ ) { out.writeTag(Array.getDouble(infoOrObject,i));
private void assertNumericArrayHeaderAndContent( Object array, PropertyType type, int expectedBitsUsedPerItem, Pair<byte[],byte[]> loadedBytesFromStore ) { assertArrayHeader( loadedBytesFromStore.first(), type, expectedBitsUsedPerItem ); Bits bits = Bits.bitsFromBytes( loadedBytesFromStore.other() ); int length = Array.getLength( array ); for ( int i = 0; i < length; i++ ) { if ( array instanceof double[] ) { assertEquals( Double.doubleToLongBits( Array.getDouble( array, i ) ), bits.getLong( expectedBitsUsedPerItem ) ); } else { assertEquals( Array.getLong( array, i ), bits.getLong( expectedBitsUsedPerItem ) ); } } }
out.writeIntPacked(length); for ( int i = 0; i < length; i++ ) { out.writeTag(Array.getDouble(infoOrObject,i));
/** * Returns a {@linkplain Range#getMinValue range's minimum value} as a {@code double}. The * {@code index} can be any value from 0 inclusive to the set's {@link #size size} exclusive. * The returned values always increase with {@code index}. * * @param index The range index, from 0 inclusive to {@link #size size} exclusive. * @return The minimum value for the range at the specified index. * @throws IndexOutOfBoundsException if {@code index} is out of bounds. * @throws ClassCastException if range elements are not convertible to numbers. */ public final double getMinValueAsDouble(int index) throws IndexOutOfBoundsException, ClassCastException { index *= 2; return (isPrimitive) ? Array.getDouble(array, index) : ((Number) Array.get(array, index)).doubleValue(); }
/** * Returns a {@linkplain Range#getMaxValue range's maximum value} as a {@code double}. The * {@code index} can be any value from 0 inclusive to the set's {@link #size size} exclusive. * The returned values always increase with {@code index}. * * @param index The range index, from 0 inclusive to {@link #size size} exclusive. * @return The maximum value for the range at the specified index. * @throws IndexOutOfBoundsException if {@code index} is out of bounds. * @throws ClassCastException if range elements are not convertible to numbers. */ public final double getMaxValueAsDouble(int index) throws IndexOutOfBoundsException, ClassCastException { index = 2 * index + 1; return (isPrimitive) ? Array.getDouble(array, index) : ((Number) Array.get(array, index)).doubleValue(); }
/** Quick double access */ public double getDouble(int index) { rangeCheck(index); return Array.getDouble( ARRAY, START + STEP * index + OFFSET); // ARRAY[ START+STEP*index + OFFSET ]; }
dest[i] = Array.getDouble(array, i);
@Override public Object get(Object array, int index) { return Array.getDouble(array, index); }
public double getX(int i) { if (points == null || i >= points.length) return Double.NaN; Object p = points[i]; if (p instanceof Point3) return ((Point3) p).x; else { Object x = Array.get(p, 0); if (x instanceof Number) return ((Number) x).doubleValue(); else return Array.getDouble(p, 0); } }
public double getX(int i) { if (points == null || i >= points.length) return Double.NaN; Object p = points[i]; if (p instanceof Point3) return ((Point3) p).x; else { Object x = Array.get(p, 0); if (x instanceof Number) return ((Number) x).doubleValue(); else return Array.getDouble(p, 0); } }
public double getY(int i) { if (i >= points.length) return Double.NaN; Object p = points[i]; if (p instanceof Point3) return ((Point3) p).y; else { Object y = Array.get(p, 0); if (y instanceof Number) return ((Number) y).doubleValue(); else return Array.getDouble(p, 1); } } }
/** Quick double access */ public double getDouble( int index ){ rangeCheck(index); return Array.getDouble(ARRAY,START+STEP*index + OFFSET );//ARRAY[ START+STEP*index + OFFSET ]; } public String getString( int index){
@Override protected String toString(Object array, int index) { return ForNonArrayType.DOUBLE.toString(Array.getDouble(array, index)); } },
/** * @throws IOException * @see org.apache.wicket.util.io.ClassStreamHandler.PrimitiveArray#writeArray(Object, * WicketObjectOutputStream) */ public void writeArray(Object object, WicketObjectOutputStream dos) throws IOException { int length = Array.getLength(object); dos.writeInt(length); for (int i = 0; i < length; i++) { dos.writeDouble(Array.getDouble(object, i)); } }
@Test public void testArrayDouble () { if (verifyNoPropertyViolation()){ try { double d = Array.getDouble(arrayDouble, 0); assert d == 42.0; Array.setDouble(arrayDouble, 0, 43.0); assert arrayDouble[0] == 43.0; } catch (Throwable t) { assert false : "unexpected exception: " + t; } } }
@JTranscSync public static Object get(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { Type elementType = getArrayElementType(array.getClass()); if (elementType == Boolean.TYPE) return getBoolean(array, index); if (elementType == Byte.TYPE) return getByte(array, index); if (elementType == Character.TYPE) return getChar(array, index); if (elementType == Short.TYPE) return getShort(array, index); if (elementType == Integer.TYPE) return getInt(array, index); if (elementType == Long.TYPE) return getLong(array, index); if (elementType == Float.TYPE) return getFloat(array, index); if (elementType == Double.TYPE) return getDouble(array, index); return getInstance(array, index); }