diff options
Diffstat (limited to 'opendc-core')
3 files changed, 9 insertions, 17 deletions
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/omega/OmegaSimulator.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/omega/OmegaSimulator.kt index c5740210..dc3c0d0f 100644 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/omega/OmegaSimulator.kt +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/omega/OmegaSimulator.kt @@ -72,7 +72,7 @@ class OmegaSimulator(override val topology: Topology) : Simulator, Iterator<Unit init { topology.forEach { node -> resolve(node) - node.outgoingEdges().forEach { resolve(it) } + node.outgoingEdges.forEach { resolve(it) } } registry.values.forEach { context -> diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/AdjacencyList.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/AdjacencyList.kt index 50f8fa0c..28154695 100644 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/AdjacencyList.kt +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/AdjacencyList.kt @@ -105,13 +105,9 @@ internal class AdjacencyListTopology: MutableTopology { override fun iterator(): MutableIterator<Node<*>> = nodes.iterator() internal inner class AdjacencyListNode<out T: Entity<*>>(override val id: Int, override val label: T): Node<T> { - internal var ingoingEdges: MutableSet<Edge<*>> = HashSet() - internal var outgoingEdges: MutableSet<Edge<*>> = HashSet() - - override fun ingoingEdges(): Set<Edge<*>> = ingoingEdges - override fun outgoingEdges(): Set<Edge<*>> = outgoingEdges + override var ingoingEdges: MutableSet<Edge<*>> = HashSet() + override var outgoingEdges: MutableSet<Edge<*>> = HashSet() override fun toString(): String = label.toString() - internal fun validate(instance: AdjacencyListTopology) = this@AdjacencyListTopology == instance } diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Node.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Node.kt index c21fd088..ee1cde9b 100644 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Node.kt +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Node.kt @@ -39,18 +39,14 @@ interface Node<out T: Entity<*>>: Component<T> { val id: Int /** - * Return the set of ingoing edges of this node. - * - * @return All edges whose destination is this node. + * The set of ingoing edges of this node. */ - fun ingoingEdges(): Set<Edge<*>> + val ingoingEdges: Set<Edge<*>> /** - * Return the set of outgoing edges of this node. - * - * @return All edges whose source is this node. + * The set of outgoing edges of this node. */ - fun outgoingEdges(): Set<Edge<*>> + val outgoingEdges: Set<Edge<*>> /** * The [Entity] this node represents within a logical topology of a cloud network. @@ -67,7 +63,7 @@ interface Node<out T: Entity<*>>: Component<T> { * @return The entities of all edges whose destination is this node and have the given tag. */ inline fun <reified T> Node<*>.ingoing(tag: String) = - ingoingEdges().filter { it.tag == tag }.map { it.to.entity as T }.toSet() + ingoingEdges.filter { it.tag == tag }.map { it.to.entity as T }.toSet() /** @@ -78,4 +74,4 @@ inline fun <reified T> Node<*>.ingoing(tag: String) = * @return The entities of all edges whose source is this node and have the given tag. */ inline fun <reified T> Node<*>.outgoing(tag: String) = - outgoingEdges().filter { it.tag == tag }.map { it.to.entity as T }.toSet() + outgoingEdges.filter { it.tag == tag }.map { it.to.entity as T }.toSet() |
