当前位置: 首页>>代码示例>>Java>>正文


Java ArrayUtils.toPrimitive方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.ArrayUtils.toPrimitive方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayUtils.toPrimitive方法的具体用法?Java ArrayUtils.toPrimitive怎么用?Java ArrayUtils.toPrimitive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.ArrayUtils的用法示例。


在下文中一共展示了ArrayUtils.toPrimitive方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fromGatherer

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
public static <E extends Serializable, G extends Serializable> ZScoreFeatureNormalizer fromGatherer(ExampleGatherer<E, G> exampleGatherer, boolean strict) {
	ZScoreFeatureNormalizer fn = new ZScoreFeatureNormalizer();
	fn.strict = strict;
	List<FeaturePack<E>> ftrPacks = exampleGatherer.getAllFeaturePacks();
	for (String ftrName : ftrPacks.get(0).getFeatureNames()) {
		Vector<Double> ftrValues = new Vector<>();
		for (FeaturePack<E> fp : ftrPacks)
			if (fp.featureIsSet(ftrName))
				ftrValues.add(fp.getFeature(ftrName));
		double[] ftrValArray = ArrayUtils.toPrimitive(ftrValues.toArray(new Double[] {}));

		double valMean = meanComputer.evaluate(ftrValArray);
		double stdDev = stdDevComputer.evaluate(ftrValArray, valMean);
		fn.avgs.put(ftrName, valMean);
		fn.stdDevs.put(ftrName, stdDev);
	}
	return fn;
}
 
开发者ID:marcocor,项目名称:smaph,代码行数:19,代码来源:ZScoreFeatureNormalizer.java

示例2: readDict

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
 * Reads a bencoded <code>Map</code> (dict in the specification) from the
 * <code>InputStream</code>. The <code>Map</code> may contain lists and maps
 * itself.
 *
 * @since 0.1.0
 * @exception IOException if an IO exception occurs when reading
 * @exception EOFException if the stream ended unexpectedly
 * @exception BencodeReadException if the value read is not a properly bencoded Map
 */
public Map<String, Object> readDict() throws IOException, BencodeReadException {
    int initial = forceRead();
    if (initial != 'd') {
        throw new BencodeReadException("Bencoded dict must start with 'd', not '%c'",
                                       initial);
    }
    LinkedHashMap<String, Object> hm = new LinkedHashMap<String, Object>();
    while (peek() != 'e') {
        String key =  new String(ArrayUtils.toPrimitive(readString()), StandardCharsets.UTF_8);
        Object val = read();
        if (val == null) {
            throw new EOFException();
        }
        hm.put(key, val);
    }
    forceRead(); // read 'e' that we peeked
    return hm;
}
 
开发者ID:jc0541,项目名称:URTorrent,代码行数:29,代码来源:BencodeReader.java

示例3: solveInflections

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
public double[] solveInflections(double x1, double y1, double x2, double y2, double x3, double y3, double x4,
		double y4) {
	double p = -(x4 * (y1 - 2 * y2 + y3)) + x3 * (2 * y1 - 3 * y2 + y4) + x1 * (y2 - 2 * y3 + y4)
			- x2 * (y1 - 3 * y3 + 2 * y4);
	double q = x4 * (y1 - y2) + 3 * x3 * (-y1 + y2) + x2 * (2 * y1 - 3 * y3 + y4) - x1 * (2 * y2 - 3 * y3 + y4);
	double r = x3 * (y1 - y2) + x1 * (y2 - y3) + x2 * (-y1 + y3);

	Double[] temp = Stream.of(ArrayUtils.toObject(quadSolve(p, q, r))).filter(t -> t > 1e-8 && t < (1 - 1e-8))
			.toArray(Double[]::new);
	Arrays.sort(temp, new Comparator<Double>() {
		@Override
		public int compare(Double o1, Double o2) {
			return (int) byNumber(o1, o2);
		}
	});
	return ArrayUtils.toPrimitive(temp);
}
 
