Code example for Vector

Methods: add, lastElement, size

0
 
		Vector<NumberedTimePeriod> periods = map.get(mmsi);
 
		if (periods == null)
		{ 
			periods = new Vector<NumberedTimePeriod>();
			map.put(mmsi, periods);
		} 
 
		NumberedTimePeriod timeP = null;
 
		if (periods.size() > 0)
		{ 
			timeP = periods.lastElement();
			Date lastTime = timeP.getEndDTG().getDate();
 
 
			// is it too far back? 
			long delta = date2.getTime() - lastTime.getTime();
			if (delta < 1000 * 60 * 30)
			{ 
				// cool, in period. extend it 
				timeP.setEndDTG(new HiResDate(date2));
			} 
			else 
			{ 
				// naah, too late. put it in another time period 
				timeP = null;
				 
				if (name2.contains("ALBE"))
				{ 
					if (timeP == null)
						System.out.println("time:" + date2 + " state:" + timeP == null);
				} 
			} 
 
		} 
 
		if (timeP == null)
		{ 
			// ok, create a new period for this time 
			timeP = new NumberedTimePeriod(new HiResDate(date2), name2);
			periods.add(timeP);
		} 
 
		// increment his counter 
		timeP.increment();