Example usage for java.util HashMap values

List of usage examples for java.util HashMap values

Introduction

In this page you can find the example usage for java.util HashMap values.

Prototype

public Collection<V> values() 

Source Link

Document

Returns a Collection view of the values contained in this map.

Usage

From source file:com.antelink.sourcesquare.client.scan.ProcessWorker.java

/**
 * Launches the process of a set of files.
 * /*w  ww. ja va 2  s .c  o  m*/
 * @param tempMap
 *            a map containing a set of tuples (filename,hash)
 */
public synchronized void process(final HashMap<String, String> tempMap) {

    this.status = false;

    logger.debug("Worker " + this.id + " analyzing files " + tempMap.values());

    Runnable runner = new Runnable() {

        @Override
        public void run() {
            try {
                analyzeMapWithCount(0, tempMap);
            } catch (Exception e) {
                logger.error("Error while processing", e);
            } finally {
                ProcessWorker.this.status = true;
                synchronized (ProcessWorker.this.lock) {
                    ProcessWorker.this.lock.notifyAll();
                }
            }
        }
    };
    this.executor = new Thread(runner);
    this.executor.start();
}

From source file:mase.generic.WeightedClusterSCPostEval.java

@Override
protected void initializeClusters(EvolutionState state) {
    // initialization should also be biased. the probability of being chosen
    // is proportional to the weight

    this.clusters = new double[numClusters][];
    this.counts = new int[numClusters];
    Integer[] list = new Integer[buffer.size()];
    buffer.keySet().toArray(list);/*from  w w w .jav a2  s. co  m*/
    HashSet<Integer> randomKeys = new HashSet<Integer>(numClusters * 2);
    HashMap<Integer, Double> pointWeight = stateCorrelations(state);
    double totalWeight = 0;
    for (Double d : pointWeight.values()) {
        totalWeight += d;
    }

    while (randomKeys.size() < numClusters) {
        int next = -1;
        double rand = state.random[0].nextDouble() * totalWeight;
        for (int i = 0; i < list.length; i++) {
            rand -= pointWeight.get(list[i]);
            if (rand <= 0.0) {
                next = list[i];
                break;
            }
        }
        if (!randomKeys.contains(next)) {
            randomKeys.add(next);
        }
    }
    int clusterIndex = 0;
    for (Integer key : randomKeys) {
        byte[] s = globalKey.get(key);
        double[] cl = new double[s.length];
        for (int i = 0; i < s.length; i++) {
            cl[i] = s[i];
        }
        clusters[clusterIndex++] = cl;
    }

}

From source file:es.udc.robotcontrol.testapp.comunication.ConectorPlaca.java

public void conectarManual(Context ctx) throws TransmisionErrorException {
    Log.i(Constantes.TAG_CONECTOR, "Conectando manualmente. modo - Host");
    /* Get the USB manager from the requesting context */
    this.manager = (UsbManager) ctx.getSystemService(Context.USB_SERVICE);

    HashMap<String, UsbDevice> deviceList = manager.getDeviceList();
    Iterator<UsbDevice> it = deviceList.values().iterator();

    PendingIntent mPermissionIntent = PendingIntent.getBroadcast(ctx, 0, new Intent(ACTION_USB_PERMISSION), 0);
    IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
    ctx.registerReceiver(mUsbReceiver, filter);

    if (it.hasNext()) {
        device = it.next();//  ww w.  j  a v  a  2s.  c  o m
        manager.requestPermission(device, mPermissionIntent);
        conectar();
    } else {
        Log.i(Constantes.TAG_CONECTOR, "No se han encontrado dispositivos");
        throw new TransmisionErrorException("No se han encontrado dispositivos");
    }
}

From source file:es.udc.fic.android.robot_control.robot.ConectorPlaca.java

public void conectarManual(Context ctx) throws TransmisionErrorException {
    Log.i(C.ROBOT_TAG, "Conectando manualmente. modo - Host");
    /* Get the USB manager from the requesting context */
    this.manager = (UsbManager) ctx.getSystemService(Context.USB_SERVICE);

    HashMap<String, UsbDevice> deviceList = manager.getDeviceList();
    Iterator<UsbDevice> it = deviceList.values().iterator();

    PendingIntent mPermissionIntent = PendingIntent.getBroadcast(ctx, 0, new Intent(ACTION_USB_PERMISSION), 0);
    IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
    ctx.registerReceiver(mUsbReceiver, filter);

    if (it.hasNext()) {
        device = it.next();//from ww  w.j  a  va2s .  c o m
        manager.requestPermission(device, mPermissionIntent);
        //conectar();
    } else {
        Log.i(C.ROBOT_TAG, "No se han encontrado dispositivos");
        throw new TransmisionErrorException("No se han encontrado dispositivos");
    }
}

From source file:edu.utah.bmi.ibiomes.lite.ExperimentIndex.java

private void storeIndexToFile(HashMap<String, IndexEntry> index) throws IOException {
    BufferedWriter bw = new BufferedWriter(new FileWriter(this.file, false));
    Collection<IndexEntry> entries = index.values();
    for (IndexEntry entry : entries) {
        bw.append(entry.toString() + "\n");
    }/*from   ww w  .j  a v a  2s  .c  o  m*/
    bw.close();
}

From source file:com.bah.applefox.main.plugins.pageranking.utilities.PRtoFile.java