开发者ID:icaoweiwei,项目名称:otf2ttf,代码行数:18,代码来源:CubicToQuad.java

示例4: parseCol

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
private int[] parseCol(String colConf, Set<Integer> existCols, Map<String, Integer> fName2IndexMap) {
    if (colConf.equalsIgnoreCase("default")) {
        CheckUtils.check(!existCols.contains(-1), "[GBDT] feature approximate config error! default has been set twice");
        existCols.add(-1);
        return new int[]{-1};
    }

    List<Integer> colList = new ArrayList<>(16);
    String[] allCols = colConf.split(COL_SPLIT);

    for (String colField : allCols) {
        colField = colField.trim();
        CheckUtils.check(fName2IndexMap.containsKey(colField), "[GBDT] feature approximate config error! feature(%s) does not exist", colField);
        int col = fName2IndexMap.get(colField);
        CheckUtils.check(!existCols.contains(col), "[GBDT] feature approximate config error!, feature(%s) has been set twice", colField);
        colList.add(col);
        existCols.add(col);
    }
    return ArrayUtils.toPrimitive(colList.toArray(new Integer[colList.size()]));
}
 
开发者ID:yuantiku,项目名称:ytk-learn,代码行数:21,代码来源:GBDTFeatureParams.java

示例5: dataBytes

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
public byte[] dataBytes() {
    if (data == null) {
        return new byte[0];
    } else {
        return ArrayUtils.toPrimitive(data.toArray(new Byte[data.size()]));
    }
}
 
开发者ID:Scrin,项目名称:RuuviCollector,代码行数:8,代码来源:HCIData.java

示例6: getPeersFromResponseDict

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
public static Iterable<InetSocketAddress> getPeersFromResponseDict(Map<String, Object> responseDict) {
	
		return  () -> {
			return new Iterator<InetSocketAddress>() {
				byte[] responsePeers = ArrayUtils.toPrimitive((Byte[])responseDict.get("peers"));
				int index = 0;
				@Override
				public boolean hasNext() {
					return index < responsePeers.length;
				}
				@Override
				public InetSocketAddress next() {
					try {
						InetAddress addr = InetAddress.getByAddress(Arrays.copyOfRange(responsePeers, index, index+4));
						ByteBuffer portBuf = ByteBuffer.allocate(4);
						portBuf.put(2, responsePeers[index+4]);
						portBuf.put(3, responsePeers[index+5]);
						index += 6;
						return new InetSocketAddress(addr, portBuf.getInt());
					} catch (UnknownHostException e) {
						return null;
					}
				}
			};
		};
	
}
 
开发者ID:jc0541,项目名称:URTorrent,代码行数:28,代码来源:TrackerRequest.java

示例7: test_eq_trace_1

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
@Test
public void test_eq_trace_1() throws Exception {
    /*
        Creates a trace like:
                    EQ
                   /  \
                  /    \
               MUL     ADD
               /\       /\
              /  \     /  \
            0x5  0x2  0x3 CALLDATALOAD
     */
    BytecodeChunk chunk = createChunk(0,
            new Opcode(Opcodes.PUSH1, BigInteger.valueOf(0x5)),
            new Opcode(Opcodes.PUSH1, BigInteger.valueOf(0x2)),
            new Opcode(Opcodes.MUL, null),
            new Opcode(Opcodes.PUSH1, BigInteger.valueOf(0x0)),
            new Opcode(Opcodes.CALLDATALOAD, null),
            new Opcode(Opcodes.PUSH1, BigInteger.valueOf(0x3)),
            new Opcode(Opcodes.ADD, null),
            new Opcode(Opcodes.EQ, null),
            new Opcode(Opcodes.STOP, null)
    );

    EVMState evmState = symExecute(new HashMap<Integer, BytecodeChunk>() {{
        put(0, chunk);
    }});
    EVMStack stack = evmState.getStack();
    TraceableWord word = stack.pop();
    TraceTree trace = word.getTrace();

    EQTraceAnalyzer eqTraceAnalyzer = new EQTraceAnalyzer();
    EVMEnvironment environmentForTrace = eqTraceAnalyzer.createEnvironmentForTrace(trace, createDefaultEnvironment());
    byte[] bytes = ArrayUtils.toPrimitive((Byte[]) environmentForTrace.getCallData().toArray());
    BigInteger callDataLoad = new BigInteger(bytes);
    Assert.assertEquals(BigInteger.valueOf(0x7), callDataLoad);
}
 
