116 blockMap.put(block, list);
117 }
118 return list;
119 }
120
121 public List<UseEntry> getUsages(AbstractBlockBase<?> block) {
122 List<UseEntry> list = blockMap.get(block);
123 if (list == null) {
124 return Collections.emptyList();
125 }
126 return Collections.unmodifiableList(list);
127 }
128
129 /**
130 * Returns the cost object associated with {@code block}. If there is none, a new cost object is
131 * created.
132 */
133 NodeCost getOrInitCost(AbstractBlockBase<?> block) {
134 NodeCost cost = getCost(block);
135 if (cost == null) {
136 cost = new NodeCost(block.probability(), blockMap.get(block), 1);
137 setCost(block, cost);
138 }
139 return cost;
140 }
141
142 @Override
143 public String getName(Flags type) {
144 switch (type) {
145 case USAGE:
146 return "hasUsage";
147 case SUBTREE:
148 return "inSubtree";
149 case MATERIALIZE:
150 return "materialize";
151 case CANDIDATE:
152 return "candidate";
153 }
154 return super.getName(type);
155 }
156
|
116 blockMap.put(block, list);
117 }
118 return list;
119 }
120
121 public List<UseEntry> getUsages(AbstractBlockBase<?> block) {
122 List<UseEntry> list = blockMap.get(block);
123 if (list == null) {
124 return Collections.emptyList();
125 }
126 return Collections.unmodifiableList(list);
127 }
128
129 /**
130 * Returns the cost object associated with {@code block}. If there is none, a new cost object is
131 * created.
132 */
133 NodeCost getOrInitCost(AbstractBlockBase<?> block) {
134 NodeCost cost = getCost(block);
135 if (cost == null) {
136 cost = new NodeCost(block.getRelativeFrequency(), blockMap.get(block), 1);
137 setCost(block, cost);
138 }
139 return cost;
140 }
141
142 @Override
143 public String getName(Flags type) {
144 switch (type) {
145 case USAGE:
146 return "hasUsage";
147 case SUBTREE:
148 return "inSubtree";
149 case MATERIALIZE:
150 return "materialize";
151 case CANDIDATE:
152 return "candidate";
153 }
154 return super.getName(type);
155 }
156
|