Example usage for java.util HashMap size

List of usage examples for java.util HashMap size

Introduction

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

Prototype

int size

To view the source code for java.util HashMap size.

Click Source Link

Document

The number of key-value mappings contained in this map.

Usage

From source file:Evaluator.StatCalculator.java

public double kendalTauCalc(HashMap<String, Double> kderunQidMap, HashMap<String, Double> aprunQidMap) {
    double xArray[], yArray[];
    int count = 0;

    xArray = new double[kderunQidMap.size()];
    yArray = new double[kderunQidMap.size()];

    Iterator it = kderunQidMap.keySet().iterator();
    while (it.hasNext()) {
        String run = (String) it.next();
        xArray[count] = kderunQidMap.get(run);
        yArray[count++] = aprunQidMap.get(run);
    }/*from  w  ww. j a va 2s  .c  o m*/

    KendallsCorrelation kc = new KendallsCorrelation();
    return kc.correlation(xArray, yArray);

}

From source file:JarUtil.java

/**
 * Reads the package-names from the given jar-file.
 * //from w w  w  .  j  av a 2s.c  om
 * @param jarFile
 *            the jar file
 * @return an array with all found package-names
 * @throws IOException
 *             when the jar-file could not be read
 */
public static String[] getPackageNames(File jarFile) throws IOException {
    HashMap<String, String> packageNames = new HashMap<String, String>();
    JarFile input = new JarFile(jarFile, false, ZipFile.OPEN_READ);
    Enumeration<JarEntry> enumeration = input.entries();
    for (; enumeration.hasMoreElements();) {
        JarEntry entry = enumeration.nextElement();
        String name = entry.getName();
        if (name.endsWith(".class")) {
            int endPos = name.lastIndexOf('/');
            boolean isWindows = false;
            if (endPos == -1) {
                endPos = name.lastIndexOf('\\');
                isWindows = true;
            }
            name = name.substring(0, endPos);
            name = name.replace('/', '.');
            if (isWindows) {
                name = name.replace('\\', '.');
            }
            packageNames.put(name, name);
        }
    }
    return (String[]) packageNames.values().toArray(new String[packageNames.size()]);
}

From source file:cc.kune.core.server.manager.I18nManagerDefaultTest.java

/**
 * Test get lexicon./* www. j a  va2 s .c  o m*/
 */
@Test
public void testGetLexicon() {
    final HashMap<String, String> map = translationManager.getLexicon("af");
    assertTrue(map.size() > 0);
}

From source file:com.ibm.bi.dml.api.DMLScript.java

/**
 * //w ww. j ava2 s .  c  o  m
 * @param fnameScript
 * @param fnameOptConfig
 * @param argVals
 */
private static void printInvocationInfo(String fnameScript, String fnameOptConfig,
        HashMap<String, String> argVals) {
    LOG.debug("****** args to DML Script ******\n" + "UUID: " + getUUID() + "\n" + "SCRIPT PATH: " + fnameScript
            + "\n" + "RUNTIME: " + rtplatform + "\n" + "BUILTIN CONFIG: "
            + DMLConfig.DEFAULT_SYSTEMML_CONFIG_FILEPATH + "\n" + "OPTIONAL CONFIG: " + fnameOptConfig + "\n");

    if (!argVals.isEmpty()) {
        LOG.debug("Script arguments are: \n");
        for (int i = 1; i <= argVals.size(); i++)
            LOG.debug("Script argument $" + i + " = " + argVals.get("$" + i));
    }
}

From source file:com.ba.reports.DayReport.BADayReportAction.java

public ActionForward baGet(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    JSONObject json = new JSONObject();
    BADayReportDTO vo = new BADayReportDTO();
    try {//from ww  w . j  av a 2  s.  c  o m
        logger.info(" get method starts here");
        String roomId = request.getParameter("search");
        HashMap hashMpRoomItemDet = BADayReportFactory.getInstanceOfBADayReportFactory().getRoomDtls(roomId);
        json.put("exception", "");
        json.put("RoomDets", hashMpRoomItemDet);
        json.put("RoomExit", hashMpRoomItemDet.size());
        //
        //                 logger.warn("strCurrent PageNo ------------->"+objPageCount);
    } catch (Exception ex) {
        logger.error("The Exception is  :" + ex);
        ex.printStackTrace();
        json.put("exception", BAHandleAllException.exceptionHandler(ex));
    }
    response.getWriter().write(json.toString());
    return null;

}

From source file:heartware.com.heartware_master.ProfileFragment.java

