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


Java SortedMap.isEmpty方法代码示例

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


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

示例1: route

import java.util.SortedMap; //导入方法依赖的package包/类
public String route(int jobId, ArrayList<String> addressList) {

        // ------A1------A2-------A3------
        // -----------J1------------------
        TreeMap<Long, String> addressRing = new TreeMap<Long, String>();
        for (String address: addressList) {
            for (int i = 0; i < VIRTUAL_NODE_NUM; i++) {
                long addressHash = hash("SHARD-" + address + "-NODE-" + i);
                addressRing.put(addressHash, address);
            }
        }

        long jobHash = hash(String.valueOf(jobId));
        SortedMap<Long, String> lastRing = addressRing.tailMap(jobHash);
        if (!lastRing.isEmpty()) {
            return lastRing.get(lastRing.firstKey());
        }
        return addressRing.firstEntry().getValue();
    }
 
开发者ID:mmwhd,项目名称:stage-job,代码行数:20,代码来源:ExecutorRouteConsistentHash.java

示例2: transformLettersListIntoTurn

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * Returns the structure turn to be sent to the game
 *
 * @param letters           The letters to be played
 * @param startLine         The line of the first letter of the played letters
 * @param startColumn       The column of the first letter of the played letters
 * @param horizontal        True if the letters are disposed horizontally, false otherwise
 * @param checkBoardLetters True if we must check if letters have already been disposed with the given letters
 * @param board             The actual board
 *
 * @return the structure turn
 */
protected static SortedMap<BoardPosition, LetterInterface> transformLettersListIntoTurn(List<LetterInterface> letters, int startLine, int startColumn, boolean horizontal, boolean checkBoardLetters, BoardInterface board) {
    SortedMap<BoardPosition, LetterInterface> turn = new TreeMap<>();

    for (int i = 0; i < letters.size(); i++) {
        short line, column;

        if (horizontal) {
            line = (short) startLine;
            column = (short) (startColumn + i);
        } else {
            line = (short) (startLine + i);
            column = (short) startColumn;
        }

        if (line < 0 || line >= BoardInterface.BOARD_SIZE || column < 0 || column >= BoardInterface.BOARD_SIZE) {
            return null;
        }

        if (!checkBoardLetters || null == board.getLetters().get(line).get(column)) {
            turn.put(new BoardPosition(line, column), letters.get(i));
        }
    }

    return !turn.isEmpty() ? turn : null;
}
 
开发者ID:Chrisp1tv,项目名称:ScrabbleGame,代码行数:38,代码来源:PossibleTurnsFinder.java

示例3: getPrefixWords

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * 
 * @param sen sen.length() greater than 0
 * @param start at first start = 0
 * @param dic
 */
private static LinkedList<Integer> getPrefixWords(String sen,int start,Dictionary dic){
	LinkedList<Integer> wl = new LinkedList<>();
	if(start == sen.length())
		return wl;
	for(int i=start+1;i<=sen.length();i++){
		String w = sen.substring(start,i);
		SortedMap<String,Double> map = dic.prefixMap(w);
		if(map.isEmpty()){
			//we find a new word! Its length maybe larger than 1.
			if(i==start+1){
				wl.add(i); //this new word's length is 1.
			}else{ //this new word's length is larger than 1.
				if(wl.indexOf(i-1) == -1)
					wl.add(i-1);
			}
			return wl;
		}
		if(map.containsKey(w)){
			wl.add(i);
		}else{
			if(i==sen.length())
				wl.add(i); //we find a new word! Its length maybe larger than 1. 
		}
	}
	return wl;
}
 
开发者ID:profullstack,项目名称:cjk-mmseg,代码行数:33,代码来源:Mmseg.java

示例4: getFirstEnabled

