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


Java SortedSet.headSet方法代码示例

本文整理汇总了Java中java.util.SortedSet.headSet方法的典型用法代码示例。如果您正苦于以下问题:Java SortedSet.headSet方法的具体用法?Java SortedSet.headSet怎么用?Java SortedSet.headSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.SortedSet的用法示例。


在下文中一共展示了SortedSet.headSet方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: last

import java.util.SortedSet; //导入方法依赖的package包/类
@Override
public E last() {
  SortedSet<E> sortedUnfiltered = (SortedSet<E>) unfiltered;
  while (true) {
    E element = sortedUnfiltered.last();
    if (predicate.apply(element)) {
      return element;
    }
    sortedUnfiltered = sortedUnfiltered.headSet(element);
  }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:12,代码来源:Sets.java

示例2: 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

示例3: 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

示例4: cleanOldLogs

import java.util.SortedSet; //导入方法依赖的package包/类
private void cleanOldLogs(SortedSet<String> wals, String key, String id) {
  SortedSet<String> walSet = wals.headSet(key);
  LOG.debug("Removing " + walSet.size() + " logs in the list: " + walSet);
  for (String wal : walSet) {
    this.replicationQueues.removeLog(id, wal);
  }
  walSet.clear();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:9,代码来源:ReplicationSourceManager.java

示例5: execute

import java.util.SortedSet; //导入方法依赖的package包/类
/**
 * the command that is run and retried for actually 
 * obtaining the lock
 * @return if the command was successful or not
 */
public boolean execute() throws KeeperException, InterruptedException {
    do {
        if (id == null) {
            long sessionId = zookeeper.getSessionId();
            String prefix = "x-" + sessionId + "-";
            // lets try look up the current ID if we failed 
            // in the middle of creating the znode
            findPrefixInChildren(prefix, zookeeper, dir);
            idName = new ZNodeName(id);
        }
        if (id != null) {
            List<String> names = zookeeper.getChildren(dir, false);
            if (names.isEmpty()) {
                LOG.warn("No children in: " + dir + " when we've just " +
                "created one! Lets recreate it...");
                // lets force the recreation of the id
                id = null;
            } else {
                // lets sort them explicitly (though they do seem to come back in order ususally :)
                SortedSet<ZNodeName> sortedNames = new TreeSet<ZNodeName>();
                for (String name : names) {
                    sortedNames.add(new ZNodeName(dir + "/" + name));
                }
                ownerId = sortedNames.first().getName();
                SortedSet<ZNodeName> lessThanMe = sortedNames.headSet(idName);
                if (!lessThanMe.isEmpty()) {
                    ZNodeName lastChildName = lessThanMe.last();
                    lastChildId = lastChildName.getName();
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("watching less than me node: " + lastChildId);
                    }
                    Stat stat = zookeeper.exists(lastChildId, new LockWatcher());
                    if (stat != null) {
                        return Boolean.FALSE;
                    } else {
                        LOG.warn("Could not find the" +
                        		" stats for less than me: " + lastChildName.getName());
                    }
                } else {
                    if (isOwner()) {
                        if (callback != null) {
                            callback.lockAcquired();
                        }
                        return Boolean.TRUE;
                    }
                }
            }
        }
    }
    while (id == null);
    return Boolean.FALSE;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:58,代码来源:WriteLock.java

示例6: testCopyOf_headSet

import java.util.SortedSet; //导入方法依赖的package包/类
public void testCopyOf_headSet() {
  SortedSet<String> set = of("e", "a", "f", "b", "d", "c");
  SortedSet<String> headset = set.headSet("d");
  SortedSet<String> copy = copyOf(headset);
  assertEquals(headset, copy);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:7,代码来源:ImmutableSortedSetTest.java


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