Example usage for com.google.common.collect ImmutableSortedMap headMap

List of usage examples for com.google.common.collect ImmutableSortedMap headMap

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableSortedMap headMap.

Prototype

ImmutableSortedMap<K, V> headMap(K toKey, boolean inclusive) 

Source Link

Usage

From source file:edu.mit.streamjit.util.bytecode.methodhandles.Combinators.java

private static MethodHandle lookupswitch0(ImmutableSortedMap<Integer, MethodHandle> cases,
        MethodHandle defaultCase) {
    if (cases.isEmpty())
        return defaultCase;
    if (cases.size() == 1) {
        Map.Entry<Integer, MethodHandle> next = cases.entrySet().iterator().next();
        return MethodHandles.guardWithTest(eq(next.getKey()),
                MethodHandles.dropArguments(next.getValue(), 0, int.class), //discard the case index
                defaultCase);//from  w  w  w . j av a  2 s.c o m
    }
    int median = median(cases.keySet().asList());
    return MethodHandles.guardWithTest(le(median), lookupswitch0(cases.headMap(median, true), defaultCase),
            lookupswitch0(cases.tailMap(median, false), defaultCase));
}