Example usage for java.util Map size

List of usage examples for java.util Map size

Introduction

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

Prototype

int size();

Source Link

Document

Returns the number of key-value mappings in this map.

Usage

From source file:Main.java

public static final void main(String[] args) {
    Map<String, String> map = new HashMap<>();
    map.put("one", "a");
    System.out.println("Size = " + map.size());
    map.put(null, "b");
    System.out.println("Size = " + map.size());
    System.out.println("map.get(null) = " + map.get(null));
}

From source file:Freq.java

public static void main(String args[]) {
    Map m = new TreeMap();

    m.put("a Key", "a Value");
    m.put("Java2s", "www.java2s.com");

    System.out.println(m.size() + " keys detected:");
    System.out.println(m);//  www.  ja v  a 2  s . co m
}

From source file:MainClass.java

public static void main(String[] a) {

    Map map = new HashMap();
    map.put("key1", "value1");
    map.put("key2", "value2");
    map.put("key3", "value3");

    System.out.println(map.size());
}

From source file:de.unisb.cs.st.javalanche.mutation.util.FilePerformanceTest.java

public static void main(String[] args) throws IOException {
    int limit = 1000;
    int total = 0;
    StopWatch stp = new StopWatch();
    stp.start();//w w w  .  jav a2s  .  co  m
    File dir = new File("mutation-files/tmp");
    dir.mkdir();
    for (int i = 0; i < limit; i++) {
        Map<String, Set<Integer>> map = getMap();
        File tempFile = new File(dir, "test-" + i + ".ser");
        if (!tempFile.exists()) {
            SerializeIo.serializeToFile(map, tempFile);
        } else {
            Map<String, Set<Integer>> deserialize = SerializeIo.get(tempFile);
            total += deserialize.size();
        }
    }
    System.out.println(
            "Handling " + limit + " files took " + DurationFormatUtils.formatDurationHMS(stp.getTime()));
}

From source file:com.khartec.waltz.jobs.DatabaseHarness.java

public static void main(String[] args) throws ParseException {

    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);

    DatabaseInformationDao databaseDao = ctx.getBean(DatabaseInformationDao.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);

    List<DatabaseInformation> dbs = databaseDao.findByApplicationId(801L);
    System.out.println(dbs.size());

    SelectConditionStep<Record1<Long>> idSelector = dsl.select(APPLICATION.ID).from(APPLICATION)
            .where(APPLICATION.ID.in(801L, 802L, 803L));

    Map<Long, List<DatabaseInformation>> moreDbs = databaseDao.findByAppSelector(idSelector);
    System.out.println(moreDbs.size());
    System.out.println(moreDbs.values().size());

}

From source file:MainClass.java

public static void main(String args[]) {

    String[] names = { "A", "J", "B", "E", "P" };
    String[] ids = { "1", "2", "9", "8", "7" };

    Map<String, String> IDMap = new HashMap<String, String>();

    for (int i = 0; i < names.length; i++)
        IDMap.put(ids[i], names[i]);/* w ww .j  a  v  a2 s  . c  o m*/

    System.out.println(IDMap.size() + " Students entered: ");
    System.out.println(IDMap);

}

From source file:Main.java

public static void main(String[] a) {
    Map<String, String> map = new HashMap<String, String>();
    map.put("key1", "value1");
    map.put("key2", "value2");
    map.put("key3", "value3");

    System.out.println(map.size());
}

From source file:io.jenkins.backend.jiraldapsyncer.LdapClient.java

public static void main(String[] args) {
    ServiceLocator locator = new ServiceLocator();
    LdapClient ldapClient = (LdapClient) locator.lookupService(LdapClient.ROLE);
    Map<String, RemoteUser> ldapUsers = ldapClient.getAllUsers();
    LOG.info("LDAP directory contains " + ldapUsers.size() + " users");
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Map<String, Integer> map = new HashMap<String, Integer>();
    map = new TreeMap();

    map.put("a", new Integer(1));
    map.put("b", new Integer(2));
    map.put("c", new Integer(3));

    int size = map.size(); // 2

    Object oldValue = map.put("a", new Integer(9)); // 1

    oldValue = map.remove("c"); // 3

    Iterator it = map.keySet().iterator();
    while (it.hasNext()) {
        Object key = it.next();//from w ww  .  java  2  s. co m
    }

    it = map.values().iterator();
    while (it.hasNext()) {
        Object value = it.next();
    }
}

From source file:com.jgoetsch.eventtrader.EventTraderSpringLauncher.java

public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: " + EventTraderSpringLauncher.class.getSimpleName() + " <files>...");
        System.out.println("       files - List of paths to spring bean definition xml files.");
        System.out.println("               Each object defined that implements Runnable will be executed");
        System.out.println("               in its own thread.");
    } else {//from  w  w w .  j  a  v a 2 s .  c  o m
        AbstractApplicationContext context = new ClassPathXmlApplicationContext(args);

        // auto register growl notifications after all GrowlNotification objects have been instantiated
        // if it is found on the classpath
        try {
            Class.forName("com.jgoetsch.eventtrader.processor.GrowlNotification").getMethod("autoRegister")
                    .invoke(null);
        } catch (Exception e) {
            log.warn("Growl not found, cannot autoRegister notifications: {}", e.getMessage());
        }

        Map<String, Runnable> runnables = BeanFactoryUtils.beansOfTypeIncludingAncestors(context,
                Runnable.class);
        List<Thread> threads = new ArrayList<Thread>(runnables.size());
        for (final Map.Entry<String, Runnable> runner : runnables.entrySet()) {
            final Thread th = new Thread(runner.getValue(), runner.getKey());
            threads.add(th);
            th.start();
        }

        // close spring context on JVM shutdown
        // this causes all @PreDestroy methods in the runnables to be called to allow for
        // them to shutdown gracefully
        context.registerShutdownHook();

        // wait for launched threads to finish before cleaning up beans
        for (Thread th : threads) {
            try {
                th.join();
            } catch (InterruptedException e) {
            }
        }
    }
}