Example usage for java.util LinkedList get

List of usage examples for java.util LinkedList get

Introduction

In this page you can find the example usage for java.util LinkedList get.

Prototype

public E get(int index) 

Source Link

Document

Returns the element at the specified position in this list.

Usage

From source file:com.apress.prospringintegration.web.MultipartReceiver.java

@ServiceActivator
public void handleMultipartRequest(LinkedMultiValueMap<String, Object> multipartRequest) {
    System.out.println("Received multipart request: " + multipartRequest);
    for (String elementName : multipartRequest.keySet()) {
        if (elementName.equals("name")) {
            LinkedList value = (LinkedList) multipartRequest.get("name");
            String[] multiValues = (String[]) value.get(0);
            for (String name : multiValues) {
                System.out.println("Name: " + name);
            }/*from  w ww .  j  a  v a 2 s. c o  m*/
        } else if (elementName.equals("picture")) {
            System.out.println("Picture as UploadedMultipartFile: "
                    + ((UploadedMultipartFile) multipartRequest.getFirst("picture")).getOriginalFilename());
        }
    }
}

From source file:overTrial.CreateGraphOverTrial.java

private DefaultCategoryDataset createDataset() {

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (LinkedList<String> lineData : this.pressureData) {
        dataset.addValue(Double.parseDouble(lineData.get(this.sensorNumber)), "pressure", lineData.get(2));
    }//from   w w w .j  a  v  a  2 s. co m
    return dataset;
}

From source file:org.springframework.integration.samples.multipart.MultipartReceiver.java

@SuppressWarnings("rawtypes")
public void receive(LinkedMultiValueMap<String, Object> multipartRequest) {
    logger.info("Successfully received multipart request: " + multipartRequest);
    for (String elementName : multipartRequest.keySet()) {
        if (elementName.equals("company")) {
            LinkedList value = (LinkedList) multipartRequest.get("company");
            String[] multiValues = (String[]) value.get(0);
            for (String companyName : multiValues) {
                logger.info(elementName + " - " + companyName);
            }/*from  www  .  ja  v a 2 s  .  co  m*/
        } else if (elementName.equals("company-logo")) {
            logger.info(elementName + " - as UploadedMultipartFile: "
                    + ((UploadedMultipartFile) multipartRequest.getFirst("company-logo"))
                            .getOriginalFilename());
        }
    }
}

From source file:overSession.CreateGraph.java

private DefaultCategoryDataset createDataset() {

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (LinkedList<String> sessionData : this.pressureData) {
        dataset.addValue(Double.parseDouble(sessionData.get(this.sensorNumber)), "pressure",
                sessionData.get(0) + sessionData.get(1));
    }//from   w  ww .  ja v  a 2s  .co m
    return dataset;
}

From source file:cascading.ComparePlatformsTest.java

private static void createComparisons(String comparison, File lhsRoot, File rhsRoot, TestSuite suite) {
    LOG.info("comparing directory: {}, with: {}", lhsRoot, rhsRoot);

    LinkedList<File> lhsFiles = new LinkedList<File>(
            FileUtils.listFiles(lhsRoot, new RegexFileFilter("^[\\w-]+"), TrueFileFilter.INSTANCE));
    LinkedList<File> rhsFiles = new LinkedList<File>();

    LOG.info("found lhs files: {}", lhsFiles.size());

    int rootLength = lhsRoot.toString().length() + 1;

    ListIterator<File> iterator = lhsFiles.listIterator();
    while (iterator.hasNext()) {
        File localFile = iterator.next();
        File file = new File(rhsRoot, localFile.toString().substring(rootLength));

        if (localFile.toString().endsWith(NONDETERMINISTIC))
            iterator.remove();/*from w ww. ja v  a 2 s  .c  o m*/
        else if (file.exists())
            rhsFiles.add(file);
        else
            iterator.remove();
    }

    LOG.info("running {} comparisons", lhsFiles.size());

    for (int i = 0; i < lhsFiles.size(); i++) {
        File localFile = lhsFiles.get(i);
        File hadoopFile = rhsFiles.get(i);

        suite.addTest(new CompareTestCase(comparison, localFile, hadoopFile));
    }
}

