本文整理了Java中java.util.TreeMap.floorKey()
方法的一些代码示例,展示了TreeMap.floorKey()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeMap.floorKey()
方法的具体详情如下:
包路径:java.util.TreeMap
类名称:TreeMap
方法名:floorKey
暂无
代码示例来源:origin: kevin-wayne/algs4
/**
* Returns the largest key in this symbol table less than or equal to {@code key}.
*
* @param key the key
* @return the largest key in this symbol table less than or equal to {@code key}
* @throws NoSuchElementException if there is no such key
* @throws IllegalArgumentException if {@code key} is {@code null}
*/
public Key floor(Key key) {
if (key == null) throw new IllegalArgumentException("argument to floor() is null");
Key k = st.floorKey(key);
if (k == null) throw new NoSuchElementException("all keys are greater than " + key);
return k;
}
代码示例来源:origin: deathmarine/Luyten
private Selection getSelectionForOffset(int offset) {
if (isNavigationLinksValid) {
Selection offsetSelection = new Selection(offset, offset);
Selection floorSelection = selectionToUniqueStrTreeMap.floorKey(offsetSelection);
if (floorSelection != null && floorSelection.from <= offset && floorSelection.to > offset) {
return floorSelection;
}
}
return null;
}
代码示例来源:origin: apache/incubator-gobblin
private URI getMatchedFloorKeyFromCache(URI configKeyURI) {
URI floorKey = this.configStoreAccessorMap.floorKey(configKeyURI);
if (floorKey == null) {
return null;
}
// both scheme name and authority name, if present, should match
// or both authority should be null
if (ConfigClientUtils.isAncestorOrSame(configKeyURI, floorKey)) {
return floorKey;
}
return null;
}
代码示例来源:origin: apache/kylin
@Override
public int getIdFromValueBytesWithoutCache(byte[] value, int offset, int len, int roundingFlag) {
byte[] val = Arrays.copyOfRange(value, offset, offset + len);
AppendDictSliceKey sliceKey = metadata.sliceFileMap.floorKey(AppendDictSliceKey.wrap(val));
if (sliceKey == null) {
sliceKey = metadata.sliceFileMap.firstKey();
}
AppendDictSlice slice;
try {
slice = dictCache.get(sliceKey);
} catch (ExecutionException e) {
throw new IllegalStateException("Failed to load slice with key " + sliceKey, e.getCause());
}
return slice.getIdFromValueBytesImpl(value, offset, len, roundingFlag);
}
代码示例来源:origin: apache/usergrid
/**
* Get all shards <= this one in descending order
*/
public Iterator<ShardEntryGroup> getShards( final Long maxShard ) {
final Long firstKey = shards.floorKey( maxShard );
return Collections.unmodifiableCollection( shards.headMap( firstKey, true ).descendingMap().values()).iterator();
}
代码示例来源:origin: stackoverflow.com
int l = map.floorKey(number);
if ( number == l ) {
return map.get(number);
代码示例来源:origin: apache/kylin
AppendDictSliceKey nextKey = sliceFileMap.floorKey(AppendDictSliceKey.wrap(valueBytes));
代码示例来源:origin: stanfordnlp/CoreNLP
HeadPosition getSeparator(int nodeNum) {
if (nodeNum >= stack.size()) {
return null;
}
TreeShapedStack<Tree> stack = this.stack;
for (int i = 0; i < nodeNum; ++i) {
stack = stack.pop();
}
Tree node = stack.peek();
int head = ShiftReduceUtils.headIndex(node);
if (separators.get(head) != null) {
return HeadPosition.HEAD;
}
int left = ShiftReduceUtils.leftIndex(node);
Integer nextLeft = separators.floorKey(head);
boolean hasLeft = (nextLeft != null && nextLeft >= left);
int right = ShiftReduceUtils.rightIndex(node);
Integer nextRight = separators.ceilingKey(head);
boolean hasRight = (nextRight != null && nextRight <= right);
if (hasLeft && hasRight) {
return HeadPosition.BOTH;
} else if (hasLeft) {
return HeadPosition.LEFT;
} else if (hasRight) {
return HeadPosition.RIGHT;
} else {
return HeadPosition.NONE;
}
}
代码示例来源:origin: MSGFPlus/msgfplus
public long getStartPosition(long position) {
Integer startPos = annotations.floorKey((int) position);
if (startPos == null) {
return 0;
}
return startPos;
}
代码示例来源:origin: apache/ctakes
public Sentence findPreviousOrCurrentSentence(int characterOffset) {
Integer floorKey = beginTreeMap.floorKey(characterOffset);
if (floorKey == null)
{
return null;
}
Sentence floorEntry = beginTreeMap.get(floorKey);
return floorEntry;
}
代码示例来源:origin: org.apache.ctakes/ctakes-assertion
public Sentence findPreviousOrCurrentSentence(int characterOffset) {
Integer floorKey = beginTreeMap.floorKey(characterOffset);
if (floorKey == null)
{
return null;
}
Sentence floorEntry = beginTreeMap.get(floorKey);
return floorEntry;
}
代码示例来源:origin: net.sf.saxon/Saxon-HE
public RangeKeyIterator() {
top = (CodepointMatchKey) (max == null ? index.lastKey() : index.floorKey(max));
}
代码示例来源:origin: org.verapdf/parser
private static String getRoman(int pageNumber) {
int curr = pageNumber;
StringBuilder builder = new StringBuilder();
while (curr > 0) {
int floor = MAP.floorKey(curr);
builder.append(MAP.get(floor));
curr -= floor;
}
return builder.toString();
}
代码示例来源:origin: io.teecube.t3/t3-common
public final static String toRoman(int number) {
int l = map.floorKey(number);
if ( number == l ) {
return map.get(number);
}
return map.get(l) + toRoman(number-l);
}
代码示例来源:origin: org.apache.gobblin/gobblin-config-client
private URI getMatchedFloorKeyFromCache(URI configKeyURI) {
URI floorKey = this.configStoreAccessorMap.floorKey(configKeyURI);
if (floorKey == null) {
return null;
}
// both scheme name and authority name, if present, should match
// or both authority should be null
if (ConfigClientUtils.isAncestorOrSame(configKeyURI, floorKey)) {
return floorKey;
}
return null;
}
代码示例来源:origin: com.linkedin.gobblin/gobblin-config-client
private URI getMatchedFloorKeyFromCache(URI configKeyURI) {
URI floorKey = this.configStoreAccessorMap.floorKey(configKeyURI);
if (floorKey == null) {
return null;
}
// both scheme name and authority name, if present, should match
// or both authority should be null
if (ConfigClientUtils.isAncestorOrSame(configKeyURI, floorKey)) {
return floorKey;
}
return null;
}
代码示例来源:origin: org.technbolts/gutenberg
private String raw(int value) {
if (value < 0)
throw new IllegalArgumentException("Negative number not allowed: " + value);
int l = map.floorKey(value);
if (value == l) {
return map.get(value);
}
return map.get(l) + raw(value - l);
}
}
代码示例来源:origin: arbelkilani/Clock-view
public final static String toArabic(int number) {
int l = arabicMap.floorKey(number);
if ( number == l ) {
return arabicMap.get(number);
}
return arabicMap.get(l) + toArabic(number-l);
}
}
代码示例来源:origin: WayofTime/BloodMagic
public static String toRoman(int arabic) {
int convert = romanNumerals.floorKey(arabic);
if (arabic == convert)
return romanNumerals.get(convert);
return romanNumerals.get(convert) + toRoman(arabic - convert);
}
}
代码示例来源:origin: stackoverflow.com
TreeMap<Integer, String> treeMap = new TreeMap<Integer, String>();
treeMap.put(100, "MarshalLib100");
treeMap.put(110, "MarshalLib110");
treeMap.put(102, "MarshalLib102");
treeMap.put(101, "MarshalLib101");
treeMap.put(150, "MarshalLib150");
System.out.println(treeMap.floorKey(102));
System.out.println(treeMap.floorEntry(102));
System.out.println(treeMap.ceilingKey(102));
System.out.println(treeMap.ceilingEntry(102));
内容来源于网络,如有侵权,请联系作者删除!