当前位置: 首页>>代码示例>>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;未经允许,请勿转载。