本文整理了Java中java.lang.reflect.Array.getFloat()
方法的一些代码示例,展示了Array.getFloat()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Array.getFloat()
方法的具体详情如下:
包路径:java.lang.reflect.Array
类名称:Array
方法名:getFloat
[英]Returns the float at the given index in the given array. Applies to byte, char, float, int, long, and short arrays.
[中]返回给定数组中给定索引处的浮点值。适用于字节、字符、浮点、整数、长数组和短数组。
代码示例来源:origin: redisson/redisson
@Override
protected String toString(Object array, int index) {
return ForNonArrayType.FLOAT.toString(Array.getFloat(array, index));
}
},
代码示例来源:origin: redisson/redisson
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;
}
代码示例来源:origin: drewnoakes/metadata-extractor
if (i != 0)
string.append(' ');
String s = format.format(Array.getFloat(o, i));
string.append(s.equals("-0") ? "0" : s);
代码示例来源:origin: RuedigerMoeller/fast-serialization
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;
}
代码示例来源:origin: redisson/redisson
out.writeIntPacked(length);
for ( int i = 0; i < length; i++ ) {
out.writeTag(Array.getFloat(infoOrObject, i));
代码示例来源:origin: RuedigerMoeller/fast-serialization
out.writeIntPacked(length);
for ( int i = 0; i < length; i++ ) {
out.writeTag(Array.getFloat(infoOrObject, i));
代码示例来源:origin: geotools/geotools
dest[i] = Array.getFloat(array, i);
代码示例来源:origin: gdpancheng/LoonAndroid3
@Override
public Object get(Object array, int index) {
return Array.getFloat(array, index);
}
代码示例来源:origin: senseidb/bobo
public float get(int r, int c) {
Object row = Array.get(_matrix, r);
if (row == null) {
throw new ArrayIndexOutOfBoundsException("index out of bounds: " + r);
}
return Array.getFloat(row, c);
}
代码示例来源:origin: tonihele/OpenKeeper
private void setChannels(Object value) {
Frame i = (Frame) information;
channels = i.channels;
if (Array.getLength(value) == 0) {
information.put(FA_CHANNEL_MAPPING, value);
return;
}
if (i.mode == DUAL_CHANNEL && (Array.getFloat(value, 0) == 1) && (Array.getFloat(value, 1) == 0)) {
whichChannels = LEFT_CHANNEL;
channels = 2;
} else if (i.mode == DUAL_CHANNEL && (Array.getFloat(value, 1) == 0) && (Array.getFloat(value, 0) == 1)) {
whichChannels = RIGHT_CHANNEL;
channels = 2;
} else {
whichChannels = STANDARD;
if (outputChannels == 1) {
value = MONO_ARRAY;
} else {
value = STANDARD_ARRAY;
}
}
information.put(FA_CHANNEL_MAPPING, value);
}
代码示例来源:origin: org.testifyproject.external/external-bytebuddy
@Override
protected String toString(Object array, int index) {
return ForNonArrayType.FLOAT.toString(Array.getFloat(array, index));
}
},
代码示例来源:origin: hyperic/hq
/**
* @param The values Object array reference.
* @param The weights Object array reference.
* @return Double containing weigted average.
*/
public static Double weightedAverage (Object values, Object weights) {
Double retVal = new Double(0);
try {
// First sanity check the weights - if they don't add up to 1
// we should probably throw an exception.
float wSum = 0f;
for (int i=0;i<Array.getLength(weights);i++)
wSum+=Array.getFloat(weights,i);
// if (wSum != 0) throw Something!
for (int i=0;i<Array.getLength(values);i++) {
retVal = runningAverage (retVal,Array.get(values,i),
i+1, Array.getFloat(weights,i));
}
}
catch (Exception e) {
e.printStackTrace();
}
return retVal;
}
代码示例来源:origin: org.python/jython
/**
* Byte order reverses an <code>Array</code> of <code>floats</code>
*
* @param array input array
*/
private static void swapFloatArray(Object array) {
int len = Array.getLength(array);
float ftmp;
int tmp;
int b1, b2, b3, b4;
for (int i = 0; i < len; i++) {
ftmp = Array.getFloat(array, i);
tmp = Float.floatToIntBits(ftmp);
b1 = (tmp >> 0) & 0xff;
b2 = (tmp >> 8) & 0xff;
b3 = (tmp >> 16) & 0xff;
b4 = (tmp >> 24) & 0xff;
tmp = b1 << 24 | b2 << 16 | b3 << 8 | b4 << 0;
ftmp = Float.intBitsToFloat(tmp);
Array.setFloat(array, i, ftmp);
}
}
代码示例来源:origin: org.apidesign.bck2brwsr/emul.mini
/**
* Returns the value of the indexed component in the specified
* array object, as a {@code double}.
*
* @param array the array
* @param index the index
* @return the value of the indexed component in the specified array
* @exception NullPointerException If the specified object is null
* @exception IllegalArgumentException If the specified object is not
* an array, or if the indexed element cannot be converted to the
* return type by an identity or widening conversion
* @exception ArrayIndexOutOfBoundsException If the specified {@code index}
* argument is negative, or if it is greater than or equal to the
* length of the specified array
* @see Array#get
*/
public static double getDouble(Object array, int index)
throws IllegalArgumentException, ArrayIndexOutOfBoundsException {
final Class<?> t = array.getClass().getComponentType();
if (MethodImpl.samePrimitive(t, Double.TYPE)) {
double[] arr = (double[]) array;
return arr[index];
}
return getFloat(array, index);
}
代码示例来源:origin: jtulach/bck2brwsr
/**
* Returns the value of the indexed component in the specified
* array object, as a {@code double}.
*
* @param array the array
* @param index the index
* @return the value of the indexed component in the specified array
* @exception NullPointerException If the specified object is null
* @exception IllegalArgumentException If the specified object is not
* an array, or if the indexed element cannot be converted to the
* return type by an identity or widening conversion
* @exception ArrayIndexOutOfBoundsException If the specified {@code index}
* argument is negative, or if it is greater than or equal to the
* length of the specified array
* @see Array#get
*/
public static double getDouble(Object array, int index)
throws IllegalArgumentException, ArrayIndexOutOfBoundsException {
final Class<?> t = array.getClass().getComponentType();
if (MethodImpl.samePrimitive(t, Double.TYPE)) {
double[] arr = (double[]) array;
return arr[index];
}
return getFloat(array, index);
}
代码示例来源:origin: org.apache.wicket/com.springsource.org.apache.wicket
/**
* @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.writeFloat(Array.getFloat(object, i));
}
}
代码示例来源:origin: org.ops4j.pax.wicket/pax-wicket-service
/**
* @throws IOException
* @see org.apache.wicket.util.io.ClassStreamHandler.PrimitiveArray#writeArray(Object,
* WicketObjectOutputStream)
*/
@Override
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.writeFloat(Array.getFloat(object, i));
}
}
代码示例来源:origin: org.kuali.rice/rice-core-api
public static Object toObject(Object value) {
if (!value.getClass().isArray())
return value;
Class type = value.getClass().getComponentType();
if (Array.getLength(value) == 0)
return null;
if (!type.isPrimitive())
return Array.get(value, 0);
if (boolean.class.isAssignableFrom(type))
return Array.getBoolean(value, 0);
if (char.class.isAssignableFrom(type))
return new Character(Array.getChar(value, 0));
if (byte.class.isAssignableFrom(type))
return new Byte(Array.getByte(value, 0));
if (int.class.isAssignableFrom(type))
return new Integer(Array.getInt(value, 0));
if (long.class.isAssignableFrom(type))
return new Long(Array.getLong(value, 0));
if (short.class.isAssignableFrom(type))
return new Short(Array.getShort(value, 0));
if (double.class.isAssignableFrom(type))
return new Double(Array.getDouble(value, 0));
if (float.class.isAssignableFrom(type))
return new Float(Array.getFloat(value, 0));
return null;
}
代码示例来源:origin: com.jtransc/jtransc-rt
@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);
}
代码示例来源:origin: jmockit/jmockit1
private void putArrayElementValues(char elementType, @Nonnull Object array) {
int length = Array.getLength(array);
putArrayLength(length);
for (int i = 0; i < length; i++) {
if (elementType == 'J') {
long value = Array.getLong(array, i);
putLong(value);
}
else if (elementType == 'F') {
float value = Array.getFloat(array, i);
putFloat(value);
}
else if (elementType == 'D') {
double value = Array.getDouble(array, i);
putDouble(value);
}
else if (elementType == 'Z') {
boolean value = Array.getBoolean(array, i);
putBoolean(value);
}
else {
int value = Array.getInt(array, i);
putInteger(elementType, value);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!