Example usage for java.util NavigableMap put

List of usage examples for java.util NavigableMap put

Introduction

In this page you can find the example usage for java.util NavigableMap put.

Prototype

V put(K key, V value);

Source Link

Document

Associates the specified value with the specified key in this map (optional operation).

Usage

From source file:Main.java

public static void main(String[] args) {
    NavigableMap<String, Integer> navigableMap = new TreeMap<String, Integer>();
    String[] letters = { "a", "b", "c" };
    int[] ints = { 3, 2, 1 };
    for (int i = 0; i < letters.length; i++) {
        navigableMap.put(letters[i], ints[i]);
    }//  w ww  . jav  a  2 s. co m
    System.out.println("Map = " + navigableMap);
    System.out.println("Last entry = " + navigableMap.lastEntry());
}

From source file:Main.java

public static void main(String[] args) {
    NavigableMap<String, Integer> navigableMap = new TreeMap<String, Integer>();
    String[] letters = { "a", "b", "c" };
    int[] ints = { 3, 2, 1 };
    for (int i = 0; i < letters.length; i++) {
        navigableMap.put(letters[i], ints[i]);
    }// www . j av a  2  s .  co  m
    System.out.println("Map = " + navigableMap);
    System.out.println("Entry < a is " + navigableMap.lowerEntry("a"));
}

From source file:Main.java

public static void main(String[] args) {
    NavigableMap<String, Integer> navigableMap = new TreeMap<String, Integer>();
    String[] letters = { "a", "b", "c" };
    int[] ints = { 3, 2, 1 };
    for (int i = 0; i < letters.length; i++) {
        navigableMap.put(letters[i], ints[i]);
    }/*from  w  w  w  .  jav a2 s.c o  m*/
    System.out.println("Map = " + navigableMap);
    System.out.println("Poll first entry: " + navigableMap.pollFirstEntry());
}

From source file:Main.java

public static void main(String[] args) {
    NavigableMap<String, Integer> navigableMap = new TreeMap<String, Integer>();
    String[] letters = { "a", "b", "c" };
    int[] ints = { 3, 2, 1 };
    for (int i = 0; i < letters.length; i++) {
        navigableMap.put(letters[i], ints[i]);
    }/*  ww  w . j a  v a 2s .c o  m*/
    System.out.println("Map = " + navigableMap);
    System.out.println("Entry > c is " + navigableMap.higherEntry("c"));
}

From source file:Main.java

public static void main(String[] args) {
    NavigableMap<String, Integer> navigableMap = new TreeMap<String, Integer>();
    String[] letters = { "a", "b", "c" };
    int[] ints = { 3, 2, 1 };
    for (int i = 0; i < letters.length; i++) {
        navigableMap.put(letters[i], ints[i]);
    }//from w  ww. j a  v  a 2 s  .  c  om
    System.out.println("Map = " + navigableMap);
    System.out.println("First entry = " + navigableMap.firstEntry());
}

From source file:com.palantir.atlasdb.keyvalue.impl.partition.FailableKeyValueServices.java

public static DynamicPartitionMap createInMemoryMap(Collection<? extends KeyValueService> services,
        QuorumParameters parameters) {//from  w  w w  .j a  va  2s .  com
    ArrayList<Byte> keyList = new ArrayList<>();
    NavigableMap<byte[], KeyValueEndpoint> ring = Maps.newTreeMap(UnsignedBytes.lexicographicalComparator());
    keyList.add((byte) 0);
    for (KeyValueService kvs : services) {
        KeyValueEndpoint endpoint = InMemoryKeyValueEndpoint.create(kvs,
                InMemoryPartitionMapService.createEmpty());
        byte[] key = ArrayUtils.toPrimitive(keyList.toArray(new Byte[keyList.size()]));
        ring.put(key, endpoint);
        keyList.add((byte) 0);
    }
    DynamicPartitionMap partitionMap = DynamicPartitionMapImpl.create(parameters, ring,
            PTExecutors.newCachedThreadPool());
    for (KeyValueEndpoint endpoint : ring.values()) {
        endpoint.partitionMapService().updateMap(partitionMap);
    }
    return partitionMap;
}

From source file:org.apache.taverna.databundle.DataBundles.java

public static NavigableMap<String, Path> getPorts(Path path) throws IOException {
    NavigableMap<String, Path> ports = new TreeMap<>();
    try (DirectoryStream<Path> ds = newDirectoryStream(path)) {
        for (Path p : ds)
            ports.put(filenameWithoutExtension(p), p);
    }// w w  w  .  jav a2s.c  o  m
    return ports;
}

From source file:com.alibaba.wasp.meta.FMetaScanner.java

/**
 * Lists all of the table EntityGroups currently in META.
 *
 * @param conf// w  w  w .ja  v a2  s  .c  o m
 * @param offlined
 *          True if we are to include offlined EntityGroups, false and we'll
 *          leave out offlined EntityGroups from returned list.
 * @return Map of all user-space EntityGroups to servers
 * @throws java.io.IOException
 */
public static NavigableMap<EntityGroupInfo, ServerName> allTableEntityGroups(Configuration conf,
        final byte[] tablename, final boolean offlined) throws IOException {
    FTable table = getService(conf).getTable(Bytes.toString(tablename));
    final byte[] parentTableName = Bytes.toBytes(getRootTable(table));
    final NavigableMap<EntityGroupInfo, ServerName> entityGroups = new TreeMap<EntityGroupInfo, ServerName>();
    MetaScannerVisitor visitor = new TableMetaScannerVisitor(conf, parentTableName) {
        @Override
        public boolean processRowInternal(Result rowResult) throws IOException {
            EntityGroupInfo entityGroupInfo = getEntityGroupInfo(rowResult);
            ServerName sn = ServerName.getServerName(rowResult);

            if (!(entityGroupInfo.isOffline() || entityGroupInfo.isSplit())) {
                entityGroups.put(entityGroupInfo, sn);
            }
            return true;
        }
    };
    metaScan(conf, visitor, parentTableName);
    return entityGroups;
}

From source file:net.projectmonkey.spring.acl.hbase.repository.AclRecordTest.java

private NavigableMap<byte[], byte[]> recordMap(final Class<?> idType, final boolean principal) {
    String ownerString = SOME_PRINCIPAL + ":" + principal;

    NavigableMap<byte[], byte[]> recordMap = new TreeMap<byte[], byte[]>(Bytes.BYTES_COMPARATOR);
    recordMap.put(HBaseACLRepository.ACL_ID_TYPE_QUALIFIER, idType.getName().getBytes());
    recordMap.put(HBaseACLRepository.ACL_TYPE_QUALIFIER, TYPE.getBytes());
    recordMap.put(HBaseACLRepository.ACL_OWNER_QUALIFIER, ownerString.getBytes());
    return recordMap;
}

From source file:dhz.skz.citaci.weblogger.zerospan.WebloggerZeroSpanCitacBean.java

private NavigableMap<Date, Uredjaj> getUredjajiMapa(ProgramMjerenja pm) {
    NavigableMap<Date, Uredjaj> mapa = new TreeMap<>();
    for (ProgramUredjajLink pul : pm.getProgramUredjajLinkCollection()) {
        mapa.put(pul.getVrijemePostavljanja(), pul.getUredjajId());
    }//  w w  w .  j  a v  a  2s . c  om
    return mapa;
}