-
Recent Posts
Recent Comments
- R.P. Churchill on TWSL Series 07: Discovery and Data Collection
- R.P. Churchill on A Simulationist’s Framework for Business Analysis: Round Two
- LN on A Simulationist’s Framework for Business Analysis: Round Two
- R.P. Churchill on Starting to Learn About the Java Memory Model
- R.P. Churchill on Multidimensional Arrays in Javascript
Categories
Meta
Daily Archives: September 8, 2016
A Simple Discrete-Event Simulation: Part 7
Today we’ll do some more streamlining. We’ll start by adding a new function to the futureEventsQueue object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
this.newItem = function(time,entity) { //create futureEventItem var feqItem = new futureEventItem(time,"absolute",entity); this.insertTime = feqItem.getActivationTime(); globalInsertTime = this.insertTime; if (this.feqSize == 0) { this.feq[0] = feqItem; this.feqSize++; console.log("Array size: "+this.feq.length); } else { //find index of feq item to insert before var insertIndex = this.feq.findIndex(this.findLaterTime); //insert the element if (insertIndex < 0) { insertIndex = this.feq.length; } this.feq.splice(insertIndex,0,feqItem); this.feqSize++; console.log("Array size: "+this.feq.length); } }; |
Then, instead of having to specify the “absolute” (vs. “advance”) flag in the initialization of a new entity object, we know we’ll … Continue reading