private void createButtons(View view) {
    bRecommend = (Button) view.findViewById(R.id.bRecommend);
    bRecommend.setOnClickListener(new View.OnClickListener() {
        @Override/*from www.  j  a va  2  s .com*/
        public void onClick(View v) {
            new LongRunningGetIO().execute();
        }
    });
    bUserInfo = (Button) view.findViewById(R.id.bUserInfo);
    bUserInfo.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            HashMap<String, String> profileMap = dbAdapter.getProfileById("1");

            if (profileMap.size() != 0) {
                mProfileDialog.setProfileText(profileMap.get(DBAdapter.USERNAME),
                        profileMap.get(DBAdapter.DIFFICULTY), profileMap.get(DBAdapter.DISABILITY));
            }
            mProfileDialog.show(getActivity().getFragmentManager(), TAG);
        }
    });
}

From source file:com.wms.studio.cache.lock.SyncLockMapCache.java

@Override
public int size() {
    try {//from ww  w  .  java 2 s  .  com
        HashMap<K, V> attributes = memcachedClient.get(name);
        if (attributes != null) {
            return attributes.size();
        }
    } catch (Exception e) {
        log.fatal("?MemCache,.", e);
    }
    return 0;
}

From source file:magma.agent.worldmodel.localizer.impl.LocalizerTriangulation.java

/**
 * Calculates absolute position and directions by performing triangulation
 * for all pairs of flags taking the average of all calculations.
 * @param flags visible landmarks with known position to be used for
 *        localization// w ww  .j a v  a2  s.  co  m
 * @param neckYawAngle the horizontal neck angle (yaw) of the viewer
 * @param neckPitchAngle the vertical neck angle (pitch) of the viewer (not
 *        used at the moment)
 * @return an array of two Vector3Ds, the first containing the absolute x,y,z
 *         position of the viewer on the field, the second containing no real
 *         vector, but the horizontal, latitudal and rotational absolute body
 *         angles of the viewer
 */
public PositionOrientation localize(HashMap<String, ILocalizationFlag> flags, float neckYawAngle,
        float neckPitchAngle, Vector3D gyro) {
    if (flags.size() < 2) {
        // there are not 2 visible flags
        logger.log(Level.FINER, "Localization not possible, only have {0} flags", flags.size());
        return null;
    }

    // sort the flags according to their angle
    List<ILocalizationFlag> sortedFlags = new ArrayList<ILocalizationFlag>(flags.values());
    Collections.sort(sortedFlags);

    // get the two flags with maximum angle difference
    int triangulations = sortedFlags.size() * (sortedFlags.size() - 1) / 2;
    assert triangulations > 0 : "we need at least one triangulation";

    PositionOrientation[] results = new PositionOrientation[triangulations];
    int count = 0;
    for (int i = 0; i < sortedFlags.size() - 1; i++) {
        ILocalizationFlag flag1 = sortedFlags.get(i);
        for (int j = i + 1; j < sortedFlags.size(); j++) {
            ILocalizationFlag flag2 = sortedFlags.get(j);
            results[count] = triangulate(flag1, flag2, neckYawAngle);
            count++;
        }
    }

    PositionOrientation result = PositionOrientation.average(results);

    return result;
}

From source file:org.apache.tika.language.translate.CachedTranslator.java

/**
 * Get the number of different translations from the source language to the target language
 * this CachedTranslator has in its cache.
 *
 * @param sourceLanguage The source language of translation.
 * @param targetLanguage The target language of translation.
 * @return The number of translations between source and target.
 * @since Tika 1.6//from www  . ja  va  2 s . c o  m
 */
public int getNumTranslationsFor(String sourceLanguage, String targetLanguage) {
    HashMap<String, String> translationCache = cache.get(buildCacheKeyString(sourceLanguage, targetLanguage));
    if (translationCache == null)
        return 0;
    else
        return translationCache.size();
}

From source file:edu.illinois.cs.cogcomp.transliteration.WikiTransliteration.java

public static HashMap<Production, Double> FindWeightedAlignments(String word1, String word2,
        int maxSubstringLength1, int maxSubstringLength2, HashMap<Production, Double> probs,
        InternDictionary<String> internTable, NormalizationMode normalization) {
    HashMap<Production, Double> weights = new HashMap<>();
    FindWeightedAlignments(1, new ArrayList<Production>(), word1, word2, maxSubstringLength1,
            maxSubstringLength2, probs, weights, new HashMap<Production, Pair<Double, Double>>());

    //CheckDictionary(weights);

    HashMap<Production, Double> weights2 = new HashMap<>(weights.size());
    for (Production wkey : weights.keySet()) {
        weights2.put(wkey, weights.get(wkey) == 0 ? 0 : weights.get(wkey) / probs.get(wkey));
    }/*from   w ww . j av a2 s  .  co  m*/
    //weights2[wPair.Key] = weights[wPair.Key] == 0 ? 0 : Math.Pow(weights[wPair.Key], 1d / word1.Length);
    weights = weights2;

    return Normalize(word1, word2, weights, internTable, normalization);
}