Example usage for java.util EnumMap size

List of usage examples for java.util EnumMap size

Introduction

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

Prototype

int size

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

Click Source Link

Document

The number of mappings in this map.

Usage

From source file:Tutorial.java

public static void main(String[] args) {
    EnumMap<Tutorial, String> map = new EnumMap<Tutorial, String>(Tutorial.class);

    map.put(Tutorial.CSS, "1");
    map.put(Tutorial.Python, "2");
    map.put(Tutorial.PHP, "3");
    map.put(Tutorial.Java, "4");

    System.out.println(map);/*from w  w w . ja  v  a2s.  c o m*/

    System.out.println("Number of mappings:" + map.size());

    map.put(Tutorial.Javascript, "5");

    // print the new number of mappings of this map
    System.out.println("Number of mappings:" + map.size());
}

From source file:org.janusgraph.graphdb.database.log.TransactionLogHeader.java

private DataOutput serializeHeader(Serializer serializer, int capacity, LogTxStatus status,
        EnumMap<LogTxMeta, Object> meta) {
    Preconditions.checkArgument(status != null && meta != null, "Invalid status or meta");
    DataOutput out = serializer.getDataOutput(capacity);
    out.putLong(times.getTime(txTimestamp));
    VariableLong.writePositive(out, transactionId);
    out.writeObjectNotNull(status);//w ww . j a  v a 2  s  .  c  o  m

    Preconditions.checkArgument(meta.size() < Byte.MAX_VALUE, "Too much meta data: %s", meta.size());
    out.putByte(VariableLong.unsignedByte(meta.size()));
    for (Map.Entry<LogTxMeta, Object> metaentry : meta.entrySet()) {
        assert metaentry.getValue() != null;
        out.putByte(VariableLong.unsignedByte(metaentry.getKey().ordinal()));
        out.writeObjectNotNull(metaentry.getValue());
    }
    return out;
}

From source file:org.omnaest.utils.structure.map.MapUtilsTest.java

/**
 * @see TestEnum//from   w  w w. j  a va  2s  .com
 */
@SuppressWarnings("javadoc")
@Test
public void testInitializedEnumMap() {
    //
    final Class<TestEnum> enumType = TestEnum.class;
    final Factory<Set<String>> factory = new Factory<Set<String>>() {
        @Override
        public Set<String> newInstance() {
            return SetUtils.valueOf("a", "b");
        }
    };

    final EnumMap<TestEnum, Set<String>> enumMapWithFilledDefaultValues = MapUtils.initializedEnumMap(enumType,
            factory);
    assertNotNull(enumMapWithFilledDefaultValues);
    assertEquals(2, enumMapWithFilledDefaultValues.size());
    assertEquals(SetUtils.valueOf("a", "b"), enumMapWithFilledDefaultValues.get(TestEnum.key1));
    assertEquals(SetUtils.valueOf("a", "b"), enumMapWithFilledDefaultValues.get(TestEnum.key2));
}