// myQueue = internalCreate();
eles = 1000;
// The seed -7538847116595691071l caused a problem in one of the queues
// (with at least 1000 and 10000 eles)
IRandom rand = new JavaRandom(-7538847116595691071l);
for (int i = 0; i < eles; i++) {
myQueue.enqueue(new Object(), tim + rand.nextDouble());
}
// get the min
Double ti = myQueue.getMin();
// remember the queue size
long st = myQueue.size();
// take away t entries from the queue (all those with the time ti)
t = myQueue.dequeueAll();
assertTrue(st == myQueue.size() + t.size());
for (Object o : t) {
myQueue.enqueue(o, ti);
}
assertTrue(
"Size is " + myQueue.size() + " but should be " + st
+ ". Time value of elements " + ti + ". The random seed used: "
+ rand.getSeed(), myQueue.size() == st);
int rememberSize = t.size();
assertTrue("The queue should have as min time " + ti + " but it is "
+ myQueue.getMin(), myQueue.getMin().compareTo(ti) == 0);
// assertTrue(myQueue.size() == eles);
// Queue has eles elements in it
// add 10 elements with time time, thus together with the one already in
// there should be 11 at all
for (int i = 0; i < 10; i++) {
myQueue.enqueue(new NamedEntity("" + i), ti);
assertTrue("Size should be " + (eles + i + rememberSize) + " but is "
+ myQueue.size(), myQueue.size() == eles + i + rememberSize);
}
assertTrue("Size is " + myQueue.size() + " instead of " + eles + 10,
eles + 10 == myQueue.size());
// System.out.println("enqueued 10 elements with time "+ti+"\n"+
// myQueue+". Now there are "+myQueue.size()+" elements in the queue.");
t = myQueue.dequeueAll();
assertTrue(
"Size should be " + (eles - rememberSize) + " but is " + myQueue.size()
+ "\nThe min extracted:" + ti + "\nExtracted " + t.size()
+ " elements (" + t + ") with that time\n"
+ "The queue contains the following elements\n\n"
+ myQueue.toString(), myQueue.size() == eles - rememberSize);
assertTrue("dequeueAll should return " + (rememberSize + 10)
+ " elements but the method returned " + t.size()
+ ".\n The min value should be " + ti + "\nThe random seed used: "
+ rand.getSeed() + ". The queue contains \n" + myQueue.toString(),
t.size() == rememberSize + 10);
// elapsedTime = System.currentTimeMillis() - startTime;
// System.out.println("dequeueAll finished at " + elapsedTime);
}