本文整理汇总了Java中java.util.SortedSet.tailSet方法的典型用法代码示例。如果您正苦于以下问题:Java SortedSet.tailSet方法的具体用法?Java SortedSet.tailSet怎么用?Java SortedSet.tailSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.SortedSet
的用法示例。
在下文中一共展示了SortedSet.tailSet方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: walkForwardInSingleRow
import java.util.SortedSet; //导入方法依赖的package包/类
private boolean walkForwardInSingleRow(final SortedSet<Cell> set,
final Cell firstOnRow, final GetClosestRowBeforeTracker state) {
boolean foundCandidate = false;
SortedSet<Cell> tail = set.tailSet(firstOnRow);
if (tail.isEmpty()) return foundCandidate;
for (Iterator<Cell> i = tail.iterator(); i.hasNext();) {
Cell kv = i.next();
// Did we go beyond the target row? If so break.
if (state.isTooFar(kv, firstOnRow)) break;
if (state.isExpired(kv)) {
i.remove();
continue;
}
// If we added something, this row is a contender. break.
if (state.handle(kv)) {
foundCandidate = true;
break;
}
}
return foundCandidate;
}
示例2: contains
import java.util.SortedSet; //导入方法依赖的package包/类
private static boolean contains(SortedSet<IconInfo> set, int hashCode) {
IconInfo fake = new IconInfo("", "", hashCode);
Set<IconInfo> greaterOrEqual = set.tailSet(fake);
if (greaterOrEqual.isEmpty()) {
return false;
}
IconInfo first = greaterOrEqual.iterator().next();
return hashCode == first.hash;
}
示例3: GsfHighlightSequence
import java.util.SortedSet; //导入方法依赖的package包/类
GsfHighlightSequence(GsfSemanticLayer layer, Document doc,
int startOffset, int endOffset,
SortedSet<SequenceElement> colorings) {
this.layer = layer;
this.endOffset = endOffset;
SequenceElement.ComparisonItem fromInclusive = new SequenceElement.ComparisonItem(startOffset);
SortedSet<SequenceElement> subMap = colorings.tailSet(fromInclusive);
iterator = subMap.iterator();
}
示例4: complete
import java.util.SortedSet; //导入方法依赖的package包/类
@Override
public int complete(String buffer, int cursor, List<CharSequence> candidates) {
// buffer could be null
Preconditions.checkNotNull(candidates);
SortedSet<String> strings = new TreeSet<>();
TabCompleteEvent event = new TabCompleteEvent(buffer);
EventExecutor.getInstance().execute(event);
if(!event.isCancelled()) {
List<String> l = event.getSuggestions();
if(l != null) strings.addAll(l);
}
String currentBuffer = event.getCurrentBuffer();
String add = event.getBeforeBuffer();
if(currentBuffer == null) {
for(String string : strings) {
candidates.add(add + string);
}
}
else {
for(String match : strings.tailSet(currentBuffer)) {
if(!match.startsWith(currentBuffer)) {
break;
}
candidates.add(add + match);
}
}
return candidates.isEmpty() ? -1 : 0;
}
示例5: createSubSet
import java.util.SortedSet; //导入方法依赖的package包/类
/**
* Calls the smallest subSet overload that filters out the extreme values.
*/
SortedSet<E> createSubSet(SortedSet<E> set, E firstExclusive, E lastExclusive) {
if (from == Bound.NO_BOUND && to == Bound.EXCLUSIVE) {
return set.headSet(lastExclusive);
} else if (from == Bound.INCLUSIVE && to == Bound.NO_BOUND) {
return set.tailSet(firstInclusive);
} else if (from == Bound.INCLUSIVE && to == Bound.EXCLUSIVE) {
return set.subSet(firstInclusive, lastExclusive);
} else {
throw new IllegalArgumentException();
}
}
示例6: versions
import java.util.SortedSet; //导入方法依赖的package包/类
public void versions(HttpExchange exchange) throws Exception
{
SortedSet<WebVersion> allVersions = new Version(config).getVersions();
WebVersion deployedVersion = new Version(config).getDeployedVersion();
Set<WebVersion> newer = allVersions.headSet(deployedVersion);
Set<WebVersion> older = allVersions.tailSet(deployedVersion);
older.remove(deployedVersion);
StringTemplate st = templates.getInstanceOf("templates/versions");
st.setAttribute("newer", newer);
st.setAttribute("older", older);
st.setAttribute("current", Collections.singleton(deployedVersion));
HttpExchangeUtils.respondHtmlMessage(exchange, 200, st.toString());
}
示例7: testTailSetContents
import java.util.SortedSet; //导入方法依赖的package包/类
/**
* tailSet returns set with keys in requested range
*/
public void testTailSetContents() {
TreeSet set = set5();
SortedSet sm = set.tailSet(two);
assertFalse(sm.contains(one));
assertTrue(sm.contains(two));
assertTrue(sm.contains(three));
assertTrue(sm.contains(four));
assertTrue(sm.contains(five));
Iterator i = sm.iterator();
Object k;
k = (Integer)(i.next());
assertEquals(two, k);
k = (Integer)(i.next());
assertEquals(three, k);
k = (Integer)(i.next());
assertEquals(four, k);
k = (Integer)(i.next());
assertEquals(five, k);
assertFalse(i.hasNext());
SortedSet ssm = sm.tailSet(four);
assertEquals(four, ssm.first());
assertEquals(five, ssm.last());
assertTrue(ssm.remove(four));
assertEquals(1, ssm.size());
assertEquals(3, sm.size());
assertEquals(4, set.size());
}
示例8: testTailSetContents
import java.util.SortedSet; //导入方法依赖的package包/类
/**
* tailSet returns set with keys in requested range
*/
public void testTailSetContents() {
NavigableSet set = set5();
SortedSet sm = set.tailSet(two);
assertFalse(sm.contains(one));
assertTrue(sm.contains(two));
assertTrue(sm.contains(three));
assertTrue(sm.contains(four));
assertTrue(sm.contains(five));
Iterator i = sm.iterator();
Object k;
k = (Integer)(i.next());
assertEquals(two, k);
k = (Integer)(i.next());
assertEquals(three, k);
k = (Integer)(i.next());
assertEquals(four, k);
k = (Integer)(i.next());
assertEquals(five, k);
assertFalse(i.hasNext());
SortedSet ssm = sm.tailSet(four);
assertEquals(four, ssm.first());
assertEquals(five, ssm.last());
assertTrue(ssm.remove(four));
assertEquals(1, ssm.size());
assertEquals(3, sm.size());
assertEquals(4, set.size());
}
示例9: testDescendingTailSetContents
import java.util.SortedSet; //导入方法依赖的package包/类
/**
* tailSet returns set with keys in requested range
*/
public void testDescendingTailSetContents() {
NavigableSet set = dset5();
SortedSet sm = set.tailSet(m2);
assertFalse(sm.contains(m1));
assertTrue(sm.contains(m2));
assertTrue(sm.contains(m3));
assertTrue(sm.contains(m4));
assertTrue(sm.contains(m5));
Iterator i = sm.iterator();
Object k;
k = (Integer)(i.next());
assertEquals(m2, k);
k = (Integer)(i.next());
assertEquals(m3, k);
k = (Integer)(i.next());
assertEquals(m4, k);
k = (Integer)(i.next());
assertEquals(m5, k);
assertFalse(i.hasNext());
SortedSet ssm = sm.tailSet(m4);
assertEquals(m4, ssm.first());
assertEquals(m5, ssm.last());
assertTrue(ssm.remove(m4));
assertEquals(1, ssm.size());
assertEquals(3, sm.size());
assertEquals(4, set.size());
}
示例10: testTailSetContents
import java.util.SortedSet; //导入方法依赖的package包/类
/**
* tailSet returns set with keys in requested range
*/
public void testTailSetContents() {
ConcurrentSkipListSet set = set5();
SortedSet sm = set.tailSet(two);
assertFalse(sm.contains(one));
assertTrue(sm.contains(two));
assertTrue(sm.contains(three));
assertTrue(sm.contains(four));
assertTrue(sm.contains(five));
Iterator i = sm.iterator();
Object k;
k = (Integer)(i.next());
assertEquals(two, k);
k = (Integer)(i.next());
assertEquals(three, k);
k = (Integer)(i.next());
assertEquals(four, k);
k = (Integer)(i.next());
assertEquals(five, k);
assertFalse(i.hasNext());
SortedSet ssm = sm.tailSet(four);
assertEquals(four, ssm.first());
assertEquals(five, ssm.last());
assertTrue(ssm.remove(four));
assertEquals(1, ssm.size());
assertEquals(3, sm.size());
assertEquals(4, set.size());
}
示例11: findNext
import java.util.SortedSet; //导入方法依赖的package包/类
private final static <T> T findNext(SortedSet<T> set, T element){
SortedSet<T> tail = set.tailSet(element);
return tail.isEmpty() ? set.first() : tail.first();
}
示例12: testCopyOf_tailSet
import java.util.SortedSet; //导入方法依赖的package包/类
public void testCopyOf_tailSet() {
SortedSet<String> set = of("e", "a", "f", "b", "d", "c");
SortedSet<String> tailset = set.tailSet("d");
SortedSet<String> copy = copyOf(tailset);
assertEquals(tailset, copy);
}
示例13: getEditLogManifest
import java.util.SortedSet; //导入方法依赖的package包/类
/**
* Return a manifest of what finalized edit logs are available. All available
* edit logs are returned starting from the transaction id passed. If
* 'fromTxId' falls in the middle of a log, that log is returned as well.
*
* @param fromTxId Starting transaction id to read the logs.
* @return RemoteEditLogManifest object.
*/
public synchronized RemoteEditLogManifest getEditLogManifest(long fromTxId) {
// Collect RemoteEditLogs available from each FileJournalManager
List<RemoteEditLog> allLogs = Lists.newArrayList();
for (JournalAndStream j : journals) {
if (j.getManager() instanceof FileJournalManager) {
FileJournalManager fjm = (FileJournalManager)j.getManager();
try {
allLogs.addAll(fjm.getRemoteEditLogs(fromTxId, false));
} catch (Throwable t) {
LOG.warn("Cannot list edit logs in " + fjm, t);
}
}
}
// Group logs by their starting txid
ImmutableListMultimap<Long, RemoteEditLog> logsByStartTxId =
Multimaps.index(allLogs, RemoteEditLog.GET_START_TXID);
long curStartTxId = fromTxId;
List<RemoteEditLog> logs = Lists.newArrayList();
while (true) {
ImmutableList<RemoteEditLog> logGroup = logsByStartTxId.get(curStartTxId);
if (logGroup.isEmpty()) {
// we have a gap in logs - for example because we recovered some old
// storage directory with ancient logs. Clear out any logs we've
// accumulated so far, and then skip to the next segment of logs
// after the gap.
SortedSet<Long> startTxIds = Sets.newTreeSet(logsByStartTxId.keySet());
startTxIds = startTxIds.tailSet(curStartTxId);
if (startTxIds.isEmpty()) {
break;
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Found gap in logs at " + curStartTxId + ": " +
"not returning previous logs in manifest.");
}
logs.clear();
curStartTxId = startTxIds.first();
continue;
}
}
// Find the one that extends the farthest forward
RemoteEditLog bestLog = Collections.max(logGroup);
logs.add(bestLog);
// And then start looking from after that point
curStartTxId = bestLog.getEndTxId() + 1;
}
RemoteEditLogManifest ret = new RemoteEditLogManifest(logs);
if (LOG.isDebugEnabled()) {
LOG.debug("Generated manifest for logs since " + fromTxId + ":"
+ ret);
}
return ret;
}