Example usage for com.google.common.collect Multimap keySet

List of usage examples for com.google.common.collect Multimap keySet

Introduction

In this page you can find the example usage for com.google.common.collect Multimap keySet.

Prototype

Set<K> keySet();

Source Link

Document

Returns a view collection of all distinct keys contained in this multimap.

Usage

From source file:org.jetbrains.kotlin.idea.codeInsight.OverrideMethodsHandler.java

@NotNull
private static Set<CallableMemberDescriptor> collectSuperMethods(@NotNull ClassDescriptor classDescriptor) {
    Set<CallableMemberDescriptor> inheritedFunctions = new LinkedHashSet<CallableMemberDescriptor>();
    for (JetType supertype : classDescriptor.getTypeConstructor().getSupertypes()) {
        for (DeclarationDescriptor descriptor : supertype.getMemberScope().getAllDescriptors()) {
            if (descriptor instanceof CallableMemberDescriptor) {
                inheritedFunctions.add((CallableMemberDescriptor) descriptor);
            }/* ww w.j  a v a2s  .c o m*/
        }
    }

    // Only those actually inherited
    Set<CallableMemberDescriptor> filteredMembers = OverrideResolver.filterOutOverridden(inheritedFunctions);

    // Group members with "the same" signature
    Multimap<CallableMemberDescriptor, CallableMemberDescriptor> factoredMembers = LinkedHashMultimap.create();
    for (CallableMemberDescriptor one : filteredMembers) {
        if (factoredMembers.values().contains(one))
            continue;
        for (CallableMemberDescriptor another : filteredMembers) {
            //                if (one == another) continue;
            factoredMembers.put(one, one);
            if (OverridingUtil.DEFAULT.isOverridableBy(one, another).getResult() == OVERRIDABLE
                    || OverridingUtil.DEFAULT.isOverridableBy(another, one).getResult() == OVERRIDABLE) {
                factoredMembers.put(one, another);
            }
        }
    }

    return factoredMembers.keySet();
}

From source file:org.clusion.DynRHAndroid.java

public static TreeMultimap<String, byte[]> tokenUpdate(byte[] key, Multimap<String, String> lookup)
        throws InvalidKeyException, InvalidAlgorithmParameterException, NoSuchAlgorithmException,
        NoSuchProviderException, NoSuchPaddingException, IOException {

    // We use a lexicographic sorted list such that the server
    // will not know any information of the inserted elements creation order
    TreeMultimap<String, byte[]> tokenUp = TreeMultimap.create(Ordering.natural(), Ordering.usingToString());

    // Key generation
    for (String word : lookup.keySet()) {

        byte[] key2 = CryptoPrimitivesAndroid.generateCmac(key, 2 + word);
        // generate keys for response-hiding construction for SIV (Synthetic
        // IV)/* w w w.  ja v a 2s  .c  o  m*/
        byte[] key3 = CryptoPrimitivesAndroid.generateCmac(key, 3 + new String());

        byte[] key4 = CryptoPrimitivesAndroid.generateCmac(key, 4 + word);

        byte[] key5 = CryptoPrimitivesAndroid.generateCmac(key, 5 + word);

        for (String id : lookup.get(word)) {
            int counter = 0;

            if (state.get(word) != null) {
                counter = state.get(word);
            }

            state.put(word, counter + 1);

            byte[] l = CryptoPrimitivesAndroid.generateCmac(key5, "" + counter);

            String value = new String(CryptoPrimitivesAndroid.DTE_encryptAES_CTR_String(key3, key4, id, 20),
                    "ISO-8859-1");

            tokenUp.put(new String(l), CryptoPrimitivesAndroid.encryptAES_CTR_String(key2,
                    CryptoPrimitivesAndroid.randomBytes(16), value, sizeOfFileIdentifer));

        }

    }
    return tokenUp;
}

From source file:moa2014.MOA2014.java

