import java.io.PrintStream; class BoxedList_double_3d_ { private List_double_3d_ l = null; public BoxedList_double_3d_() { } public BoxedList_double_3d_(double [3d] x) { push(x); } public void push(double [3d] item) { l = new List_double_3d_(item, l); } public double [3d] pop() { double [3d] t = l.first(); l = l.rest(); return t; } public double [3d] first() { return l.first(); } public List_double_3d_ toList() { return l; } // Destructive append. public BoxedList_double_3d_ concat(BoxedList_double_3d_ x) { if (l == null) l = x.l; else if (x != null) l.concat(x.l); return this; } public double [1d] [3d] toArray() { double [1d] [3d] a = new double [[0 : length() - 1]] [3d]; int i = 0; for (List_double_3d_ r = l; r != null; r = r.rest()) { a[i] = r.first(); i++; } return a; } public double [1d] [3d] toReversedArray() { int i = length(); double [1d] [3d] a = new double [[0 : i - 1]] [3d]; for (List_double_3d_ r = l; r != null; r = r.rest()) { a[--i] = r.first(); } return a; } public boolean isEmpty() { return l == null; } public int length() { return l == null ? 0 : l.length(); } }