From source file:strat.mining.stratum.proxy.utils.mining.SHA256HashingUtils.java

/**
 * Compute the SHA256 midstate of the given 64 bytes of data and return the
 * 32 bytes midstate. This algorithm is the Java implementation of the
 * Python implementation got from the Slush0 stratum proxy.
 * /* ww  w.j a va 2  s  . c  o m*/
 * @param data
 * @return
 */
public static final byte[] midstateSHA256(byte[] data) {
    if (data.length != 64) {
        throw new IndexOutOfBoundsException("Data must be 64 bytes long");
    }

    LinkedList<Long> w = new LinkedList<>();
    for (int i = 0; i < 16; i++) {
        int dataIndex = i * 4;
        w.add(Longs.fromBytes((byte) 0, (byte) 0, (byte) 0, (byte) 0, data[dataIndex + 3], data[dataIndex + 2],
                data[dataIndex + 1], data[dataIndex]));
    }

    long a = A0;
    long b = B0;
    long c = C0;
    long d = D0;
    long e = E0;
    long f = F0;
    long g = G0;
    long h = H0;

    for (long k : K) {
        long s0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22);
        long s1 = rotateRight(e, 6) ^ rotateRight(e, 11) ^ rotateRight(e, 25);
        long ma = (a & b) ^ (a & c) ^ (b & c);
        long ch = (e & f) ^ ((~e) & g);

        h = addu32(h, w.get(0), k, ch, s1);
        d = addu32(d, h);
        h = addu32(h, ma, s0);

        long tempa = a;
        a = h;
        h = g;
        g = f;
        f = e;
        e = d;
        d = c;
        c = b;
        b = tempa;

        long w1 = w.get(1);
        long w14 = w.get(14);
        s0 = rotateRight(w1, 7) ^ rotateRight(w1, 18) ^ (w1 >> 3);
        s1 = rotateRight(w14, 17) ^ rotateRight(w14, 19) ^ (w14 >> 10);
        w.add(addu32(w.get(0), s0, w.get(9), s1));
        w.remove(0);
    }

    a = addu32(a, A0);
    b = addu32(b, B0);
    c = addu32(c, C0);
    d = addu32(d, D0);
    e = addu32(e, E0);
    f = addu32(f, F0);
    g = addu32(g, G0);
    h = addu32(h, H0);

    byte[] result = new byte[32];
    byte[] bytes = Longs.toByteArray(a);
    result[0] = bytes[7];
    result[1] = bytes[6];
    result[2] = bytes[5];
    result[3] = bytes[4];

    bytes = Longs.toByteArray(b);
    result[4] = bytes[7];
    result[5] = bytes[6];
    result[6] = bytes[5];
    result[7] = bytes[4];

    bytes = Longs.toByteArray(c);
    result[8] = bytes[7];
    result[9] = bytes[6];
    result[10] = bytes[5];
    result[11] = bytes[4];

    bytes = Longs.toByteArray(d);
    result[12] = bytes[7];
    result[13] = bytes[6];
    result[14] = bytes[5];
    result[15] = bytes[4];

    bytes = Longs.toByteArray(e);
    result[16] = bytes[7];
    result[17] = bytes[6];
    result[18] = bytes[5];
    result[19] = bytes[4];

    bytes = Longs.toByteArray(f);
    result[20] = bytes[7];
    result[21] = bytes[6];
    result[22] = bytes[5];
    result[23] = bytes[4];

    bytes = Longs.toByteArray(g);
    result[24] = bytes[7];
    result[25] = bytes[6];
    result[26] = bytes[5];
    result[27] = bytes[4];

    bytes = Longs.toByteArray(h);
    result[28] = bytes[7];
    result[29] = bytes[6];
    result[30] = bytes[5];
    result[31] = bytes[4];

    return result;
}

From source file:data_gen.Data_gen.java