public static void principal(int[][] matrizatual) {

    Multimap<Integer, String> open_list = TreeMultimap.create();
    HashMap<String, Estado> processados = new HashMap();

    int difmatrizatual = diferencaMatriz(matrizatual);

    String stringmatriz = transformaMatrizString(matrizatual);
    open_list.put(difmatrizatual, stringmatriz);
    Estado estadoatual = new Estado(matrizatual, 0);
    processados.put(stringmatriz, estadoatual);

    int counter = 1;

    while (!open_list.isEmpty()) {
        System.out.println("Arvores processadas: " + counter);
        Iterator iterator = open_list.keySet().iterator();
        /*//w  w  w  .j  a va  2 s .co  m
        Iterator iterator2 = open_list.keySet().iterator();
                
        while (iterator2.hasNext()) {
          Integer key = (Integer) iterator2.next();
          System.out.println("key : " + key + " value :" + open_list.get(key));
        }
                
        Scanner scanner = new Scanner( System.in );
        String input = scanner.nextLine();
        */
        counter++;
        Integer key = (Integer) iterator.next();
        String matrizatualx1 = open_list.asMap().get(key).iterator().next();
        Estado estadomenor = processados.get(matrizatualx1);
        int altura = estadomenor.getCusto();
        System.out.println("Altura: " + altura);
        //LOCALIZA O ZERO
        int[] zerot = localizazero(estadomenor.getMatriz());
        int x = zerot[0];
        int y = zerot[1];
        int x0 = x - 1;
        int x1 = x + 1;
        int y0 = y - 1;
        int y1 = y + 1;
        int difmatrizatualx = diferencaMatriz(estadomenor.getMatriz());
        if (difmatrizatualx == 0) {
            System.out.println("Arvores processadas: " + counter);
            System.out.println("Custo: " + estadomenor.getCusto());
            break;
        }
        int[][] matrizatualx = estadomenor.getMatriz();
        if (x0 >= 0) {

            int[][] matriz;
            matriz = copyarray(matrizatualx);
            matriz[x][y] = matrizatualx[x0][y];
            matriz[x0][y] = matrizatualx[x][y];

            String stringmatriz1 = transformaMatrizString(matriz);
            if (!(processados.containsKey(stringmatriz1))) {

                int diferencamatriz = diferencaMatriz(matriz);
                int custototal = diferencamatriz + altura + 1;

                Estado estadonovo = new Estado(matriz, altura + 1);
                open_list.put(custototal, stringmatriz1);

                processados.put(stringmatriz1, estadonovo);

            }
        }
        if (x1 <= 3) {
            int[][] matriz;
            matriz = copyarray(matrizatualx);
            matriz[x][y] = matrizatualx[x1][y];
            matriz[x1][y] = matrizatualx[x][y];
            String stringmatriz2 = transformaMatrizString(matriz);

            if (!(processados.containsKey(stringmatriz2))) {

                int diferencamatriz = diferencaMatriz(matriz);
                int custototal = diferencamatriz + altura + 1;

                Estado estadonovo = new Estado(matriz, altura + 1);
                open_list.put(custototal, stringmatriz2);

                processados.put(stringmatriz2, estadonovo);

            }
        }
        if (y0 >= 0) {
            int[][] matriz;
            matriz = copyarray(matrizatualx);
            matriz[x][y] = matrizatualx[x][y0];
            matriz[x][y0] = matrizatualx[x][y];
            String stringmatriz3 = transformaMatrizString(matriz);

            if (!(processados.containsKey(stringmatriz3))) {

                int diferencamatriz = diferencaMatriz(matriz);
                int custototal = diferencamatriz + altura + 1;

                Estado estadonovo = new Estado(matriz, altura + 1);
                open_list.put(custototal, stringmatriz3);

                processados.put(stringmatriz3, estadonovo);

            }
        }
        if (y1 <= 3) {
            int[][] matriz;
            matriz = copyarray(matrizatualx);
            matriz[x][y] = matrizatualx[x][y1];
            matriz[x][y1] = matrizatualx[x][y];

            int custoateaqui = diferencaMatriz(matriz) + altura + 1;
            String stringmatriz4 = transformaMatrizString(matriz);

            if (!(processados.containsKey(stringmatriz4))) {

                int diferencamatriz = diferencaMatriz(matriz);
                int custototal = diferencamatriz + altura + 1;

                Estado estadonovo = new Estado(matriz, altura + 1);
                open_list.put(custototal, stringmatriz4);

                processados.put(stringmatriz4, estadonovo);

            }
        }
        open_list.remove(key, matrizatualx1);
    }

}

From source file:moa2014.MOAH12014.java