开发者ID:fergarrui,项目名称:ethereum-bytecode-analyzer,代码行数:38,代码来源:EQTraceAnalyzerTest.java

示例8: test_eq_trace_2

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
@Test
public void test_eq_trace_2() throws Exception {

    BytecodeChunk chunk = createChunk(0,
            new Opcode(Opcodes.PUSH1, BigInteger.valueOf(0x2)),
            new Opcode(Opcodes.PUSH1, BigInteger.valueOf(0xA)),
            new Opcode(Opcodes.DIV, null),
            new Opcode(Opcodes.PUSH1, BigInteger.valueOf(1)),
            new Opcode(Opcodes.PUSH1, BigInteger.valueOf(2)),
            new Opcode(Opcodes.SUB, null),
            new Opcode(Opcodes.ADD, null),
            new Opcode(Opcodes.PUSH1, BigInteger.valueOf(0x2)),
            new Opcode(Opcodes.PUSH1, BigInteger.valueOf(0x0)),
            new Opcode(Opcodes.CALLDATALOAD, null),
            new Opcode(Opcodes.DIV, null),
            new Opcode(Opcodes.MUL, null),
            new Opcode(Opcodes.PUSH1, BigInteger.valueOf(0x6)),
            new Opcode(Opcodes.EQ, null),
            new Opcode(Opcodes.STOP, null)
    );

    EVMState evmState = symExecute(new HashMap<Integer, BytecodeChunk>() {{
        put(0, chunk);
    }});
    EVMStack stack = evmState.getStack();
    TraceableWord word = stack.pop();
    TraceTree trace = word.getTrace();

    EQTraceAnalyzer eqTraceAnalyzer = new EQTraceAnalyzer();
    EVMEnvironment environmentForTrace = eqTraceAnalyzer.createEnvironmentForTrace(trace, createDefaultEnvironment());
    byte[] bytes = ArrayUtils.toPrimitive((Byte[]) environmentForTrace.getCallData().toArray());
    BigInteger callDataLoad = new BigInteger(bytes);
    Assert.assertEquals(BigInteger.valueOf(0x2), callDataLoad);
}
 
开发者ID:fergarrui,项目名称:ethereum-bytecode-analyzer,代码行数:35,代码来源:EQTraceAnalyzerTest.java

示例9: test_eq_trace_function_calls

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
@Test
public void test_eq_trace_function_calls() throws Exception {

    BytecodeChunk chunk = createChunk(0,
            new Opcode(Opcodes.PUSH1, BigInteger.valueOf(0x0)),
            new Opcode(Opcodes.CALLDATALOAD, null),
            new Opcode(Opcodes.PUSH29, new BigInteger("100000000000000000000000000000000000000000000000000000000", 16)),
            new Opcode(Opcodes.SWAP1, null),
            new Opcode(Opcodes.DIV, null),
            new Opcode(Opcodes.PUSH4, BigInteger.valueOf(0xffffffff)),
            new Opcode(Opcodes.AND, null),
            new Opcode(Opcodes.PUSH4, BigInteger.valueOf(0x3f7a0270)),
            new Opcode(Opcodes.EQ, null),
            new Opcode(Opcodes.STOP, null)
    );

    EVMState evmState = symExecute(new HashMap<Integer, BytecodeChunk>() {{
        put(0, chunk);
    }});
    EVMStack stack = evmState.getStack();
    TraceableWord word = stack.pop();
    TraceTree trace = word.getTrace();

    EQTraceAnalyzer eqTraceAnalyzer = new EQTraceAnalyzer();
    EVMEnvironment environmentForTrace = eqTraceAnalyzer.createEnvironmentForTrace(trace, createDefaultEnvironment());
    byte[] bytes = ArrayUtils.toPrimitive((Byte[]) environmentForTrace.getCallData().toArray());
    BigInteger callDataLoad = new BigInteger(bytes);
    Assert.assertEquals(new BigInteger("3f7a027000000000000000000000000000000000000000000000000000000000", 16), callDataLoad);
}
 
