當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。