private static void multi_enum_json(HashMap<String, Object> fields, String key, String value) {
    try {/*  w  w  w . j a va  2s . c  om*/
        String[] values = value.split(":");
        String trim_val = values[1].substring(1, values[1].length() - 1);
        String[] possible_values = trim_val.split(",");
        LinkedList<String> all = new LinkedList(Arrays.asList(possible_values));
        Random rand = new Random();
        Random rand2 = new Random();
        String result = "";
        int r = rand.nextInt(possible_values.length - 1);
        if (r == 0) {
            r = 1;
        }
        String[] words = new String[r];
        for (int i = 0; i < r; i++) {
            int r2 = rand.nextInt(all.size() - 1);
            words[i] = all.get(r2);
            all.remove(r2);
        }
        List<String> myList = new ArrayList<>(Arrays.asList(words));

        fields.put(key, myList);
    } catch (ArrayIndexOutOfBoundsException e) {
        System.out.println("Make sure you have the right multi value enumeration format in configration file");
        System.out.println("example:    multi:[science,sport,art,literature,politics]" + "\n");
        System.exit(0);

    }

}

From source file:data_gen.Data_gen.java

private static void multi_enum_dat(HashMap<String, Object> fields, String key, String value) {
    try {/*from  w  w  w .j a v  a2  s.  co m*/
        String[] values = value.split(":");
        String trim_val = values[1].substring(1, values[1].length() - 1);
        String[] possible_values = trim_val.split(",");
        LinkedList<String> all = new LinkedList(Arrays.asList(possible_values));
        Random rand = new Random();
        Random rand2 = new Random();
        String result = "";
        int r = rand.nextInt(possible_values.length - 1);
        if (r == 0) {
            r = 1;
        }
        String[] words = new String[r];
        for (int i = 0; i < r; i++) {
            int r2 = rand.nextInt(all.size() - 1);
            words[i] = all.get(r2);
            all.remove(r2);
        }
        String multi_values = "";
        for (int i = 0; i < words.length; i++) {
            multi_values += words[i] + (char) 59;
        }
        multi_values = multi_values.substring(0, multi_values.length() - 1);
        fields.put(key, multi_values);
    } catch (ArrayIndexOutOfBoundsException e) {
        System.out.println("Make sure you have the right multi value enumeration format in configration file");
        System.out.println("example:    multi:[science,sport,art,literature,politics]" + "\n");
        System.exit(0);

    }

}

From source file:io.hops.common.INodeUtil.java

public static void findPathINodesById(long inodeId, boolean inTree, LinkedList<INode> preTxResolvedINodes,
        boolean[] isPreTxPathFullyResolved) throws StorageException {
    if (inTree) {
        INode inode = indexINodeScanById(inodeId);
        if (inode == null) {
            isPreTxPathFullyResolved[0] = false;
            return;
        }/*from   w  w  w  .j a  v  a 2s .  c o  m*/
        preTxResolvedINodes.add(inode);
        readFromLeafToRoot(inode, preTxResolvedINodes);
    }
    isPreTxPathFullyResolved[0] = true;
    //reverse the list
    int firstCounter = 0;
    int lastCounter = preTxResolvedINodes.size() - 1 - firstCounter;
    INode firstNode = null;
    INode lastNode = null;
    while (firstCounter < (preTxResolvedINodes.size() / 2)) {
        firstNode = preTxResolvedINodes.get(firstCounter);
        lastNode = preTxResolvedINodes.get(lastCounter);
        preTxResolvedINodes.remove(firstCounter);
        preTxResolvedINodes.add(firstCounter, lastNode);
        preTxResolvedINodes.remove(lastCounter);
        preTxResolvedINodes.add(lastCounter, firstNode);
        firstCounter++;
        lastCounter = preTxResolvedINodes.size() - 1 - firstCounter;
    }
}

From source file:com.jnj.b2b.core.search.solrfacetsearch.provider.entity.VariantValueCategoryModelPriorityComparator.java

private LinkedList<CategoryModel> getPathToRoot(final VariantValueCategoryModel variantValueCategory) {
    final LinkedList<CategoryModel> pathToRoot = new LinkedList<>(
            getCategoryService().getPathForCategory(variantValueCategory));

    while (!getCategoryService().isRoot(pathToRoot.get(0))) {
        pathToRoot.addAll(0, getCategoryService().getPathForCategory(pathToRoot.get(0)));
    }/* w  w  w  .  j  a  v a2  s .  c  o  m*/

    return pathToRoot;
}