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 type
U - second element type
V - third element type

public class MultiList<T extends Comparable<T>,U,V> extends Object
Implements a list whose elements are tuples of 3 elements
  • Field Details

    • first

      private final List<T extends Comparable<T>> first
    • second

      private final List<U> second
    • third

      private final List<V> third
  • Constructor Details

    • MultiList

      public MultiList()
  • Method Details

    • getFirst

      public T getFirst(int index)
      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

      public U getSecond(int index)
      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

      public V getThird(int index)
      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

      public void add(T first, U second, V third)
      Adds the tuple to the multi-list
      Parameters:
      first - first element of the tuple
      second - second element of the tuple
      third - third element of the tuple
    • remove

      public void remove(T firstKey)
      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

      public MultiList<T,U,V> filter(MultiListPredicate<T,U,V> predicate)
      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

      public void forEach(MultiListProcedure<T,U,V> procedure)
      Applies the procedure to each tuple in the multi-list
      Parameters:
      procedure - a procedure that takes a tuple as input