本文整理匯總了Java中java.util.TreeMap.firstEntry方法的典型用法代碼示例。如果您正苦於以下問題:Java TreeMap.firstEntry方法的具體用法?Java TreeMap.firstEntry怎麽用?Java TreeMap.firstEntry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.TreeMap
的用法示例。
在下文中一共展示了TreeMap.firstEntry方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: take
import java.util.TreeMap; //導入方法依賴的package包/類
/**
* Remove a version tag from the map.
*/
public Map.Entry<VersionTag, T> take() {
if (tombstoneMap.isEmpty()) {
// if there are no more entries, return null;
return null;
} else {
// Otherwise, look at all of the members and find the tag with the
// lowest timestamp.
long lowestTimestamp = Long.MAX_VALUE;
TreeMap<VersionTag, T> lowestMap = null;
for (TreeMap<VersionTag, T> memberMap : tombstoneMap.values()) {
VersionTag firstTag = memberMap.firstKey();
long stamp = firstTag.getVersionTimeStamp();
if (stamp < lowestTimestamp) {
lowestTimestamp = stamp;
lowestMap = memberMap;
}
}
if (lowestMap == null) {
return null;
}
// Remove the lowest entry
Entry<VersionTag, T> result = lowestMap.firstEntry();
lowestMap.remove(result.getKey());
if (lowestMap.isEmpty()) {
// if this is the last entry from a given member,
// the map for that member
tombstoneMap.remove(result.getKey().getMemberID());
}
return result;
}
}
示例2: getSmallestEntry
import java.util.TreeMap; //導入方法依賴的package包/類
public void getSmallestEntry(TreeMap<String, String> maps){
Map.Entry<String,String> entry = maps.firstEntry();
System.out.println("最小的Entry如下");
System.out.print("key = " + entry.getKey());
System.out.println(" value = " + entry.getValue());
}