public static int principal(int[][] matrizatual) {
    long startTime = System.currentTimeMillis();
    Multimap<Integer, String> open_list = TreeMultimap.create();
    HashMap<String, Estado> processados = new HashMap();

    int difmatrizatual = diferencaMatriz(matrizatual);

    String stringmatriz = transformaMatrizString(matrizatual);
    open_list.put(difmatrizatual, stringmatriz);
    Estado estadoatual = new Estado(matrizatual, 0);
    processados.put(stringmatriz, estadoatual);

    int arvoresgeradas = 0;
    int arvoresprocessadas = 0;

    while (!open_list.isEmpty()) {

        Iterator iterator = open_list.keySet().iterator();
        Integer key = (Integer) iterator.next();
        String matrizatualx1 = open_list.asMap().get(key).iterator().next();
        Estado estadomenor = processados.get(matrizatualx1);
        int altura = estadomenor.getCusto();
        //LOCALIZA O ZERO
        int[] zerot = localizazero(estadomenor.getMatriz());
        int x = zerot[0];
        int y = zerot[1];
        int x0 = x - 1;
        int x1 = x + 1;
        int y0 = y - 1;
        int y1 = y + 1;
        int difmatrizatualx = diferencaMatriz(estadomenor.getMatriz());
        if (difmatrizatualx == 0) {
            long endTime = System.currentTimeMillis();
            System.out.println("---------------------------------------");
            System.out.println("Arvores Geradas: " + arvoresgeradas);
            System.out.println("Arvores Processadas: " + arvoresprocessadas);
            System.out.println("Quantidade de Movimentos: " + estadomenor.getCusto());
            System.out.println("Tempo de processamento " + (endTime - startTime) + " ms");
            System.out.println("---------------------------------------\n\n");
            return 0;
        }//  w ww  .j  av  a2s  . com
        arvoresprocessadas++;
        int[][] matrizatualx = estadomenor.getMatriz();
        if (x0 >= 0) {

            int[][] matriz;
            matriz = copyarray(matrizatualx);
            matriz[x][y] = matrizatualx[x0][y];
            matriz[x0][y] = matrizatualx[x][y];

            String stringmatriz1 = transformaMatrizString(matriz);
            if (!(processados.containsKey(stringmatriz1))) {
                arvoresgeradas++;
                int diferencamatriz = diferencaMatriz(matriz);
                int custototal = diferencamatriz + altura + 1;

                Estado estadonovo = new Estado(matriz, altura + 1);
                open_list.put(custototal, stringmatriz1);

                processados.put(stringmatriz1, estadonovo);

            }
        }
        if (x1 <= 3) {
            int[][] matriz;
            matriz = copyarray(matrizatualx);
            matriz[x][y] = matrizatualx[x1][y];
            matriz[x1][y] = matrizatualx[x][y];
            String stringmatriz2 = transformaMatrizString(matriz);

            if (!(processados.containsKey(stringmatriz2))) {
                arvoresgeradas++;
                int diferencamatriz = diferencaMatriz(matriz);
                int custototal = diferencamatriz + altura + 1;

                Estado estadonovo = new Estado(matriz, altura + 1);
                open_list.put(custototal, stringmatriz2);

                processados.put(stringmatriz2, estadonovo);

            }
        }
        if (y0 >= 0) {
            int[][] matriz;
            matriz = copyarray(matrizatualx);
            matriz[x][y] = matrizatualx[x][y0];
            matriz[x][y0] = matrizatualx[x][y];
            String stringmatriz3 = transformaMatrizString(matriz);

            if (!(processados.containsKey(stringmatriz3))) {
                arvoresgeradas++;
                int diferencamatriz = diferencaMatriz(matriz);
                int custototal = diferencamatriz + altura + 1;

                Estado estadonovo = new Estado(matriz, altura + 1);
                open_list.put(custototal, stringmatriz3);

                processados.put(stringmatriz3, estadonovo);

            }
        }
        if (y1 <= 3) {
            int[][] matriz;
            matriz = copyarray(matrizatualx);
            matriz[x][y] = matrizatualx[x][y1];
            matriz[x][y1] = matrizatualx[x][y];

            int custoateaqui = diferencaMatriz(matriz) + altura + 1;
            String stringmatriz4 = transformaMatrizString(matriz);

            if (!(processados.containsKey(stringmatriz4))) {
                arvoresgeradas++;
                int diferencamatriz = diferencaMatriz(matriz);
                int custototal = diferencamatriz + altura + 1;

                Estado estadonovo = new Estado(matriz, altura + 1);
                open_list.put(custototal, stringmatriz4);

                processados.put(stringmatriz4, estadonovo);

            }
        }
        open_list.remove(key, matrizatualx1);
    }
    return 0;

}

