Package it.polimi.ingsw.utils.multilist
Class MultiList<T extends Comparable<T>,U,V>
java.lang.Object
it.polimi.ingsw.utils.multilist.MultiList<T,U,V>
- Type Parameters:
T- first element typeU- second element typeV- third element type
Implements a list whose elements are tuples of 3 elements
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the tuple to the multi-listfilter(MultiListPredicate<T, U, V> predicate) voidforEach(MultiListProcedure<T, U, V> procedure) Applies the procedure to each tuple in the multi-listgetFirst(int index) getSecond(int index) getThird(int index) voidRemoves the first occurrence of a tuple whose first element is equal to the specified oneintsize()
-
Field Details
-
first
-
second
-
third
-
-
Constructor Details
-
MultiList
public MultiList()
-
-
Method Details
-
getFirst
- Parameters:
index- index of the element to return- Returns:
- the first element of the tuple at the specified position
- Throws:
IndexOutOfBoundsException- if index is out of range (index invalid input: '<' 0 || index >= size())
-
getSecond
- Parameters:
index- index of the element to return- Returns:
- the second element of the tuple at the specified position
- Throws:
IndexOutOfBoundsException- if index is out of range (index invalid input: '<' 0 || index >= size())
-
getThird
- Parameters:
index- index of the element to return- Returns:
- the third element of the tuple at the specified position
- Throws:
IndexOutOfBoundsException- if index is out of range (index invalid input: '<' 0 || index >= size())
-
add
Adds the tuple to the multi-list- Parameters:
first- first element of the tuplesecond- second element of the tuplethird- third element of the tuple
-
remove
Removes the first occurrence of a tuple whose first element is equal to the specified one- Parameters:
firstKey- the first element of the tuple to remove
-
size
public int size()- Returns:
- the number of tuples in the multi-list
-
filter
- Parameters:
predicate- a predicate that takes a tuple as input- Returns:
- a multi-list containing the elements of this list that make the predicate true
-
forEach
Applies the procedure to each tuple in the multi-list- Parameters:
procedure- a procedure that takes a tuple as input
-