本文整理了Java中java.util.TreeMap.lowerKey()
方法的一些代码示例,展示了TreeMap.lowerKey()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeMap.lowerKey()
方法的具体详情如下:
包路径:java.util.TreeMap
类名称:TreeMap
方法名:lowerKey
暂无
代码示例来源:origin: PenguinSquad/Harvest-Festival
@Nullable
private BuildingLocation getTargetFromMapBasedOnTime(TreeMap<Long, BuildingLocation> hourlyMap, long time) {
long Ttime = hourlyMap.lowerKey(time) == null ? time : hourlyMap.lowerKey(time);
if (hourlyMap.containsKey(Ttime)) {
BuildingLocation location = hourlyMap.get(Ttime);
if (location != null) return location;
}
return null;
}
}
代码示例来源:origin: worstcase/gumshoe
public Long getPositionBefore(Long key) {
if(timeByPosition.isEmpty()) { return null; }
if(key==null) { return timeByPosition.lastKey(); }
return timeByPosition.lowerKey(key);
}
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) throws Exception {
int arrayOne[] = {1, 50, 100, 50, 100, 22, 23, 26};
int arrayTwo[] = {1, 45, 22, 23, 52, 90, 100, 99};
TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
for (int i = 0; i < arrayTwo.length; i++)
if (!map.containsKey(arrayTwo[i])) // if you want it to choose the first
map.put(arrayTwo[i], i);
int arrayThree[] = new int[arrayOne.length];
for (int i = 0; i < arrayThree.length; i++) {
int v = arrayOne[i];
Integer h = map.higherKey(v - 1);
Integer l = map.lowerKey(v);
arrayThree[i] = map.get(l !=null && (h ==null || v - l < h - v) ? l : h);
}
System.out.println(Arrays.toString(arrayThree));
}
代码示例来源:origin: PenguinSquad/Harvest-Festival
private BuildingLocation getTarget(World world, EntityLiving entity, Season season, Weekday weekday, long time) {
if (default_ == null) return null;
//Holidays take priority over anything else
Festival festival = HFApi.calendar.getFestival(world, new BlockPos(entity));
if (!festival.equals(Festival.NONE) && holidayMap.containsKey(festival)) {
BuildingLocation location = getTargetFromMapBasedOnTime(holidayMap.get(festival), time);
if (location != null) return location;
}
//Now we stick to normal schedules
Season seasonal = seasonalMap.lowerKey(season) == null ? season: seasonalMap.lowerKey(season);
if (seasonalMap.containsKey(seasonal)) {
TreeMap<Weekday, TreeMap<Long, BuildingLocation>> weekdayMap = seasonalMap.get(seasonal);
Weekday weekly = weekdayMap.lowerKey(weekday) == null ? weekday : weekdayMap.lowerKey(weekday);
if (weekdayMap.containsKey(weekly)) {
BuildingLocation location = getTargetFromMapBasedOnTime(weekdayMap.get(weekly), time);
if (location != null) return location;
}
}
return default_;
}
代码示例来源:origin: fenix-framework/fenix-framework
private void rotateLeftToRight(Map.Entry<Comparable, InnerNode> leftEntry, Map.Entry<Comparable, InnerNode> rightEntry) {
InnerNode leftSubNode = leftEntry.getValue();
InnerNode rightSubNode = rightEntry.getValue();
TreeMap<Comparable, AbstractNode> newLeftSubNodeSubNodes = leftSubNode.duplicateMap();
TreeMap<Comparable, AbstractNode> newRightSubNodeSubNodes = rightSubNode.duplicateMap();
Comparable leftHighestKey = newLeftSubNodeSubNodes.lowerKey(BPlusTree.LAST_KEY);
AbstractNode leftHighestValue = newLeftSubNodeSubNodes.get(BPlusTree.LAST_KEY);
// move the highest value from the left to the right. Use the split-key as the index.
newRightSubNodeSubNodes.put(leftEntry.getKey(), leftHighestValue);
leftHighestValue.setParent(rightSubNode);
// shift a new child to the last entry on the left
leftHighestValue = newLeftSubNodeSubNodes.remove(leftHighestKey);
newLeftSubNodeSubNodes.put(BPlusTree.LAST_KEY, leftHighestValue);
leftSubNode.setSubNodes(newLeftSubNodeSubNodes);
rightSubNode.setSubNodes(newRightSubNodeSubNodes);
// update the split-key to be the key we just removed from the left
TreeMap<Comparable, AbstractNode> newMap = duplicateMap();
newMap.remove(leftEntry.getKey());
newMap.put(leftHighestKey, leftSubNode);
setSubNodes(newMap);
}
代码示例来源:origin: org.ballerinalang/siddhi-core
switch (operator) {
case LESS_THAN:
return ((TreeMap<Object, StreamEvent>) primaryKeyData).lowerKey(value) != null;
case GREATER_THAN:
return ((TreeMap<Object, StreamEvent>) primaryKeyData).higherKey(value) != null;
return currentIndexedData.lowerKey(value) != null;
case GREATER_THAN:
return currentIndexedData.higherKey(value) != null;
代码示例来源:origin: CogComp/talen
model.addAttribute("previd", tas.lowerKey(taid));
}else{
model.addAttribute("previd", -1);
代码示例来源:origin: MSGFPlus/msgfplus
public List<Pair<Integer, Float>> getXIC(int scanNum, float mz, Tolerance tol) {
ArrayList<Pair<Integer, Float>> xic = new ArrayList<Pair<Integer, Float>>();
Peak p;
// Move down
Integer curScanNum = scanNum;
while (curScanNum != null && scanNum > 0) {
curScanNum = ms1SpecMap.lowerKey(curScanNum);
if ((p = getMS1Peak(curScanNum, mz, tol)) != null)
xic.add(new Pair<Integer, Float>(curScanNum, p.getIntensity()));
else
break;
}
// Move up
curScanNum = scanNum;
while (curScanNum != null && curScanNum < 100000) {
curScanNum = ms1SpecMap.higherKey(curScanNum);
if ((p = getMS1Peak(curScanNum, mz, tol)) != null)
xic.add(new Pair<Integer, Float>(curScanNum, p.getIntensity()));
else
break;
}
Collections.sort(xic, new Pair.PairComparator<Integer, Float>());
return xic;
}
代码示例来源:origin: MSGFPlus/msgfplus
public boolean checkMS1Peaks(int scanNum, float mz, int charge, Tolerance tol, int windowSize) {
int precursorScanNum = ms1SpecMap.floorKey(scanNum);
if (checkMS1Peaks(precursorScanNum, mz, charge, tol))
return true;
// Move down
Integer curScanNum = precursorScanNum;
for (int i = 0; i < windowSize; i++) {
curScanNum = ms1SpecMap.lowerKey(curScanNum);
if (curScanNum == null)
break;
else {
if (checkMS1Peaks(curScanNum, mz, charge, tol))
return true;
}
}
// Move up
curScanNum = precursorScanNum;
for (int i = 0; i < windowSize; i++) {
curScanNum = ms1SpecMap.higherKey(curScanNum);
if (curScanNum == null)
break;
else {
if (checkMS1Peaks(curScanNum, mz, charge, tol))
return true;
}
}
return false;
}
代码示例来源:origin: espertechinc/esper
assertEquals(treemap.floorKey(5), actual.floorKey(5));
assertEquals(treemap.ceilingKey(5), actual.ceilingKey(5));
assertEquals(treemap.lowerKey(5), actual.lowerKey(5));
assertEquals(treemap.higherKey(5), actual.higherKey(5));
代码示例来源:origin: espertechinc/esper
(map, key) -> map.lowerKey(key),
(map, key) -> null,
(map, key) -> null
代码示例来源:origin: espertechinc/esper
assertEquals(firstEvent(treemap.lowerEntry(i)), event.get("le"));
EPAssertionUtil.assertEqualsExactOrder(allEvents(treemap.lowerEntry(i)), (SupportBean[]) event.get("les"));
assertEquals(treemap.lowerKey(i), event.get("lk"));
内容来源于网络,如有侵权,请联系作者删除!