From source file:com.giaybac.traprange.MAIN.java

private static void extractTables(String[] args) {
    try {//from  www . j av  a 2s .  c o m
        List<Integer> pages = getPages(args);
        List<Integer> exceptPages = getExceptPages(args);
        List<Integer[]> exceptLines = getExceptLines(args);
        String in = getIn(args);
        String out = getOut(args);

        PDFTableExtractor extractor = (new PDFTableExtractor()).setSource(in);
        //page
        for (Integer page : pages) {
            extractor.addPage(page);
        }
        //except page
        for (Integer exceptPage : exceptPages) {
            extractor.exceptPage(exceptPage);
        }
        //except lines
        List<Integer> exceptLineIdxs = new ArrayList<>();
        Multimap<Integer, Integer> exceptLineInPages = LinkedListMultimap.create();
        for (Integer[] exceptLine : exceptLines) {
            if (exceptLine.length == 1) {
                exceptLineIdxs.add(exceptLine[0]);
            } else if (exceptLine.length == 2) {
                int lineIdx = exceptLine[0];
                int pageIdx = exceptLine[1];
                exceptLineInPages.put(pageIdx, lineIdx);
            }
        }
        if (!exceptLineIdxs.isEmpty()) {
            extractor.exceptLine(Ints.toArray(exceptLineIdxs));
        }
        if (!exceptLineInPages.isEmpty()) {
            for (int pageIdx : exceptLineInPages.keySet()) {
                extractor.exceptLine(pageIdx, Ints.toArray(exceptLineInPages.get(pageIdx)));
            }
        }
        //begin parsing pdf file
        List<Table> tables = extractor.extract();

        Writer writer = new OutputStreamWriter(new FileOutputStream(out), "UTF-8");
        try {
            for (Table table : tables) {
                writer.write("Page: " + (table.getPageIdx() + 1) + "\n");
                writer.write(table.toHtml());
            }
        } finally {
            try {
                writer.close();
            } catch (Exception e) {
            }
        }
    } catch (Exception e) {
        logger.error(null, e);
    }
}

From source file:moa2014.MOAH32014.java

