Tommy Rogers c9333667ca completed lab | преди 6 години | |
---|---|---|
src | преди 6 години | |
.gitignore | преди 7 години | |
README.md | преди 7 години | |
pom.xml | преди 7 години |
The microlabs for the Generics chapter are all grouped together. So, you need to work through them package by package. The following list is the package name followed by a quick description of the assignment.
Stack<E>
to use an ArrayList as a stack. You need to make the push
, pop
, and
isEmpty
functions.Stack<E>
to use an array as a stack. You'll need to potentially grow the array in the
push
method. Do this first with an E[]
array, and then again with an Object[]
array. Both should compile
without warnings and pass the tests.get
which takes a key and returns either the entry from the ArrayList with that key, or null if none is found.put
which takes a key and value and sets the value in the ArrayList to Entry(key, value);
remove
which takes a key and removes it from the ArrayList if it's in there. It's a void method; no return type.superCombiner
and extendCombiner
, which each take two arraylists and append
all of the items from the second to the first. superCombiner
should use ? super E
and extendCombiner
should use
? extends E
.map
method that takes an ArrayList and a Function<T,R>
object and returns an arraylist
containing all of the elements of the first with the function applied to them.E
.
min
and max
, that return the largest and smallest of the Pair
.Arrays
and, in that, create a method
public static <___> Pair<E> firstLast(ArrayList<___> a)
<___>
is there because you
need to fill in the blank.Arrays
make two methods, min
and max
that returns the smallest and largest elements in the ArrayList.Arrays
make a minMax
function that returns a Pair
with the minimum and maximum values of the ArrayList.