The IntListListOps class contains some commonly used auxiliary class methods
that manipulate lists of integer lists.
All of these can easily be written in terms of the class methods from
the IntListList contract; they are provided here for convenience.
Also for convenience, the IntListListOps class also supplies all
of the IntListList class methods.
By default, an IntListListOps class method is invoked via
IntListListOps.methodName(args), but this can
be abbreviated to ILL.methodName(args)
by including the following "magical" declaration in the body
of a class:
public static IntListListOps ILL; // declare but never initialize this variable.
Because IntListListOps includes both core IntListList
methods and auxiliary methods, the above declaration enables
using the prefix ILL. to access all of these class methods.
Class Methods
For convenience, the
public static IntListList append (IntListList L1, IntListList L2)
Returns an integer list whose length is the sum of the lengths ofL1andL2and whose elements are all the elements ofL1, in order, followed by all the elements ofL2, in order.
public static boolean equals (IntListList L1, IntListList L2)
ReturnstrueifL1andL2have the same length and the same elements in the same order (where sameness of elements is determined by theequalsmethod of theIntListclass); otherwise returnsfalse. Note that theequalsmethod behaves differently than==on lists, which determines if two list nodes were created by the same call toprepend. For instance, ifLis the list[[7,1,4],[6],[-3,-8]], thenL.equals(prepend(IntList.fromString("[7,1,4]"),tail(L)))istrue, butL == prepend(IntList.fromString("[7,1,4]"),tail(L))isfalse.
public static boolean isMember (IntList x, IntListList L)
Returnstrueifxis an element of listLandfalseotherwise. Equality of elements is determined by theequalsmethod of theIntListclass.
public static int length (IntListList L)
Returns the length ofL-- i.e., the number of non-empty list nodes inL.
public static IntListList postpend (IntListList L, IntList x)
Returns a list whose length is one more than the length ofLand whose elements are all the elements ofL, in order, followed byx.
public static IntListList reverse (IntListList L)
Returns a list whose length is the same as that asLand whose elements are all the elements ofLin reverse order.
public static void prettyPrint (IntListList L)
Display a printed representation ofLin which each integer list element appears on its own line.
IntListListOps class also provides all the
class methods of the IntListList class:
public static IntListList empty() public static IntListList prepend (IntList x, IntListList L) public static boolean isEmpty (IntListList L) public static IntList head (IntListList L) public static IntListList tail (IntListList L) public static String toString (IntListList L) public static IntListList fromString (String s)