Sim hash free #1

Merged
Berack96 merged 20 commits from sim-hash-free into main 2025-02-11 14:30:15 +01:00
2 changed files with 7 additions and 35 deletions
Showing only changes of commit 5aedd25c5f - Show all commits

View File

@@ -146,20 +146,6 @@ public final class Net implements Iterable<ServerNode> {
return this.servers.get(index);
}
/**
* Get one of the child nodes from the parent specified.
* If the node has no child then null is returned.
*
* @param parent the parent node
* @param rng the random number generator used for getting one of the child
* @return the resultig node
*/
public ServerNode getChildOf(ServerNode parent, Rng rng) {
var index = this.indices.get(parent);
index = this.getChildOf(index, rng);
return index < 0 ? null : this.servers.get(index);
}
/**
* Get one of the child nodes from the parent specified. If the index is out of
* bounds then an exception is thrown. If the node has no child then -1 is
@@ -180,18 +166,6 @@ public final class Net implements Iterable<ServerNode> {
return -1;
}
/**
* Get a list of all the children of the parent.
* In the list there is the node and the weight associated with.
*
* @param parent the parent node
* @return the list of children
*/
public List<NetChild> getChildren(ServerNode parent) {
var index = this.indices.get(parent);
return this.getChildren(index);
}
/**
* Get a list of all the children of the parent.
* In the list there is the node and the weight associated with.

View File

@@ -2,6 +2,8 @@ package net.berack.upo.valpre.sim;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.HashSet;
@@ -152,20 +154,16 @@ public class TestSimulation {
var sample = net.getChildOf(0, rigged);
assertEquals(1, sample);
var sample2 = net.getChildOf(node, rigged);
assertEquals(node1, sample2);
assertEquals(node1, net.getNode(sample));
}
@Test
public void nodeState() {
var net = new Net();
var node = ServerNode.createQueue("First", 1, const0);
net.addNode(node);
var state = new ServerNodeState(0, net);
var state = new ServerNodeState(1, simpleNet);
assertEquals(0, state.index);
assertEquals(net, state.net);
assertEquals(node, state.node);
assertEquals(1, state.index);
assertEquals(simpleNet, state.net);
assertEquals(node1, state.node);
assertEquals(0, state.numServerBusy);
assertEquals(0, state.numServerUnavailable);
assertEquals(0, state.queue.size());