public static int principal(int[][] matrizatual) {
    long startTime = System.currentTimeMillis();
    Multimap<Integer, String> open_list = TreeMultimap.create();
    HashMap<String, Estado> processados = new HashMap();

    int difmatrizatual = diferencaMatriz(matrizatual);

    String stringmatriz = transformaMatrizString(matrizatual);
    open_list.put(difmatrizatual, stringmatriz);
    Estado estadoatual = new Estado(matrizatual, 0);
    processados.put(stringmatriz, estadoatual);

    int arvoresgeradas = 0;
    int arvoresprocessadas = 0;

    while (!open_list.isEmpty()) {
        Iterator iterator = open_list.keySet().iterator();
        Integer key = (Integer) iterator.next();
        String matrizatualx1 = open_list.asMap().get(key).iterator().next();
        Estado estadomenor = processados.get(matrizatualx1);
        int altura = estadomenor.getCusto();
        //LOCALIZA O ZERO
        int[] zerot = localizazero(estadomenor.getMatriz());
        int x = zerot[0];
        int y = zerot[1];
        int x0 = x - 1;
        int x1 = x + 1;
        int y0 = y - 1;
        int y1 = y + 1;
        int difmatrizatualx = diferencaMatriz(estadomenor.getMatriz());
        if (difmatrizatualx == 0) {
            long endTime = System.currentTimeMillis();
            System.out.println("---------------------------------------");
            System.out.println("Arvores Geradas: " + arvoresgeradas);
            System.out.println("Arvores Processadas: " + arvoresprocessadas);
            System.out.println("Quantidade de Movimentos: " + estadomenor.getCusto());
            System.out.println("Tempo de processamento " + (endTime - startTime) + " ms");
            System.out.println("---------------------------------------\n\n");
            return 0;
        }/*from  w  ww.  j  av  a  2 s  .  c o  m*/
        arvoresprocessadas++;
        int[][] matrizatualx = estadomenor.getMatriz();
        if (x0 >= 0) {

            int[][] matriz;
            matriz = copyarray(matrizatualx);
            matriz[x][y] = matrizatualx[x0][y];
            matriz[x0][y] = matrizatualx[x][y];

            String stringmatriz1 = transformaMatrizString(matriz);
            if (!(processados.containsKey(stringmatriz1))) {
                arvoresgeradas++;
                int diferencamatriz = diferencaMatriz(matriz);
                int custototal = diferencamatriz + altura + 1;

                Estado estadonovo = new Estado(matriz, altura + 1);
                open_list.put(custototal, stringmatriz1);

                processados.put(stringmatriz1, estadonovo);

            }
        }
        if (x1 <= 3) {
            int[][] matriz;
            matriz = copyarray(matrizatualx);
            matriz[x][y] = matrizatualx[x1][y];
            matriz[x1][y] = matrizatualx[x][y];
            String stringmatriz2 = transformaMatrizString(matriz);

            if (!(processados.containsKey(stringmatriz2))) {
                arvoresgeradas++;
                int diferencamatriz = diferencaMatriz(matriz);
                int custototal = diferencamatriz + altura + 1;

                Estado estadonovo = new Estado(matriz, altura + 1);
                open_list.put(custototal, stringmatriz2);

                processados.put(stringmatriz2, estadonovo);

            }
        }
        if (y0 >= 0) {
            int[][] matriz;
            matriz = copyarray(matrizatualx);
            matriz[x][y] = matrizatualx[x][y0];
            matriz[x][y0] = matrizatualx[x][y];
            String stringmatriz3 = transformaMatrizString(matriz);

            if (!(processados.containsKey(stringmatriz3))) {
                arvoresgeradas++;
                int diferencamatriz = diferencaMatriz(matriz);
                int custototal = diferencamatriz + altura + 1;

                Estado estadonovo = new Estado(matriz, altura + 1);
                open_list.put(custototal, stringmatriz3);

                processados.put(stringmatriz3, estadonovo);

            }
        }
        if (y1 <= 3) {
            int[][] matriz;
            matriz = copyarray(matrizatualx);
            matriz[x][y] = matrizatualx[x][y1];
            matriz[x][y1] = matrizatualx[x][y];

            int custoateaqui = diferencaMatriz(matriz) + altura + 1;
            String stringmatriz4 = transformaMatrizString(matriz);

            if (!(processados.containsKey(stringmatriz4))) {
                arvoresgeradas++;
                int diferencamatriz = diferencaMatriz(matriz);
                int custototal = diferencamatriz + altura + 1;

                Estado estadonovo = new Estado(matriz, altura + 1);
                open_list.put(custototal, stringmatriz4);

                processados.put(stringmatriz4, estadonovo);

            }
        }
        open_list.remove(key, matrizatualx1);
    }
    return 0;

}

From source file:moa2014.MOAH22014.java

