本文整理汇总了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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}