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


Java OrderedHashSet类代码示例

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


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

示例1: sort

import org.antlr.v4.runtime.misc.OrderedHashSet; //导入依赖的package包/类
/** DFS-based topological sort.  A valid sort is the reverse of
 *  the post-order DFA traversal.  Amazingly simple but true.
 *  For sorting, I'm not following convention here since ANTLR
 *  needs the opposite.  Here's what I assume for sorting:
 *
 *    If there exists an edge u -> v then u depends on v and v
 *    must happen before u.
 *
 *  So if this gives nonreversed postorder traversal, I get the order
 *  I want.
 */
public List<T> sort() {
	Set<Node<T>> visited = new OrderedHashSet<Node<T>>();
	ArrayList<T> sorted = new ArrayList<T>();
	while ( visited.size() < nodes.size() ) {
		// pick any unvisited node, n
		Node<T> n = null;
		for (Node<T> tNode : nodes.values()) {
			n = tNode;
			if ( !visited.contains(n) ) break;
		}
		if (n!=null) { // if at least one unvisited
			DFS(n, visited, sorted);
		}
	}
	return sorted;
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:28,代码来源:Graph.java

示例2: addRulesToCycle

import org.antlr.v4.runtime.misc.OrderedHashSet; //导入依赖的package包/类
/** enclosingRule calls targetRule. Find the cycle containing
 *  the target and add the caller.  Find the cycle containing the caller
 *  and add the target.  If no cycles contain either, then create a new
 *  cycle.
 */
protected void addRulesToCycle(Rule enclosingRule, Rule targetRule) {
	//System.err.println("left-recursion to "+targetRule.name+" from "+enclosingRule.name);
	boolean foundCycle = false;
	for (Set<Rule> rulesInCycle : listOfRecursiveCycles) {
		// ensure both rules are in same cycle
		if (rulesInCycle.contains(targetRule)) {
			rulesInCycle.add(enclosingRule);
			foundCycle = true;
		}
		if (rulesInCycle.contains(enclosingRule)) {
			rulesInCycle.add(targetRule);
			foundCycle = true;
		}
	}
	if ( !foundCycle ) {
		Set<Rule> cycle = new OrderedHashSet<Rule>();
		cycle.add(targetRule);
		cycle.add(enclosingRule);
		listOfRecursiveCycles.add(cycle);
	}
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:27,代码来源:LeftRecursionDetector.java

示例3: subscribeComponentToIdentifier

import org.antlr.v4.runtime.misc.OrderedHashSet; //导入依赖的package包/类
/**
 * Subscribes given component to given identifier. If there are no subscriptions
 * yet for this identifier, an entry in the subscriptions map is created.
 *
 * @param formComponent the component to subscribe.
 * @param identifier    the identifier the given component should be
 *                      subscribed to.
 */
private void subscribeComponentToIdentifier(AbstractFormComponent formComponent,
                                            String identifier) {
    if (hasSubscriptionsForIdentifier(identifier)) {
        subscriptions.get(identifier).add(formComponent);
    } else {
        HashSet<AbstractFormComponent> subscribedComponents =
                new OrderedHashSet<AbstractFormComponent>();
        subscribedComponents.add(formComponent);
        subscriptions.put(identifier, subscribedComponents);
    }
}
 
开发者ID:software-engineering-amsterdam,项目名称:poly-ql,代码行数:20,代码来源:FormEventManager.java

示例4: FormFrameBuilder

import org.antlr.v4.runtime.misc.OrderedHashSet; //导入依赖的package包/类
private FormFrameBuilder(Form form, GUIController controller) {
    formComponents = new OrderedHashSet<AbstractFormComponent>();
    EvaluationVisitor evaluator = new EvaluationVisitor();
    FormEventManager eventManager = new FormEventManager(evaluator);
    formFrame = new FormFrame(form.getName(), evaluator, eventManager);
    AbstractFormComponent topComponent = form.getBody().accept(this);
    initValues();
    formFrame.initUI(topComponent, controller);
}
 
开发者ID:software-engineering-amsterdam,项目名称:poly-ql,代码行数:10,代码来源:FormFrameBuilder.java

示例5: addLocalDecl

import org.antlr.v4.runtime.misc.OrderedHashSet; //导入依赖的package包/类
/** Add local var decl */
public void addLocalDecl(Decl d) {
	if ( locals ==null ) locals = new OrderedHashSet<Decl>();
	locals.add(d);
	d.isLocal = true;
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:7,代码来源:RuleFunction.java

示例6: addLocalDecl

import org.antlr.v4.runtime.misc.OrderedHashSet; //导入依赖的package包/类
/** Add local var decl */
public void addLocalDecl(Decl d) {
	if ( locals==null ) locals = new OrderedHashSet<Decl>();
	locals.add(d);
	d.isLocal = true;
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:7,代码来源:CodeBlock.java


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