public static int principal(int[][] matrizatual) {
    long startTime = System.currentTimeMillis();
    Multimap<Integer, String> open_list = TreeMultimap.create();
    HashMap<String, Estado> processados = new HashMap();

    int difmatrizatual = diferencaMatriz(matrizatual);

    String stringmatriz = transformaMatrizString(matrizatual);
    open_list.put(difmatrizatual, stringmatriz);
    Estado estadoatual = new Estado(matrizatual, 0);
    processados.put(stringmatriz, estadoatual);

    int arvoresgeradas = 0;
    int arvoresprocessadas = 0;

    while (!open_list.isEmpty()) {
        Iterator iterator = open_list.keySet().iterator();

        Integer key = (Integer) iterator.next();
        String matrizatualx1 = open_list.asMap().get(key).iterator().next();
        Estado estadomenor = processados.get(matrizatualx1);
        int altura = estadomenor.getCusto();
        //LOCALIZA O ZERO
        int[] zerot = localizazero(estadomenor.getMatriz());
        int x = zerot[0];
        int y = zerot[1];
        int x0 = x - 1;
        int x1 = x + 1;
        int y0 = y - 1;
        int y1 = y + 1;
        int difmatrizatualx = diferencaMatriz(estadomenor.getMatriz());
        if (difmatrizatualx == 0) {
            long endTime = System.currentTimeMillis();
            System.out.println("---------------------------------------");
            System.out.println("Arvores Geradas: " + arvoresgeradas);
            System.out.println("Arvores Processadas: " + arvoresprocessadas);
            System.out.println("Quantidade de Movimentos: " + estadomenor.getCusto());
            System.out.println("Tempo de processamento " + (endTime - startTime) + " ms");
            System.out.println("---------------------------------------\n\n");
            return 0;
        }/*from   w w w  . ja v a2 s .c  o m*/
        arvoresprocessadas++;
        int[][] matrizatualx = estadomenor.getMatriz();
        if (x0 >= 0) {

            int[][] matriz;
            matriz = copyarray(matrizatualx);
            matriz[x][y] = matrizatualx[x0][y];
            matriz[x0][y] = matrizatualx[x][y];

            String stringmatriz1 = transformaMatrizString(matriz);
            if (!(processados.containsKey(stringmatriz1))) {
                arvoresgeradas++;
                int diferencamatriz = diferencaMatriz(matriz);
                int custototal = diferencamatriz + altura + 1;

                Estado estadonovo = new Estado(matriz, altura + 1);
                open_list.put(custototal, stringmatriz1);

                processados.put(stringmatriz1, estadonovo);

            }
        }
        if (x1 <= 3) {
            int[][] matriz;
            matriz = copyarray(matrizatualx);
            matriz[x][y] = matrizatualx[x1][y];
            matriz[x1][y] = matrizatualx[x][y];
            String stringmatriz2 = transformaMatrizString(matriz);

            if (!(processados.containsKey(stringmatriz2))) {
                arvoresgeradas++;
                int diferencamatriz = diferencaMatriz(matriz);
                int custototal = diferencamatriz + altura + 1;

                Estado estadonovo = new Estado(matriz, altura + 1);
                open_list.put(custototal, stringmatriz2);

                processados.put(stringmatriz2, estadonovo);

            }
        }
        if (y0 >= 0) {
            int[][] matriz;
            matriz = copyarray(matrizatualx);
            matriz[x][y] = matrizatualx[x][y0];
            matriz[x][y0] = matrizatualx[x][y];
            String stringmatriz3 = transformaMatrizString(matriz);

            if (!(processados.containsKey(stringmatriz3))) {
                arvoresgeradas++;
                int diferencamatriz = diferencaMatriz(matriz);
                int custototal = diferencamatriz + altura + 1;

                Estado estadonovo = new Estado(matriz, altura + 1);
                open_list.put(custototal, stringmatriz3);

                processados.put(stringmatriz3, estadonovo);

            }
        }
        if (y1 <= 3) {
            int[][] matriz;
            matriz = copyarray(matrizatualx);
            matriz[x][y] = matrizatualx[x][y1];
            matriz[x][y1] = matrizatualx[x][y];

            int custoateaqui = diferencaMatriz(matriz) + altura + 1;
            String stringmatriz4 = transformaMatrizString(matriz);

            if (!(processados.containsKey(stringmatriz4))) {
                arvoresgeradas++;
                int diferencamatriz = diferencaMatriz(matriz);
                int custototal = diferencamatriz + altura + 1;

                Estado estadonovo = new Estado(matriz, altura + 1);
                open_list.put(custototal, stringmatriz4);

                processados.put(stringmatriz4, estadonovo);

            }
        }
        open_list.remove(key, matrizatualx1);
    }
    return 0;

}

From source file:org.crypto.sse.DynRH_Disk.java

public static TreeMultimap<String, byte[]> tokenUpdate(byte[] key, Multimap<String, String> lookup)
        throws InvalidKeyException, InvalidAlgorithmParameterException, NoSuchAlgorithmException,
        NoSuchProviderException, NoSuchPaddingException, IOException {

    // A lexicographic sorted tree to hide order of insertion
    TreeMultimap<String, byte[]> tokenUp = TreeMultimap.create(Ordering.natural(), Ordering.usingToString());
    // Key generation
    SecureRandom random = new SecureRandom();
    random.setSeed(CryptoPrimitives.randomSeed(16));
    byte[] iv = new byte[16];

    for (String word : lookup.keySet()) {

        byte[] key1 = CryptoPrimitives.generateCmac(key, 1 + new String());

        byte[] key2 = CryptoPrimitives.generateCmac(key, 2 + word);

        for (String id : lookup.get(word)) {
            random.nextBytes(iv);//from ww  w . j  av a2 s. c  o  m
            int counter = 0;

            if (state.get(word) != null) {
                counter = state.get(word);
            }

            state.put(word, counter + 1);

            byte[] l = CryptoPrimitives.generateCmac(key2, "" + counter);

            byte[] value = CryptoPrimitives.encryptAES_CTR_String(key1, iv, id, sizeOfFileIdentifer);
            tokenUp.put(new String(l), value);
        }

    }
    return tokenUp;
}

From source file:com.android.tools.idea.templates.GradleFileMerger.java

private static void mergeDependencies(@NotNull PsiElement fromRoot, @NotNull PsiElement toRoot,
        @NotNull Project project) {//w ww. j  a v  a 2  s.c  o  m
    Multimap<String, GradleCoordinate> dependencies = LinkedListMultimap.create();
    List<String> unparseableDependencies = new ArrayList<String>();

    // Load existing dependencies into the map for the existing build.gradle
    pullDependenciesIntoMap(toRoot, dependencies, null);

    // Load dependencies into the map for the new build.gradle
    pullDependenciesIntoMap(fromRoot, dependencies, unparseableDependencies);

    GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(project);

    RepositoryUrlManager urlManager = RepositoryUrlManager.get();

    for (String key : dependencies.keySet()) {
        GradleCoordinate highest = Collections.max(dependencies.get(key), COMPARE_PLUS_LOWER);

        // For test consistency, don't depend on installed SDK state while testing
        if (!ApplicationManager.getApplication().isUnitTestMode()
                || Boolean.getBoolean("force.gradlemerger.repository.check")) {
            // If this coordinate points to an artifact in one of our repositories, check to see if there is a static version
            // that we can add instead of a plus revision.
            if (RepositoryUrlManager.supports(highest.getArtifactId())) {
                String libraryCoordinate = urlManager.getLibraryCoordinate(highest.getArtifactId(), null,
                        false /* No previews */);
                GradleCoordinate available = GradleCoordinate.parseCoordinateString(libraryCoordinate);

                if (available != null) {
                    File archiveFile = urlManager.getArchiveForCoordinate(available);
                    if (archiveFile != null && archiveFile.exists()
                            && COMPARE_PLUS_LOWER.compare(available, highest) >= 0) {
                        highest = available;
                    }
                }
            }
        }
        PsiElement dependencyElement = factory
                .createStatementFromText(String.format(COMPILE_FORMAT, highest.toString()));
        toRoot.addBefore(dependencyElement, toRoot.getLastChild());
    }
    for (String unparseableDependency : unparseableDependencies) {
        PsiElement dependencyElement = factory.createStatementFromText(unparseableDependency);
        toRoot.addBefore(dependencyElement, toRoot.getLastChild());
    }
}

From source file:com.ardor3d.util.TextureManager.java

private static void handleTextureDelete(final Renderer deleter, final Multimap<Object, Integer> idMap,
        final Map<Object, Future<Void>> futureStore) {
    Object currentGLRef = null;/*  w  ww.ja v a 2  s .c o  m*/
    // Grab the current context, if any.
    if (deleter != null && ContextManager.getCurrentContext() != null) {
        currentGLRef = ContextManager.getCurrentContext().getGlContextRep();
    }
    // For each affected context...
    for (final Object glref : idMap.keySet()) {
        // If we have a deleter and the context is current, immediately delete
        if (currentGLRef != null && (!Constants.useMultipleContexts || glref.equals(currentGLRef))) {
            deleter.deleteTextureIds(idMap.get(glref));
        }
        // Otherwise, add a delete request to that context's render task queue.
        else {
            final Future<Void> future = GameTaskQueueManager.getManager(ContextManager.getContextForRef(glref))
                    .render(new RendererCallable<Void>() {
                        public Void call() throws Exception {
                            getRenderer().deleteTextureIds(idMap.get(glref));
                            return null;
                        }
                    });
            if (futureStore != null) {
                futureStore.put(glref, future);
            }
        }
    }
}