Skip to content

Commit

Permalink
Merge branch 'linked_hash_set_in_componentsymbol' into 'dev'
Browse files Browse the repository at this point in the history
use LinkedHashSet in ComponentSymbol to get deterministic iterator

See merge request monticore/monticore!911
  • Loading branch information
Sebastian Stüber committed Nov 24, 2023
2 parents d927f2a + caae71b commit 0f22e17
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -185,12 +185,12 @@ public List<PortSymbol> getPorts(boolean incoming, boolean outgoing) {
* @return a {@code Set} of all ports of this component
*/
public Set<PortSymbol> getAllPorts() {
return this.getAllPorts(new HashSet<>());
return this.getAllPorts(new LinkedHashSet<>());
}

protected Set<PortSymbol> getAllPorts(Collection<ComponentSymbol> visited) {
visited.add(this);
Set<PortSymbol> result = new HashSet<>(this.getPortsList());
Set<PortSymbol> result = new LinkedHashSet<>(this.getPortsList());
for (CompKindExpression superComponent : this.getSuperComponentsList()) {
if (visited.contains(superComponent.getTypeInfo())) continue;
for (PortSymbol port : superComponent.getTypeInfo().getAllPorts(visited)) {
Expand All @@ -209,7 +209,7 @@ protected Set<PortSymbol> getAllPorts(Collection<ComponentSymbol> visited) {
* @return a {@code Set} of all incoming ports of this component
*/
public Set<PortSymbol> getAllIncomingPorts() {
Set<PortSymbol> result = new HashSet<>();
Set<PortSymbol> result = new LinkedHashSet<>();
for (PortSymbol port : this.getAllPorts()) {
if (port.isIncoming()) {
result.add(port);
Expand All @@ -224,7 +224,7 @@ public Set<PortSymbol> getAllIncomingPorts() {
* @return a {@code Set} of all outgoing ports of this component
*/
public Set<PortSymbol> getAllOutgoingPorts() {
Set<PortSymbol> result = new HashSet<>();
Set<PortSymbol> result = new LinkedHashSet<>();
for (PortSymbol port : this.getAllPorts()) {
if (port.isOutgoing()) {
result.add(port);
Expand All @@ -242,7 +242,7 @@ public Set<PortSymbol> getAllOutgoingPorts() {
* @return a {@code Set} of all ports of this component with the given direction
*/
public Set<PortSymbol> getAllPorts(boolean incoming, boolean outgoing) {
Set<PortSymbol> result = new HashSet<>();
Set<PortSymbol> result = new LinkedHashSet<>();
for (PortSymbol port : this.getAllPorts()) {
if (port.isIncoming() == incoming && port.isOutgoing() == outgoing) {
result.add(port);
Expand Down

0 comments on commit 0f22e17

Please sign in to comment.