当前位置: 首页>>代码示例>>Java>>正文


Java SortedSet.tailSet方法代码示例

本文整理汇总了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;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:22,代码来源:DefaultMemStore.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:PrintIcon.java

示例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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:GsfSemanticLayer.java

示例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;
}
 
开发者ID:Superioz,项目名称:MooProject,代码行数:33,代码来源:CandidateCompleter.java

示例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();
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:15,代码来源:DerivedCollectionGenerators.java

示例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());
}
 
开发者ID:equella,项目名称:Equella,代码行数:16,代码来源:PagesHandler.java

示例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());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:TreeSetTest.java

示例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());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:TreeSubSetTest.java

示例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());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:TreeSubSetTest.java

示例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());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:ConcurrentSkipListSetTest.java

示例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();
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:5,代码来源:Polygon2DUtils.java

示例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);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:7,代码来源:ImmutableSortedSetTest.java

示例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;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:65,代码来源:JournalSet.java


注:本文中的java.util.SortedSet.tailSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。