Package it.unimi.di.prog2.h23
Class ListUtils
java.lang.Object
it.unimi.di.prog2.h23.ListUtils
A class providing some utility methods for lists.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A subtype ofListUtils.PositiveIntBox
that can be created from negative ints.static class
A box containing a positive integer. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Comparable<T>>
TalmostRightMax
(List<T> lst) Returns the maximum element in a list.static void
A method to test the code in this classstatic <T extends Comparable<? super T>>
TReturns the maximum element in a list.
-
Constructor Details
-
ListUtils
private ListUtils().
-
-
Method Details
-
almostRightMax
Returns the maximum element in a list.This implementation has an issue with subclasses.
- Type Parameters:
T
- the type of the elements in the list.- Parameters:
lst
- the list.- Returns:
- the maximum element in
lst
. - Throws:
NullPointerException
- iflst
isnull
.
-
max
Returns the maximum element in a list.- Type Parameters:
T
- the type of the elements in the list.- Parameters:
lst
- the list.- Returns:
- the maximum element in
lst
. - Throws:
NullPointerException
- iflst
isnull
.
-
main
A method to test the code in this class- Parameters:
args
- unused.
-