import java.util.SortedMap; //导入方法依赖的package包/类
public T getFirstEnabled() {
    SortedMap<String, T> map = enabled.getAsMap();
    if (map.isEmpty()) {
        return null;
    } else {
        return map.get(map.firstKey());
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:9,代码来源:DefaultReportContainer.java

示例5: getReservationsAtTime

import java.util.SortedMap; //导入方法依赖的package包/类
@Override
public Set<ReservationAllocation> getReservationsAtTime(long tick) {
  ReservationInterval searchInterval =
      new ReservationInterval(tick, Long.MAX_VALUE);
  readLock.lock();
  try {
    SortedMap<ReservationInterval, Set<InMemoryReservationAllocation>> reservations =
        currentReservations.headMap(searchInterval, true);
    if (!reservations.isEmpty()) {
      Set<ReservationAllocation> flattenedReservations =
          new HashSet<ReservationAllocation>();
      for (Set<InMemoryReservationAllocation> reservationEntries : reservations
          .values()) {
        for (InMemoryReservationAllocation reservation : reservationEntries) {
          if (reservation.getEndTime() > tick) {
            flattenedReservations.add(reservation);
          }
        }
      }
      return Collections.unmodifiableSet(flattenedReservations);
    } else {
      return Collections.emptySet();
    }
  } finally {
    readLock.unlock();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:InMemoryPlan.java

示例6: selectForKey

import java.util.SortedMap; //导入方法依赖的package包/类
private Invoker<T> selectForKey(long hash) {
    Invoker<T> invoker;
    Long key = hash;
    if (!virtualInvokers.containsKey(key)) {
        SortedMap<Long, Invoker<T>> tailMap = virtualInvokers.tailMap(key);
        if (tailMap.isEmpty()) {
            key = virtualInvokers.firstKey();
        } else {
            key = tailMap.firstKey();
        }
    }
    invoker = virtualInvokers.get(key);
    return invoker;
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:15,代码来源:ConsistentHashLoadBalance.java

示例7: checkForProblems

import java.util.SortedMap; //导入方法依赖的package包/类
private void checkForProblems(SortedMap<String,SortedSet<String>> problems, String msg, String testName, Map<String,String> pseudoTests) {
    if (!problems.isEmpty()) {
        StringBuilder message = new StringBuilder(msg);
        for (Map.Entry<String, SortedSet<String>> entry : problems.entrySet()) {
            message.append("\nProblems found for module ").append(entry.getKey()).append(": ").append(entry.getValue());
        }
        pseudoTests.put(testName, message.toString());
    } else {
        pseudoTests.put(testName, null);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:VerifyUpdateCenter.java

示例8: findPath2

import java.util.SortedMap; //导入方法依赖的package包/类
private ASTPath findPath2 (List<ASTItem> path, int offset) {
    TreeMap<Integer,ASTItem> childrenMap = getChildrenMap ();
    SortedMap<Integer,ASTItem> headMap = childrenMap.headMap (new Integer (offset + 1));
    if (headMap.isEmpty ())
        return ASTPath.create (path);
    Integer key = headMap.lastKey ();
    ASTItem item = childrenMap.get (key);
    ASTPath path2 =  item.findPath (path, offset);
    if (path2 == null)
        return ASTPath.create (path);
    return path2;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:ASTItem.java

示例9: getShardInfo

import java.util.SortedMap; //导入方法依赖的package包/类
public S getShardInfo(byte[] key) {
	SortedMap<Long, S> tail = nodes.tailMap(algo.hash(key));
	if (tail.isEmpty()) {
		return nodes.get(nodes.firstKey());
	}
	return tail.get(tail.firstKey());
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:8,代码来源:Sharded.java

示例10: floor

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * Return the largest key in the table <= k.
 */ 
public Key floor(Key k) {
    if (st.containsKey(k)) return k;

    // does not include key if present (!)
    SortedMap<Key, Value> head = st.headMap(k);
    if (head.isEmpty()) return null;
    else return head.lastKey();
}
 
开发者ID:wz12406,项目名称:accumulate,代码行数:12,代码来源:ST.java

示例11: sekectForKey

import java.util.SortedMap; //导入方法依赖的package包/类
private Invoker<T> sekectForKey(long hash) {
    Invoker<T> invoker;
    Long key = hash;
    if (!virtualInvokers.containsKey(key)) {
        SortedMap<Long, Invoker<T>> tailMap = virtualInvokers.tailMap(key);
        if (tailMap.isEmpty()) {
            key = virtualInvokers.firstKey();
        } else {
            key = tailMap.firstKey();
        }
    }
    invoker = virtualInvokers.get(key);
    return invoker;
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:15,代码来源:ConsistentHashLoadBalance.java

示例12: processKeyMap

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * process not null parameters for parameters map
 * @param map
 * @param process
 */
private void processKeyMap(@NonNull SortedMap<String, String> map,
                           @NonNull ProcessNotNullMapParameters process){
    if (!map.isEmpty()) {
        for (Map.Entry<String, String> entry : map.entrySet()) {
            if (entry.getValue() != null && !entry.getValue().isEmpty())
                process.process(entry.getKey().toString(), entry.getValue());
        }
    }
}
 
开发者ID:Webtrekk,项目名称:webtrekk-android-sdk,代码行数:15,代码来源:TrackingRequest.java

示例13: getForegroundAppPackageName

import java.util.SortedMap; //导入方法依赖的package包/类
@SuppressWarnings("WrongConstant")
public static String getForegroundAppPackageName(Context context) {
    UsageStatsManager manager = (UsageStatsManager) context.getSystemService("usagestats");
    long time = System.currentTimeMillis();
    List<UsageStats> list = manager.queryUsageStats(UsageStatsManager.INTERVAL_DAILY,
            time - 1000 * 1000, time);
    if (list != null && !list.isEmpty()) {
        SortedMap<Long, UsageStats> map = new TreeMap<>();
        for (UsageStats stats : list) {
            map.put(stats.getLastTimeUsed(), stats);
        }

        if (!map.isEmpty()) {
            return map.get(map.lastKey()).getPackageName();
        }
    }

    return null;
}
 
开发者ID:mthli,项目名称:Mount,代码行数:20,代码来源:PolicyUtils.java

示例14: archiveCompletedReservations

import java.util.SortedMap; //导入方法依赖的package包/类
@Override
public void archiveCompletedReservations(long tick) {
  // Since we are looking for old reservations, read lock is optimal
  LOG.debug("Running archival at time: {}", tick);
  List<InMemoryReservationAllocation> expiredReservations =
      new ArrayList<InMemoryReservationAllocation>();
  readLock.lock();
  // archive reservations and delete the ones which are beyond
  // the reservation policy "window"
  try {
    long archivalTime = tick - policy.getValidWindow();
    ReservationInterval searchInterval =
        new ReservationInterval(archivalTime, archivalTime);
    SortedMap<ReservationInterval, Set<InMemoryReservationAllocation>> reservations =
        currentReservations.headMap(searchInterval, true);
    if (!reservations.isEmpty()) {
      for (Set<InMemoryReservationAllocation> reservationEntries : reservations
          .values()) {
        for (InMemoryReservationAllocation reservation : reservationEntries) {
          if (reservation.getEndTime() <= archivalTime) {
            expiredReservations.add(reservation);
          }
        }
      }
    }
  } finally {
    readLock.unlock();
  }
  if (expiredReservations.isEmpty()) {
    return;
  }
  // Need write lock only if there are any reservations to be deleted
  writeLock.lock();
  try {
    for (InMemoryReservationAllocation expiredReservation : expiredReservations) {
      removeReservation(expiredReservation);
    }
  } finally {
    writeLock.unlock();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:42,代码来源:InMemoryPlan.java

示例15: ceil

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * Return the smallest key in the table >= k.
 */ 
public Key ceil(Key k) {
    SortedMap<Key, Value> tail = st.tailMap(k);
    if (tail.isEmpty()) return null;
    else return tail.firstKey();
}
 
开发者ID:wz12406,项目名称:accumulate,代码行数:9,代码来源:ST.java


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