Question: //implement method only for to do section. import java.util.function.BiFunction; import java.util.function.Function; class EmptyListE extends Exception {} //------------------------------------------------------------- /** * This is persistent implementation. * After
//implement method only for to do section. import java.util.function.BiFunction; import java.util.function.Function;
class EmptyListE extends Exception {}
//-------------------------------------------------------------
/** * This is persistent implementation. * After a list is created, it is never updated * * See the test cases for examples */ abstract class List
/** * Computes the length of the list */ abstract int length();
/** * Checks if the given elem occurs in the list * (Use .equals() to check for equality) */ abstract boolean inList(E elem);
/** * Inserts newElem after every occurrence of elem */ abstract List
/** * Removes the first occurrence of elem (if * there is one) */ abstract List
/** * Returns the 0-based index of elem in the list * If the element is not in the list, throw * an exception */ abstract int indexOf (E elem) throws EmptyListE;
/** * Returns a new list that only contains the * elements satisfying the given predicate */ abstract List
/** * Returns a new list in which every element * is transformed using the given function */ abstract
/** * Starting with base as the current result, * repeatedly applies the bifunction f to the * current result and one element from the list */ abstract
/** * Appends the given list at the end of the * current list */ abstract List
/** * Use to accumulate the reverse of the given list */ abstract List
/** * Returns a big list containing all the sublists of * the current list */ abstract List> powerSet ();
List
//-------------------------------------------------------------
class EmptyL
int length() { return 0; // TODO }
boolean inList(E elem) { return false; // TODO }
List
List
int indexOf(E elem) throws EmptyListE { return 0; // TODO }
List
List
List
List> powerSet() { return null; // TODO }
public boolean equals (Object o) { return o instanceof EmptyL; } }
//-------------------------------------------------------------
class NodeL
NodeL (E first, List
int length() { return 0; // TODO }
boolean inList(E elem) { return false; // TODO }
List
List
int indexOf(E elem) throws EmptyListE { return 0; // TODO }
List
List
List
List> powerSet() { return null; // TODO }
public boolean equals (Object o) { if (o instanceof NodeL) { NodeL
// //
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
