23 * questions.
24 */
25
26 package javafx.collections.transformation;
27
28 import com.sun.javafx.collections.NonIterableChange.GenericAddRemoveChange;
29 import com.sun.javafx.collections.SortHelper;
30 import java.util.ArrayList;
31 import java.util.Arrays;
32 import java.util.Iterator;
33 import java.util.List;
34 import java.util.ListIterator;
35 import java.util.function.Predicate;
36 import javafx.beans.NamedArg;
37 import javafx.beans.property.ObjectProperty;
38 import javafx.beans.property.ObjectPropertyBase;
39 import javafx.collections.ListChangeListener.Change;
40 import javafx.collections.ObservableList;
41
42 /**
43 * Wraps an ObservableList and filters it's content using the provided Predicate.
44 * All changes in the ObservableList are propagated immediately
45 * to the FilteredList.
46 *
47 * @see TransformationList
48 * @since JavaFX 8.0
49 */
50 public final class FilteredList<E> extends TransformationList<E, E>{
51
52 private int[] filtered;
53 private int size;
54
55 private SortHelper helper;
56 private static final Predicate ALWAYS_TRUE = t -> true;
57
58 /**
59 * Constructs a new FilteredList wrapper around the source list.
60 * The provided predicate will match the elements in the source list that will be visible.
61 * If the predicate is null, all elements will be matched and the list is equal to the source list.
62 * @param source the source list
63 * @param predicate the predicate to match the elements or null to match all elements.
|
23 * questions.
24 */
25
26 package javafx.collections.transformation;
27
28 import com.sun.javafx.collections.NonIterableChange.GenericAddRemoveChange;
29 import com.sun.javafx.collections.SortHelper;
30 import java.util.ArrayList;
31 import java.util.Arrays;
32 import java.util.Iterator;
33 import java.util.List;
34 import java.util.ListIterator;
35 import java.util.function.Predicate;
36 import javafx.beans.NamedArg;
37 import javafx.beans.property.ObjectProperty;
38 import javafx.beans.property.ObjectPropertyBase;
39 import javafx.collections.ListChangeListener.Change;
40 import javafx.collections.ObservableList;
41
42 /**
43 * Wraps an ObservableList and filters its content using the provided Predicate.
44 * All changes in the ObservableList are propagated immediately
45 * to the FilteredList.
46 *
47 * @see TransformationList
48 * @since JavaFX 8.0
49 */
50 public final class FilteredList<E> extends TransformationList<E, E>{
51
52 private int[] filtered;
53 private int size;
54
55 private SortHelper helper;
56 private static final Predicate ALWAYS_TRUE = t -> true;
57
58 /**
59 * Constructs a new FilteredList wrapper around the source list.
60 * The provided predicate will match the elements in the source list that will be visible.
61 * If the predicate is null, all elements will be matched and the list is equal to the source list.
62 * @param source the source list
63 * @param predicate the predicate to match the elements or null to match all elements.
|