private static HashMap<String, Double> createMap(String[] args)
        throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
    HashMap<String, Double> ret = new HashMap<String, Double>();
    String readTable = args[13] + "Old";

    Scanner scan = AccumuloUtils.connectRead(readTable);

    Iterator<Entry<Key, Value>> itr = scan.iterator();

    while (itr.hasNext()) {
        Entry<Key, Value> temp = itr.next();
        try {/*from   w  w w.  j ava  2 s  . co m*/
            Double val = (Double) IngestUtils.deserialize(temp.getValue().get());
            ret.put(temp.getKey().getRow().toString(), val);
            System.out.println("Adding to Map: " + temp.getKey().getRow().toString() + " with rank: " + val);
        } catch (IOException e) {
            if (e.getMessage() != null) {
                log.error(e.getMessage());
            } else {
                log.error(e.getStackTrace());
            }
        } catch (ClassNotFoundException e) {
            if (e.getMessage() != null) {
                log.error(e.getMessage());
            } else {
                log.error(e.getStackTrace());
            }
        }
    }

    Double max = 0.0;

    Collection<Double> values = ret.values();

    ArrayList<Double> tempValues = new ArrayList<Double>();
    tempValues.addAll(values);
    Collections.sort(tempValues);
    Collections.reverse(tempValues);

    max = tempValues.get(0);

    ret.put("[[MAX_PR]]", max);

    return ret;
}

From source file:com.alibaba.jstorm.ui.controller.NettyController.java

private List<UINettyMetric> getNettyData(MetricInfo nettyMetrics, String host, int window) {
    HashMap<String, UINettyMetric> nettyData = new HashMap<>();
    if (nettyMetrics == null || nettyMetrics.get_metrics_size() == 0) {
        return new ArrayList<>(nettyData.values());
    }/*from  w ww .  j a  v  a2s .  c  o  m*/
    for (Map.Entry<String, Map<Integer, MetricSnapshot>> metric : nettyMetrics.get_metrics().entrySet()) {
        String name = metric.getKey();
        String[] split_name = name.split("@");

        String metricName = UIMetricUtils.extractMetricName(split_name);
        String connection = null;
        if (metricName != null) {
            connection = metricName.substring(metricName.indexOf(".") + 1);
            metricName = metricName.substring(0, metricName.indexOf("."));
        }
        MetricSnapshot snapshot = metric.getValue().get(window);

        UINettyMetric netty;
        if (nettyData.containsKey(connection)) {
            netty = nettyData.get(connection);
        } else {
            netty = new UINettyMetric(host, connection);
            nettyData.put(connection, netty);
        }
        netty.setMetricValue(snapshot, metricName);
    }
    return new ArrayList<>(nettyData.values());
}

From source file:MSUmpire.SearchResultWriter.PepXMLWriter.java

public void SetPepList(HashMap<String, PepIonID> Import) {
    this.PepList = new ArrayList<>();
    for (PepIonID pepIonID : Import.values()) {
        PepList.add(pepIonID);/*from w w  w.j a v a2  s . co m*/
    }
}

From source file:com.fulcrum.mule.cluster.boot.ClusterExtension.java

@Override
public synchronized void onUndeploymentStart(String artifactName) {
    if (!initialized) {
        throw new MuleRuntimeException(new IllegalStateException("ClusterManager not initialized"));
    }/*  w w  w . j  a va 2  s .c o  m*/

    HashMap<String, ClusterContext> clusterContexts = cluster.getClusterContexts();

    synchronized (clusterContexts) {
        for (ClusterContext clusterContext : clusterContexts.values()) {
            clusterContext.close();
        }
    }
}

From source file:eu.socialSensor.diverseImages2014.datasetCreation.MakeRelevanceDataset.java

public String generateArffHeader() throws Exception {
    // generate the header of the arff file
    StringBuilder sb = new StringBuilder();
    sb.append("% Created by MakeARFFs.java\n");
    sb.append("@RELATION matches\n\n");
    sb.append("@ATTRIBUTE imageId\tNUMERIC\n");
    // sb.append("@ATTRIBUTE locationId\tNUMERIC\n");
    sb.append("@ATTRIBUTE locationId\t{");
    for (int i = 0; i < dataStore.getLocationList().size() - 1; i++) {
        sb.append(dataStore.getLocationList().get(i).getQueryId() + ",");
    }/*  w w w .  j  ava  2 s.  c  o m*/
    // for (int i = locationIdsStart; i <= locationIdsEnd; i++) { // use all location ids in header
    // sb.append(i + ",");
    // }
    sb.append(dataStore.getLocationList().get(dataStore.getLocationList().size() - 1).getQueryId() + "}");
    sb.append("\n");
    sb.append("@ATTRIBUTE flickrRank\tNUMERIC\n");

    // sb.append("@ATTRIBUTE latitude\tNUMERIC\n");
    // sb.append("@ATTRIBUTE longitude\tNUMERIC\n");

    // used to get the length of each feature type
    ArrayList<HashMap<Long, double[]>> features = dataStore.getLocationList().get(0).getFeatures();
    int counter = 0;
    for (String featureType : featureTypes) {
        // get the length of this feature type
        HashMap<Long, double[]> feature = features.get(counter);
        int featureLength = feature.values().iterator().next().length;
        totalLength += featureLength;
        for (int i = 0; i < featureLength; i++) {
            sb.append("@ATTRIBUTE " + featureType + "_" + i + "\tNUMERIC\n");
        }
        counter++;
    }

    sb.append("@ATTRIBUTE relevance \t{0,1}\n\n");
    sb.append("@DATA\n");
    return sb.toString();
}