Class OrderedListCombiner
java.lang.Object
es.uam.eps.ir.relison.utils.listcombiner.OrderedListCombiner
public class OrderedListCombiner
extends java.lang.Object
Methods and algorithms for combining ordered lists.
-
Constructor Summary
Constructors Constructor Description OrderedListCombiner()
-
Method Summary
Modifier and Type Method Description static <T> boolean
intersectionHasElements(java.util.Iterator<T> firstList, java.util.Iterator<T> secondList, java.util.Comparator<T> comp)
Checks whether the intersection of two ordered lists is empty or not.static <T> boolean
intersectionHasElements(java.util.List<T> firstList, java.util.List<T> secondList, java.util.Comparator<T> comp)
Checks whether the intersection of two ordered lists is empty or not.static <T> boolean
intersectionHaslements(java.util.stream.Stream<T> firstList, java.util.stream.Stream<T> secondList, java.util.Comparator<T> comp)
Checks whether the intersection of two ordered lists is empty or not.static <T> java.util.List<T>
intersectLists(java.util.Iterator<T> firstIter, java.util.Iterator<T> secondIter, java.util.Comparator<T> comp, java.util.function.BiFunction<T,T,T> combiner)
Intersects two ordered streams/lists, represented by iterators, preserving the order.static <T> java.util.List<T>
intersectLists(java.util.List<T> firstList, java.util.List<T> secondList, java.util.Comparator<T> comp, java.util.function.BiFunction<T,T,T> combiner)
Intersects two ordered lists, preserving the order.static <T> java.util.List<T>
intersectLists(java.util.stream.Stream<T> firstStream, java.util.stream.Stream<T> secondStream, java.util.Comparator<T> comp, java.util.function.BiFunction<T,T,T> combiner)
Intersects two ordered streams, preserving the order.static <T> int
intersectListsSize(java.util.Iterator<T> firstIter, java.util.Iterator<T> secondIter, java.util.Comparator<T> comp)
Finds the size of the intersection of two ordered streams/lists.static <T> int
intersectListsSize(java.util.List<T> firstList, java.util.List<T> secondList, java.util.Comparator<T> comp)
Finds the size of the intersection of two ordered lists.static <T> int
intersectListsSize(java.util.stream.Stream<T> firstStream, java.util.stream.Stream<T> secondStream, java.util.Comparator<T> comp)
Finds the size of the intersection of two ordered streams.static <T> Pair<java.util.List<T>>
mergeAndIntersectLists(java.util.Iterator<T> firstIterator, java.util.Iterator<T> secondIterator, java.util.Comparator<T> comp, java.util.function.BiFunction<T,T,T> combiner)
Finds the union and intersection of two ordered streams/lists, represented by iterators, preserving the order.static <T> Pair<java.util.List<T>>
mergeAndIntersectLists(java.util.List<T> firstList, java.util.List<T> secondList, java.util.Comparator<T> comp, java.util.function.BiFunction<T,T,T> combiner)
Finds the union and intersection of two ordered lists, preserving the order.static <T> Pair<java.util.List<T>>
mergeAndIntersectLists(java.util.stream.Stream<T> firstList, java.util.stream.Stream<T> secondList, java.util.Comparator<T> comp, java.util.function.BiFunction<T,T,T> combiner)
Finds the union and intersection of two ordered streams, preserving the order.static <T> Pair<java.lang.Integer>
mergeAndIntersectListsSize(java.util.Iterator<T> firstIterator, java.util.Iterator<T> secondIterator, java.util.Comparator<T> comp)
Finds the union and intersection of two ordered streams/lists, represented by iterators, preserving the order.static <T> Pair<java.lang.Integer>
mergeAndIntersectListsSize(java.util.List<T> firstList, java.util.List<T> secondList, java.util.Comparator<T> comp)
Finds the union and intersection of two ordered lists, preserving the order.static <T> Pair<java.lang.Integer>
mergeAndIntersectListsSize(java.util.stream.Stream<T> firstList, java.util.stream.Stream<T> secondList, java.util.Comparator<T> comp)
Finds the union and intersection of two ordered streams, preserving the order.static <T> java.util.List<T>
mergeLists(java.util.Iterator<T> firstIterator, java.util.Iterator<T> secondIterator, java.util.Comparator<T> comp, java.util.function.BiFunction<T,T,T> combiner)
Merges two ordered lists/streams, represented by iterators, so that the order is preserved.static <T> java.util.List<T>
mergeLists(java.util.List<T> firstList, java.util.List<T> secondList, java.util.Comparator<T> comp, java.util.function.BiFunction<T,T,T> combiner)
Merges two ordered lists, so that the order is preserved.static <T> java.util.List<T>
mergeLists(java.util.stream.Stream<T> firstStream, java.util.stream.Stream<T> secondStream, java.util.Comparator<T> comp, java.util.function.BiFunction<T,T,T> combiner)
Merges two ordered streams, so that the order is preserved.static <T> int
mergeListsSize(java.util.Iterator<T> firstIterator, java.util.Iterator<T> secondIterator, java.util.Comparator<T> comp)
Finds the size of the union of two ordered lists/streams, represented by iterators.static <T> int
mergeListsSize(java.util.List<T> firstList, java.util.List<T> secondList, java.util.Comparator<T> comp)
Finds the size of the union of two ordered lists.static <T> int
mergeListsSize(java.util.stream.Stream<T> firstStream, java.util.stream.Stream<T> secondStream, java.util.Comparator<T> comp)
Finds the size of the union of two ordered streams.
-
Constructor Details
-
OrderedListCombiner
public OrderedListCombiner()
-
-
Method Details
-
mergeLists
public static <T> java.util.List<T> mergeLists(java.util.List<T> firstList, java.util.List<T> secondList, java.util.Comparator<T> comp, java.util.function.BiFunction<T,T,T> combiner)Merges two ordered lists, so that the order is preserved.- Type Parameters:
T
- The type of the elements in the lists.- Parameters:
firstList
- The first list.secondList
- The second list.comp
- A comparator for determining the order of the elements.combiner
- A function for combining two elements in case they are present in both lists. The first argument of the function receives an element of the first list, and the second an element of the second.- Returns:
- the merged list.
-
mergeLists
public static <T> java.util.List<T> mergeLists(java.util.stream.Stream<T> firstStream, java.util.stream.Stream<T> secondStream, java.util.Comparator<T> comp, java.util.function.BiFunction<T,T,T> combiner)Merges two ordered streams, so that the order is preserved.- Type Parameters:
T
- The type of the elements in the lists.- Parameters:
firstStream
- The first stream.secondStream
- The second stream.comp
- A comparator for determining the order of the elements.combiner
- A function for combining two elements in case they are present in both streams. The first argument of the function receives an element of the first stream, and the second an element of the second stream.- Returns:
- the merged list.
-
mergeLists
public static <T> java.util.List<T> mergeLists(java.util.Iterator<T> firstIterator, java.util.Iterator<T> secondIterator, java.util.Comparator<T> comp, java.util.function.BiFunction<T,T,T> combiner)Merges two ordered lists/streams, represented by iterators, so that the order is preserved.- Type Parameters:
T
- The type of the elements in the lists.- Parameters:
firstIterator
- The first iterator.secondIterator
- The second iterator.comp
- A comparator for determining the order of the elements.combiner
- A function for combining two elements in case they are present in both lists/streams. The first argument of the function receives an element of the first list/stream, and the second an element of the second list/stream.- Returns:
- the merged list.
-
mergeListsSize
public static <T> int mergeListsSize(java.util.List<T> firstList, java.util.List<T> secondList, java.util.Comparator<T> comp)Finds the size of the union of two ordered lists.- Type Parameters:
T
- The type of the elements in the lists.- Parameters:
firstList
- The first list.secondList
- The second list.comp
- A comparator for determining the order of the elements.- Returns:
- the size of the merged list.
-
mergeListsSize
public static <T> int mergeListsSize(java.util.stream.Stream<T> firstStream, java.util.stream.Stream<T> secondStream, java.util.Comparator<T> comp)Finds the size of the union of two ordered streams.- Type Parameters:
T
- The type of the elements in the streams.- Parameters:
firstStream
- The first stream.secondStream
- The second stream.comp
- A comparator for determining the order of the elements.- Returns:
- the size of the merged list.
-
mergeListsSize
public static <T> int mergeListsSize(java.util.Iterator<T> firstIterator, java.util.Iterator<T> secondIterator, java.util.Comparator<T> comp)Finds the size of the union of two ordered lists/streams, represented by iterators.- Type Parameters:
T
- The type of the elements in the lists.- Parameters:
firstIterator
- The first iterator.secondIterator
- The second iterator.comp
- A comparator for determining the order of the elements.- Returns:
- the size of the union list.
-
intersectLists
public static <T> java.util.List<T> intersectLists(java.util.List<T> firstList, java.util.List<T> secondList, java.util.Comparator<T> comp, java.util.function.BiFunction<T,T,T> combiner)Intersects two ordered lists, preserving the order.- Type Parameters:
T
- The type of the elements in the lists.- Parameters:
firstList
- The first list.secondList
- The second list.comp
- A comparator for determining the order of the elements.combiner
- A function for combining two elements. The first argument of the function is the one in the first list, whereas the second argument is the element in the second list.- Returns:
- the intersection of the lists.
-
intersectLists
public static <T> java.util.List<T> intersectLists(java.util.stream.Stream<T> firstStream, java.util.stream.Stream<T> secondStream, java.util.Comparator<T> comp, java.util.function.BiFunction<T,T,T> combiner)Intersects two ordered streams, preserving the order.- Type Parameters:
T
- the type of the elements in the lists.- Parameters:
firstStream
- The first stream.secondStream
- The second stream.comp
- A comparator for determining the order of the elements.combiner
- A function for combining two elements. The first argument of the function is the one in the first stream, whereas the second argument is the element in the second stream.- Returns:
- the intersection of the streams.
-
intersectLists
public static <T> java.util.List<T> intersectLists(java.util.Iterator<T> firstIter, java.util.Iterator<T> secondIter, java.util.Comparator<T> comp, java.util.function.BiFunction<T,T,T> combiner)Intersects two ordered streams/lists, represented by iterators, preserving the order.- Type Parameters:
T
- The type of the elements in the lists.- Parameters:
firstIter
- The first iterator.secondIter
- The second iterator.comp
- A comparator for determining the order of the elements.combiner
- A function for combining two elements. The first argument of the function is the one in the first stream, whereas the second argument is the element in the second stream.- Returns:
- the intersection of the streams/lists.
-
intersectListsSize
public static <T> int intersectListsSize(java.util.List<T> firstList, java.util.List<T> secondList, java.util.Comparator<T> comp)Finds the size of the intersection of two ordered lists.- Type Parameters:
T
- the type of the elements in the lists.- Parameters:
firstList
- The first list.secondList
- The second list.comp
- A comparator for determining the order of the elements.- Returns:
- the size of the intersection of the lists.
-
intersectListsSize
public static <T> int intersectListsSize(java.util.stream.Stream<T> firstStream, java.util.stream.Stream<T> secondStream, java.util.Comparator<T> comp)Finds the size of the intersection of two ordered streams.- Type Parameters:
T
- The type of the elements in the lists.- Parameters:
firstStream
- The first stream.secondStream
- The second stream.comp
- A comparator for determining the order of the elements.- Returns:
- the size of the intersection of the streams.
-
intersectListsSize
public static <T> int intersectListsSize(java.util.Iterator<T> firstIter, java.util.Iterator<T> secondIter, java.util.Comparator<T> comp)Finds the size of the intersection of two ordered streams/lists.- Type Parameters:
T
- The type of the elements.- Parameters:
firstIter
- The iterator representing the first list/stream.secondIter
- The iterator representing the second list/stream.comp
- The comparator.- Returns:
- the size of the intersection.
-
intersectionHasElements
public static <T> boolean intersectionHasElements(java.util.List<T> firstList, java.util.List<T> secondList, java.util.Comparator<T> comp)Checks whether the intersection of two ordered lists is empty or not.- Type Parameters:
T
- The type of the elements.- Parameters:
firstList
- The first list.secondList
- The second list.comp
- A comparator.- Returns:
- true if the intersection has elements, false otherwise.
-
intersectionHaslements
public static <T> boolean intersectionHaslements(java.util.stream.Stream<T> firstList, java.util.stream.Stream<T> secondList, java.util.Comparator<T> comp)Checks whether the intersection of two ordered lists is empty or not.- Type Parameters:
T
- The type of the elements.- Parameters:
firstList
- A stream containing the first list.secondList
- A stream containing the second list.comp
- A comparator.- Returns:
- true if the intersection has elements, false otherwise.
-
intersectionHasElements
public static <T> boolean intersectionHasElements(java.util.Iterator<T> firstList, java.util.Iterator<T> secondList, java.util.Comparator<T> comp)Checks whether the intersection of two ordered lists is empty or not.- Type Parameters:
T
- The type of the elements.- Parameters:
firstList
- The iterator of the first list.secondList
- The iterator of the second list.comp
- A comparator.- Returns:
- true if the intersection has elements, false otherwise.
-
mergeAndIntersectLists
public static <T> Pair<java.util.List<T>> mergeAndIntersectLists(java.util.List<T> firstList, java.util.List<T> secondList, java.util.Comparator<T> comp, java.util.function.BiFunction<T,T,T> combiner)Finds the union and intersection of two ordered lists, preserving the order.- Type Parameters:
T
- The type of the elements in the lists.- Parameters:
firstList
- The first list.secondList
- The second list.comp
- A comparator for determining the order of the elements.combiner
- A function for combining two elements. The first argument of the function is the one in the first stream, whereas the second argument is the element in the second stream.- Returns:
- a pair containing the union of the streams/lists in the first element, and the intersection in the other.
-
mergeAndIntersectLists
public static <T> Pair<java.util.List<T>> mergeAndIntersectLists(java.util.stream.Stream<T> firstList, java.util.stream.Stream<T> secondList, java.util.Comparator<T> comp, java.util.function.BiFunction<T,T,T> combiner)Finds the union and intersection of two ordered streams, preserving the order.- Type Parameters:
T
- The type of the elements in the streams.- Parameters:
firstList
- The first streams.secondList
- The second streams.comp
- A comparator for determining the order of the elements.combiner
- A function for combining two elements. The first argument of the function is the one in the first stream, whereas the second argument is the element in the second stream.- Returns:
- a pair containing the union of the streams/lists in the first element, and the intersection in the other.
-
mergeAndIntersectLists
public static <T> Pair<java.util.List<T>> mergeAndIntersectLists(java.util.Iterator<T> firstIterator, java.util.Iterator<T> secondIterator, java.util.Comparator<T> comp, java.util.function.BiFunction<T,T,T> combiner)Finds the union and intersection of two ordered streams/lists, represented by iterators, preserving the order.- Type Parameters:
T
- The type of the elements in the lists.- Parameters:
firstIterator
- The first iterator.secondIterator
- The second iterator.comp
- A comparator for determining the order of the elements.combiner
- A function for combining two elements. The first argument of the function is the one in the first stream, whereas the second argument is the element in the second stream.- Returns:
- a pair containing the union of the streams/lists in the first element, and the intersection in the other.
-
mergeAndIntersectListsSize
public static <T> Pair<java.lang.Integer> mergeAndIntersectListsSize(java.util.List<T> firstList, java.util.List<T> secondList, java.util.Comparator<T> comp)Finds the union and intersection of two ordered lists, preserving the order.- Type Parameters:
T
- The type of the elements in the lists.- Parameters:
firstList
- The first list.secondList
- The second list.comp
- A comparator for determining the order of the elements.- Returns:
- a pair containing the union of the streams/lists in the first element, and the intersection in the other.
-
mergeAndIntersectListsSize
public static <T> Pair<java.lang.Integer> mergeAndIntersectListsSize(java.util.stream.Stream<T> firstList, java.util.stream.Stream<T> secondList, java.util.Comparator<T> comp)Finds the union and intersection of two ordered streams, preserving the order.- Type Parameters:
T
- The type of the elements in the streams.- Parameters:
firstList
- The first streams.secondList
- The second streams.comp
- A comparator for determining the order of the elements.- Returns:
- a pair containing the union of the streams/lists in the first element, and the intersection in the other.
-
mergeAndIntersectListsSize
public static <T> Pair<java.lang.Integer> mergeAndIntersectListsSize(java.util.Iterator<T> firstIterator, java.util.Iterator<T> secondIterator, java.util.Comparator<T> comp)Finds the union and intersection of two ordered streams/lists, represented by iterators, preserving the order.- Type Parameters:
T
- The type of the elements in the lists.- Parameters:
firstIterator
- The first iterator.secondIterator
- The second iterator.comp
- A comparator for determining the order of the elements.- Returns:
- a pair containing the union of the streams/lists in the first element, and the intersection in the other.
-