summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
ddf8558)
Pre-allocating the result list saves us the common case when
the input is actually empty.
Change-Id: I237a75db38e8e0c160b204875bc5824433e9c3dc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
throw new IllegalArgumentException("Set of Type Definitions cannot be NULL!");
}
throw new IllegalArgumentException("Set of Type Definitions cannot be NULL!");
}
- final List<GroupingDefinition> resultGroupingDefinitions = new ArrayList<>();
- final Set<Node> unsorted = groupingDefinitionsToNodes(groupingDefinitions);
- final List<Node> sortedNodes = TopologicalSort.sort(unsorted);
+ final List<Node> sortedNodes = TopologicalSort.sort(groupingDefinitionsToNodes(groupingDefinitions));
+ final List<GroupingDefinition> resultGroupingDefinitions = new ArrayList<>(sortedNodes.size());
for (Node node : sortedNodes) {
NodeWrappedType nodeWrappedType = (NodeWrappedType) node;
resultGroupingDefinitions.add((GroupingDefinition) nodeWrappedType.getWrappedType());
for (Node node : sortedNodes) {
NodeWrappedType nodeWrappedType = (NodeWrappedType) node;
resultGroupingDefinitions.add((GroupingDefinition) nodeWrappedType.getWrappedType());
* For every uses node is found its wrapping node (next as <i>nodeTo</i>). This dependency relationship between
* nodeFrom and all found nodesTo is modeled with creating of one edge from nodeFrom to nodeTo.
*
* For every uses node is found its wrapping node (next as <i>nodeTo</i>). This dependency relationship between
* nodeFrom and all found nodesTo is modeled with creating of one edge from nodeFrom to nodeTo.
*
- * @param groupingDefinitions set of goruping definition which will be wrapped to nodes
+ * @param groupingDefinitions set of grouping definition which will be wrapped to nodes
* @return set of nodes where every one contains wrapped grouping definition
*/
private Set<Node> groupingDefinitionsToNodes(final Collection<GroupingDefinition> groupingDefinitions) {
* @return set of nodes where every one contains wrapped grouping definition
*/
private Set<Node> groupingDefinitionsToNodes(final Collection<GroupingDefinition> groupingDefinitions) {