Rev | Line | |
---|
[31] | 1 | /************************************************************************************ |
---|
| 2 | * Copyright (C) 2008 by Politehnica University of Bucharest and Rutgers University |
---|
| 3 | * All rights reserved. |
---|
| 4 | * Refer to LICENSE for terms and conditions of use. |
---|
| 5 | ***********************************************************************************/ |
---|
| 6 | package vnsim.vehicular.generator; |
---|
| 7 | |
---|
| 8 | import java.util.*; |
---|
| 9 | |
---|
| 10 | public class EntryFlowVariation { |
---|
| 11 | |
---|
| 12 | //sorted by time |
---|
| 13 | |
---|
| 14 | ArrayList<Integer> times; //simulation time |
---|
| 15 | ArrayList<Integer> flow; |
---|
| 16 | |
---|
| 17 | public EntryFlowVariation(){ |
---|
| 18 | times=new ArrayList<Integer> (); |
---|
| 19 | flow=new ArrayList<Integer> (); |
---|
| 20 | } |
---|
| 21 | |
---|
| 22 | public int getFirstValue() { |
---|
| 23 | if(flow.size()<0) |
---|
| 24 | return -1; |
---|
| 25 | return flow.get(0); |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | public void removeFirst() { |
---|
| 29 | times.remove(0); |
---|
| 30 | flow.remove(0); |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | public int getFirstMom() { |
---|
| 34 | if(times.size()==0) |
---|
| 35 | return -1; |
---|
| 36 | return times.get(0); |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | public void add(int mom, int val) { |
---|
| 40 | if(times.size()>0) { |
---|
| 41 | int last=times.get(times.size()-1); |
---|
| 42 | if(mom<last) { |
---|
| 43 | System.err.println("WARNING! Skipped adding time = "+mom+" NOT LAST!"); |
---|
| 44 | return; |
---|
| 45 | } |
---|
| 46 | } |
---|
| 47 | times.add(mom); |
---|
| 48 | flow.add(val); |
---|
| 49 | } |
---|
| 50 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.