當前位置: 首頁>>代碼示例>>Java>>正文


Java NavigableMap.floorKey方法代碼示例

本文整理匯總了Java中java.util.NavigableMap.floorKey方法的典型用法代碼示例。如果您正苦於以下問題:Java NavigableMap.floorKey方法的具體用法?Java NavigableMap.floorKey怎麽用?Java NavigableMap.floorKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.NavigableMap的用法示例。


在下文中一共展示了NavigableMap.floorKey方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findMatchingValues

import java.util.NavigableMap; //導入方法依賴的package包/類
private void findMatchingValues(NavigableMap<Endpoint, Integer> map, Endpoint endpoint, List<UUID> result) {
    // Mark this endpoint as a marker, because it is used to do a tailMap traversal to query matching edges
    endpoint.setMarker();
    
    // Find the first key 
    Endpoint floorKey = map.floorKey(endpoint);
    
    Map<Endpoint, Integer> view;
    if (floorKey == null) {
        // This means that the element being searched is the minimum
        view = map;
    } else {
        view = map.tailMap(floorKey);
    }
    
    boolean isFirst = true;
    for (Map.Entry<Endpoint, Integer> entry : view.entrySet()) {
        Endpoint key = entry.getKey();

        if (endpoint.isMatch(key)) {
            // Matching entry, must be added to result
            result.add(key.getEdgeId());
        } else {
            // Done with the search -- the tree map is sorted
            
            if (isFirst) {
                // continue
            } else {
                break;
            }
        }
        
        isFirst = false;
    }
}
 
開發者ID:lambdazen,項目名稱:bitsy,代碼行數:36,代碼來源:AdjacencyMap.java

示例2: removeMatchingKeys

import java.util.NavigableMap; //導入方法依賴的package包/類
private boolean removeMatchingKeys(NavigableMap<Endpoint, Integer> map, Endpoint endpoint, Map<UUID, TreeMap<Endpoint, Integer>> otherMap, Direction dir) {
    if (map == null) {
        return false;
    }
    
    // Mark this endpoint as a marker, because it is used to do a tailMap traversal to remove matching edges
    endpoint.setMarker();
    
    // Find the first key 
    Endpoint floorKey = map.floorKey(endpoint);
    
    Map<Endpoint, Integer> view;
    if (floorKey == null) {
        // This means that the element being searched is the minimum
        view = map;
    } else {
        view = map.tailMap(floorKey);
    }
    
    Iterator<Map.Entry<Endpoint, Integer>> entryIter = view.entrySet().iterator();

    boolean isFirst = true;
    while (entryIter.hasNext()) {
        Map.Entry<Endpoint, Integer> entry = entryIter.next();
        Endpoint key = entry.getKey();
        
        if (endpoint.isMatch(key)) {
            // Remove it from this index
            entryIter.remove();
            
            // and from the underlying edge map if necessary
            if (dir != null) { // Direction is null if this is a recursive all
                // Remove the edge if the map is provided for this purpose 
                UUID edgeId = key.getEdgeId();

                IEdge edge = edgeRemover.removeEdge(edgeId);
                
                assert (edge != null);
                
                // Remove the other endpoint of this edge. NOTE: Self loops are not allowed.
                Endpoint otherEndpoint;
                UUID otherVertexId;
                if (dir == Direction.OUT) {
                    otherVertexId = edge.getInVertexId();
                    otherEndpoint = new Endpoint(key.getEdgeLabel(), key.getEdgeId());
                } else {
                    otherVertexId = edge.getOutVertexId();
                    otherEndpoint = new Endpoint(key.getEdgeLabel(), key.getEdgeId());
                }

                if (removeMatchingKeys(otherMap.get(otherVertexId), otherEndpoint, null, null)) {
                    otherMap.remove(otherVertexId);
                }
            }
        } else {
            // Done with removes -- the tree map is sorted
            if (isFirst) {
                // continue
            } else {
                break;
            }
        }
        
        isFirst = false;
    }
    
    return (map.size() == 0);
}
 
開發者ID:lambdazen,項目名稱:bitsy,代碼行數:69,代碼來源:AdjacencyMap.java


注:本文中的java.util.NavigableMap.floorKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。