Example usage for java.util TreeSet ceiling

List of usage examples for java.util TreeSet ceiling

Introduction

In this page you can find the example usage for java.util TreeSet ceiling.

Prototype

public E ceiling(E e) 

Source Link

Usage

From source file:Main.java

public static void main(String[] args) {

    TreeSet<Integer> treeadd = new TreeSet<Integer>();

    treeadd.add(12);/*w ww  .j a va2 s  .c  om*/
    treeadd.add(11);
    treeadd.add(16);
    treeadd.add(15);

    // getting ceiling value for 13
    System.out.println("Ceiling value for 13: " + treeadd.ceiling(13));
}

From source file:juicebox.data.HiCFileTools.java

private static int closestValue(int val, TreeSet<Integer> valSet) {
    int floorVal = valSet.floor(val);
    int ceilVal = valSet.ceiling(val);

    if (Math.abs(ceilVal - val) < Math.abs(val - floorVal))
        return ceilVal;

    return floorVal;
}

From source file:org.apache.cloudstack.network.contrail.model.VirtualMachineModel.java

public VMInterfaceModel getVMInterface(String uuid) {
    TreeSet<ModelObject> tree = successors();
    VMInterfaceModel vmiKey = new VMInterfaceModel(uuid);
    VMInterfaceModel current = (VMInterfaceModel) tree.ceiling(vmiKey);
    if (current != null && current.getUuid().equals(uuid)) {
        return current;
    }//from w ww  .  j a  va 2  s.  c om
    return null;
}

From source file:org.apache.hyracks.storage.am.btree.OrderedIndexTestUtils.java

@SuppressWarnings("unchecked")
// Create a new TreeSet containing the elements satisfying the prefix search.
// Implementing prefix search by changing compareTo() in CheckTuple does not
// work./*from ww w. j av a  2 s  . c  om*/
public static SortedSet<CheckTuple> getPrefixExpectedSubset(TreeSet<CheckTuple> checkTuples, CheckTuple lowKey,
        CheckTuple highKey) {
    lowKey.setIsHighKey(false);
    highKey.setIsHighKey(true);
    CheckTuple low = checkTuples.ceiling(lowKey);
    CheckTuple high = checkTuples.floor(highKey);
    if (low == null || high == null) {
        // Must be empty.
        return new TreeSet<>();
    }
    if (high.compareTo(low) < 0) {
        // Must be empty.
        return new TreeSet<>();
    }
    return checkTuples.subSet(low, true, high, true);
}