public static double Average(ArrayList l) { double accum = 0.0d; Iterator i = l.iterator(); while (i.hasNext()) { Double d = (Double) i.next(); accum += d.doubleValue(); } return (accum / (double) l.size()); }
public static String PrintList(ArrayList l) { StringBuffer sb = new StringBuffer("[ "); Iterator i = l.iterator(); while (i.hasNext()) { Double d = (Double) i.next(); sb.append(MDP._df.format(d.doubleValue()) + " "); } sb.append("]"); return sb.toString(); }
public static String PrintState(ArrayList state) { StringBuffer sb = new StringBuffer(); Iterator i = state.iterator(); while (i.hasNext()) { Object o = i.next(); if (o instanceof Boolean) { Boolean val = (Boolean) o; sb.append((val.booleanValue() ? "." : "X")); } } return sb.toString(); }
public void draw() { if (_pointLists.size() <= 0) return; pushStyle(); noFill(); PVector vec; PVector firstVec; PVector screenPos = new PVector(); int colorIndex = 0; // draw the hand lists Iterator<Map.Entry> itrList = _pointLists.entrySet().iterator(); while (itrList.hasNext()) { strokeWeight(2); stroke(_colorList[colorIndex % (_colorList.length - 1)]); ArrayList curList = (ArrayList) itrList.next().getValue(); // draw line firstVec = null; Iterator<PVector> itr = curList.iterator(); beginShape(); while (itr.hasNext()) { vec = itr.next(); if (firstVec == null) firstVec = vec; // calc the screen pos context.convertRealWorldToProjective(vec, screenPos); vertex(screenPos.x, screenPos.y); } endShape(); // draw current pos of the hand if (firstVec != null) { strokeWeight(8); context.convertRealWorldToProjective(firstVec, screenPos); point(screenPos.x, screenPos.y); } colorIndex++; } popStyle(); }