开发者ID:fergarrui,项目名称:ethereum-bytecode-analyzer,代码行数:30,代码来源:EQTraceAnalyzerTest.java

示例10: decryptString

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
protected String decryptString(String alias, String text) throws CryptoException {

        if (!alias.isEmpty() && !text.isEmpty()) {
            try {
                KeyStore.PrivateKeyEntry privateKeyEntry = (KeyStore.PrivateKeyEntry) keyStore.getEntry(alias, null);

                Cipher output = Cipher.getInstance("RSA/ECB/PKCS1Padding");
                output.init(Cipher.DECRYPT_MODE, privateKeyEntry.getPrivateKey());

                CipherInputStream cipherInputStream = new CipherInputStream(
                        new ByteArrayInputStream(Base64.decode(text, Base64.DEFAULT)), output);

                ArrayList<Byte> values = new ArrayList<>();

                int nextByte;

                while ((nextByte = cipherInputStream.read()) != -1) {
                    values.add((byte) nextByte);
                }

                Byte[] bytes = values.toArray(new Byte[values.size()]);

                return new String(ArrayUtils.toPrimitive(bytes), 0, bytes.length, "UTF-8");

            } catch (Exception e) {
                Log.e(DEBUG_TAG, e.getMessage());
                throw new CryptoException(e.getMessage());
            }
        } else {
            Log.e(DEBUG_TAG, "EncryptString - String is empty");
            throw new CryptoException("EncryptString - String is empty");

        }
    }
 
开发者ID:wulkanowy,项目名称:wulkanowy,代码行数:35,代码来源:Scrambler.java

示例11: newRandomByteArray

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
 * @return An array of 256 bytes emulating binary content rather being a random text. The array contains
 *         all values possible for {@code byte} type in random order.
 */
public static byte[] newRandomByteArray() {

    // @formatter:off
    final List<Byte> byteList = IntStream.rangeClosed(Byte.MIN_VALUE, Byte.MAX_VALUE)
        .boxed()
        .map(Integer::byteValue)
        .collect(toList());
    // @formatter:on

    shuffle(byteList);

    return ArrayUtils.toPrimitive(byteList.toArray(new Byte[0]));
}
 
开发者ID:NHS-digital-website,项目名称:hippo,代码行数:18,代码来源:RandomHelper.java

示例12: toFlatArray

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
public double[] toFlatArray(Point[][] quadsList) {
	List<Double> result = new ArrayList<>();
	result.add(quadsList[0][0].x);
	result.add(quadsList[0][0].y);
	for (int i = 0; i < quadsList.length; i++) {
		result.add(quadsList[i][1].x);
		result.add(quadsList[i][1].y);
		result.add(quadsList[i][2].x);
		result.add(quadsList[i][2].y);
	}
	return ArrayUtils.toPrimitive(result.toArray(new Double[result.size()]));
}
 
开发者ID:icaoweiwei,项目名称:otf2ttf,代码行数:13,代码来源:CubicToQuad.java

示例13: getCallDataHex

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
public String getCallDataHex() {
    byte[] bytes = ArrayUtils.toPrimitive(callData.toArray(new Byte[callData.size()]));
    return Hex.encodeHexString(bytes);
}
 
开发者ID:fergarrui,项目名称:ethereum-bytecode-analyzer,代码行数:5,代码来源:EVMEnvironment.java


注:本文中的org.apache.commons.lang3.ArrayUtils.toPrimitive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。