本文整理汇总了Java中java.util.TreeMap.ceilingEntry方法的典型用法代码示例。如果您正苦于以下问题:Java TreeMap.ceilingEntry方法的具体用法?Java TreeMap.ceilingEntry怎么用?Java TreeMap.ceilingEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.TreeMap
的用法示例。
在下文中一共展示了TreeMap.ceilingEntry方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBuffer
import java.util.TreeMap; //导入方法依赖的package包/类
@Override
public synchronized ByteBuffer getBuffer(boolean direct, int length) {
TreeMap<Key, ByteBuffer> tree = getBufferTree(direct);
Map.Entry<Key, ByteBuffer> entry =
tree.ceilingEntry(new Key(length, 0));
if (entry == null) {
return direct ? ByteBuffer.allocateDirect(length) :
ByteBuffer.allocate(length);
}
tree.remove(entry.getKey());
return entry.getValue();
}
示例2: indexIn
import java.util.TreeMap; //导入方法依赖的package包/类
private static Integer indexIn(TreeMap<Time, Integer> lookup, Time time, int noEntryFound) {
Entry<Time, Integer> possibleEntry = lookup.ceilingEntry(time);
if (possibleEntry == null) {
return noEntryFound;
}
return possibleEntry.getValue();
}
示例3: testCeilingEntry
import java.util.TreeMap; //导入方法依赖的package包/类
/**
* ceilingEntry returns next entry.
*/
public void testCeilingEntry() {
TreeMap map = map5();
Map.Entry e1 = map.ceilingEntry(three);
assertEquals(three, e1.getKey());
Map.Entry e2 = map.ceilingEntry(zero);
assertEquals(one, e2.getKey());
Map.Entry e3 = map.ceilingEntry(five);
assertEquals(five, e3.getKey());
Map.Entry e4 = map.ceilingEntry(six);
assertNull(e4);
}