@Test public void testSortedArrivals() { network.send(m, 1, n0, Arrays.asList(n1, n2, n3)); Envelope<?> m = network.msgs.peekFirst(); Assert.assertNotNull(m); HashSet<Integer> dests = new HashSet<>(Arrays.asList(1, 2, 3)); int l = m.nextArrivalTime(network); Assert.assertTrue(dests.contains(m.getNextDestId())); dests.remove(m.getNextDestId()); m.markRead(); Assert.assertTrue(m.hasNextReader()); Assert.assertTrue(m.nextArrivalTime(network) >= l); Assert.assertTrue(dests.contains(m.getNextDestId())); dests.remove(m.getNextDestId()); l = m.nextArrivalTime(network); m.markRead(); Assert.assertTrue(m.hasNextReader()); Assert.assertTrue(m.nextArrivalTime(network) >= l); Assert.assertTrue(dests.contains(m.getNextDestId())); m.markRead(); Assert.assertFalse(m.hasNextReader()); }
public void send(Message<? extends TN> m, TN fromNode, List<TN> dests) { if (dests == null || dests.isEmpty()) { return; } if (dests.size() == 1) { send(m, time + 1, fromNode, dests.get(0)); } else { send(m, time + 1, fromNode, dests); } }
Network { public void send(Message<? extends TN> m, TN fromNode, List<TN> dests) { if (dests == null || dests.isEmpty()) { return; } if (dests.size() == 1) { send(m, time + 1, fromNode, dests.get(0)); } else { send(m, time + 1, fromNode, dests); } } }
Network { public void send(Message<? extends TN> m, TN fromNode, List<TN> dests) { if (dests == null || dests.isEmpty()) { return; } if (dests.size() == 1) { send(m, time + 1, fromNode, dests.get(0)); } else { send(m, time + 1, fromNode, dests); } }  }
Network { public void send(Message<? extends TN> m, TN fromNode, List<TN> dests) { if (dests == null || dests.isEmpty()) { return; } if (dests.size() == 1) { send(m, time + 1, fromNode, dests.get(0)); } else { send(m, time + 1, fromNode, dests); } }  static BitSet chooseBadNodes(Random rd, int nodeCount, int nodesDown); BitSet getDeadNodes(); TN getNodeById(int id); TN getFirstLiveNode(); void printSpeedDistribution(int segmentCt); @SuppressWarnings("UnusedReturnValue") Network<TN> setMsgDiscardTime(int l); void run(int seconds); void runH(int hours); boolean runMs(int ms); void sendAll(Message<? extends TN> m, int sendTime, TN fromNode); void sendAll(Message<? extends TN> m, TN fromNode); void send(Message<? extends TN> m, TN fromNode, List<TN> dests); void send(Message<? extends TN> m, TN fromNode, TN toNode); void send(Message<? extends TN> mc, int sendTime, TN fromNode, TN toNode); void sendArriveAt(Message<? extends TN> mc, int arriveAt, TN fromNode, TN toNode); boolean hasMessage(); void send(Message<? extends TN> m, int sendTime, TN fromNode, List<? extends Node> dests); void send(
      Message<? extends TN> m,
      int sendTime,
      TN fromNode,
      List<? extends Node> dests,
      int delaysBetweenMessage); static int getPseudoRandom(int nodeId, int randomSeed); void registerTask(final Runnable task, int startAt, TN fromNode); void registerPeriodicTask(final Runnable task, int startAt, int period, TN fromNode); void registerPeriodicTask(
      final Runnable task, int startAt, int period, TN fromNode, Condition c); void registerConditionalTask(
      final Runnable task,
      int startAt,
      int duration,
      TN fromNode,
      Condition startIf,
      Condition repeatIf); void addNode(TN node); List<TN> liveNodes(); Network<TN> setNetworkLatency(int[] distribProp, int[] distribVal); Network<TN> setNetworkLatency(NetworkLatency networkLatency); void printNetworkLatency(); void partition(float part); void endPartition(); }
Network { public void send(Message<? extends TN> m, TN fromNode, List<TN> dests) { if (dests == null || dests.isEmpty()) { return; } if (dests.size() == 1) { send(m, time + 1, fromNode, dests.get(0)); } else { send(m, time + 1, fromNode, dests); } }  static BitSet chooseBadNodes(Random rd, int nodeCount, int nodesDown); BitSet getDeadNodes(); TN getNodeById(int id); TN getFirstLiveNode(); void printSpeedDistribution(int segmentCt); @SuppressWarnings("UnusedReturnValue") Network<TN> setMsgDiscardTime(int l); void run(int seconds); void runH(int hours); boolean runMs(int ms); void sendAll(Message<? extends TN> m, int sendTime, TN fromNode); void sendAll(Message<? extends TN> m, TN fromNode); void send(Message<? extends TN> m, TN fromNode, List<TN> dests); void send(Message<? extends TN> m, TN fromNode, TN toNode); void send(Message<? extends TN> mc, int sendTime, TN fromNode, TN toNode); void sendArriveAt(Message<? extends TN> mc, int arriveAt, TN fromNode, TN toNode); boolean hasMessage(); void send(Message<? extends TN> m, int sendTime, TN fromNode, List<? extends Node> dests); void send(
      Message<? extends TN> m,
      int sendTime,
      TN fromNode,
      List<? extends Node> dests,
      int delaysBetweenMessage); static int getPseudoRandom(int nodeId, int randomSeed); void registerTask(final Runnable task, int startAt, TN fromNode); void registerPeriodicTask(final Runnable task, int startAt, int period, TN fromNode); void registerPeriodicTask(
      final Runnable task, int startAt, int period, TN fromNode, Condition c); void registerConditionalTask(
      final Runnable task,
      int startAt,
      int duration,
      TN fromNode,
      Condition startIf,
      Condition repeatIf); void addNode(TN node); List<TN> liveNodes(); Network<TN> setNetworkLatency(int[] distribProp, int[] distribVal); Network<TN> setNetworkLatency(NetworkLatency networkLatency); void printNetworkLatency(); void partition(float part); void endPartition(); final MessageStorage msgs; final List<ConditionalTask<TN>> conditionalTasks; final List<TN> allNodes; final Random rd; public NetworkLatency networkLatency; public int time; }