• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ListUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.commons.collections15.ListUtils的典型用法代码示例。如果您正苦于以下问题:Java ListUtils类的具体用法?Java ListUtils怎么用?Java ListUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ListUtils类属于org.apache.commons.collections15包,在下文中一共展示了ListUtils类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getShortestPathsIntern

import org.apache.commons.collections15.ListUtils; //导入依赖的package包/类
@Override
protected List<List<E>> getShortestPathsIntern(final V source,
		final V target, int k) {
	LinkedList<List<E>> found_paths = new LinkedList<List<E>>();
	PriorityQueue<WeightedPath> prioQ = new PriorityQueue<WeightedPath>();
	DijkstraShortestPath<V, E> blockedDijkstra;

	// Check if target is reachable from source.
	if (dijkstra.getDistance(source, target) == null)
		return found_paths;

	// Add Dijkstra solution, the first shortest path.
	found_paths.add(dijkstra.getPath(source, target));

	while (found_paths.size() < k) {
		List<E> curShortestPath = found_paths.getLast();

		int maxIndex = curShortestPath.size();

		// Split path into Head and NextEdge
		for (int i = 0; i < maxIndex; i++) {
			List<E> head = curShortestPath.subList(0, i /* excluded */);
			V deviation = head.isEmpty() ? source : graph.getDest(head
					.get(i - 1));

			// 1. Block edges.
			Graph<V, E> blocked = blockFilter(head, deviation, found_paths);

			// 2. Get shortest path in graph with blocked edges.
			blockedDijkstra = new DijkstraShortestPath<V, E>(blocked, nev);

			Number dist = blockedDijkstra.getDistance(deviation, target);
			if (dist == null)
				continue;

			List<E> tail = blockedDijkstra.getPath(deviation, target);

			// 3. Combine head and tail into new path.
			List<E> candidate = new ArrayList<E>(i + tail.size());
			candidate.addAll(head);
			candidate.addAll(tail);

			// Check if we already found this solution
			boolean duplicate = false;
			for (WeightedPath path : prioQ)
				if (ListUtils.isEqualList(path.getPath(), candidate)) {
					duplicate = true;
					break;
				}

			if (!duplicate)
				prioQ.add(new WeightedPath(candidate));
		}

		if (prioQ.isEmpty())
			break; // We have not found any new candidate!
		else
			found_paths.add(prioQ.poll().getPath());
	}

	return found_paths;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:63,代码来源:Yen.java


示例2: findItemsBetween

import org.apache.commons.collections15.ListUtils; //导入依赖的package包/类
@Override
public List<IBoundedItem> findItemsBetween(IBoundedItem in, IBoundedItem out){
    // these list will contain the item referenced by edges also containing IN or OUT item
    List<IBoundedItem> ins = new ArrayList<IBoundedItem>();
    List<IBoundedItem> outs = new ArrayList<IBoundedItem>();
    
    for(Tube tube: rootTubes){
        retrieveInOutItems(tube, in, out, ins, outs);
    }
    for(IEdge edge: internalEdges){
        retrieveInOutItems(edge, in, out, ins, outs);
    }
    
    return ListUtils.intersection(ins, outs);
}
 
开发者ID:datagr4m,项目名称:org.datagr4m,代码行数:16,代码来源:HierarchicalEdgeModel.java


示例3: findTwoWays

import org.apache.commons.collections15.ListUtils; //导入依赖的package包/类
/**
 * Combines two disjoint paths from two SuurballeTarjan input paths.
 * 
 * @param path1
 *            Dijkstra shortest path
 * @param path2
 *            Dijkstra shortest path in partly reverted graph
 * @return the two disjoint paths
 */
private List<List<E>> findTwoWays(List<E> path1, List<E> path2) {
	final V source = graph.getSource(path1.get(0));
	final V target = graph.getDest(path1.get(path1.size() - 1));

	// Remove common links.
	Iterator<E> it1 = path1.iterator();
	while (it1.hasNext()) {
		E e1 = it1.next();

		Iterator<E> it2 = path2.iterator();
		while (it2.hasNext()) {
			E e2 = it2.next();

			// ensure disjointness
			if (comparator.compare(e1, e2) == 0) { // for multigraph
				if (graph.isSource(source, e1)
						|| graph.isSource(source, e2)
						|| graph.isDest(target, e1)
						|| graph.isDest(target, e2))
					return null; // Removing required edge

				it1.remove();
				it2.remove();
				break; // inner loop
			}
		}
	}

	if (path1.isEmpty() || path2.isEmpty())
		return null; // no disjoint solution found

	// Now recombine the two paths.
	List<E> union = ListUtils.union(path1, path2); // concatenate

	List<E> p1 = recombinePaths(path1, target, union);
	if (p1 == null)
		return null;

	List<E> p2 = recombinePaths(path2, target, union);
	if (p2 == null)
		return null;
	
	if (!union.isEmpty())
		throw new AssertionError("BUG");

	List<List<E>> solution = new LinkedList<List<E>>();
	solution.add(p1);
	solution.add(p2);
	return solution;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:60,代码来源:SuurballeTarjan.java


示例4: getShortestPathsIntern

import org.apache.commons.collections15.ListUtils; //导入依赖的package包/类
@Override
protected List<List<E>> getShortestPathsIntern(final V source,
                                               final V target, int k) {
    LinkedList<List<E>> found_paths = new LinkedList<List<E>>();
    PriorityQueue<WeightedPath> prioQ = new PriorityQueue<WeightedPath>();
    DijkstraShortestPath<V, E> blockedDijkstra;

    // Check if target is reachable from source.
    if (dijkstra.getDistance(source, target) == null)
        return found_paths;

    // Add Dijkstra solution, the first shortest path.
    found_paths.add(dijkstra.getPath(source, target));

    while (found_paths.size() < k) {
        List<E> curShortestPath = found_paths.getLast();

        int maxIndex = curShortestPath.size();

        // Split path into Head and NextEdge
        for (int i = 0; i < maxIndex; i++) {
            List<E> head = curShortestPath.subList(0, i /* excluded */);
            V deviation = head.isEmpty() ? source : graph.getDest(head
                    .get(i - 1));

            // 1. Block edges.
            Graph<V, E> blocked = blockFilter(head, deviation, found_paths);

            // 2. Get shortest path in graph with blocked edges.
            blockedDijkstra = new DijkstraShortestPath<V, E>(blocked, nev);

            Number dist = blockedDijkstra.getDistance(deviation, target);
            if (dist == null)
                continue;

            List<E> tail = blockedDijkstra.getPath(deviation, target);

            // 3. Combine head and tail into new path.
            List<E> candidate = new ArrayList<E>(i + tail.size());
            candidate.addAll(head);
            candidate.addAll(tail);

            // Check if we already found this solution
            boolean duplicate = false;
            for (WeightedPath path : prioQ)
                if (ListUtils.isEqualList(path.getPath(), candidate)) {
                    duplicate = true;
                    break;
                }

            if (!duplicate)
                prioQ.add(new WeightedPath(candidate));
        }

        if (prioQ.isEmpty())
            break; // We have not found any new candidate!
        else
            found_paths.add(prioQ.poll().getPath());
    }

    return found_paths;
}
 
开发者ID:liruixpc11,项目名称:crucian,代码行数:63,代码来源:Yen.java


示例5: findTwoWays

import org.apache.commons.collections15.ListUtils; //导入依赖的package包/类
/**
 * Combines two disjoint paths from two SuurballeTarjan input paths.
 *
 * @param path1 Dijkstra shortest path
 * @param path2 Dijkstra shortest path in partly reverted graph
 * @return the two disjoint paths
 */
private List<List<E>> findTwoWays(List<E> path1, List<E> path2) {
    final V source = graph.getSource(path1.get(0));
    final V target = graph.getDest(path1.get(path1.size() - 1));

    // Remove common links.
    Iterator<E> it1 = path1.iterator();
    while (it1.hasNext()) {
        E e1 = it1.next();

        Iterator<E> it2 = path2.iterator();
        while (it2.hasNext()) {
            E e2 = it2.next();

            // ensure disjointness
            if (comparator.compare(e1, e2) == 0) { // for multigraph
                if (graph.isSource(source, e1)
                        || graph.isSource(source, e2)
                        || graph.isDest(target, e1)
                        || graph.isDest(target, e2))
                    return null; // Removing required edge

                it1.remove();
                it2.remove();
                break; // inner loop
            }
        }
    }

    if (path1.isEmpty() || path2.isEmpty())
        return null; // no disjoint solution found

    // Now recombine the two paths.
    List<E> union = ListUtils.union(path1, path2); // concatenate

    List<E> p1 = recombinePaths(path1, target, union);
    if (p1 == null)
        return null;

    List<E> p2 = recombinePaths(path2, target, union);
    if (p2 == null)
        return null;

    if (!union.isEmpty())
        throw new AssertionError("BUG");

    List<List<E>> solution = new LinkedList<List<E>>();
    solution.add(p1);
    solution.add(p2);
    return solution;
}
 
开发者ID:liruixpc11,项目名称:crucian,代码行数:58,代码来源:SuurballeTarjan.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RollingUpgradeAction类代码示例发布时间:1970-01-01
下一篇:
Java AppProperties类代码示例发布时间:1970-01-01
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap