Class FilteredIterableOrderedSet<T,I extends Iterable<T>>

java.lang.Object
com.github.tommyettinger.ds.ObjectSet<T>
com.github.tommyettinger.ds.ObjectOrderedSet<I>
com.github.tommyettinger.ds.FilteredIterableOrderedSet<T,I>
Type Parameters:
T - the type of sub-items
I - the type of items, which must be either Iterable or an implementing class, containing T sub-items
All Implemented Interfaces:
Arrangeable, EnhancedCollection<I>, Ordered<I>, Iterable<I>, Collection<I>, Set<I>

public class FilteredIterableOrderedSet<T,I extends Iterable<T>> extends ObjectOrderedSet<I>
A customizable variant on ObjectOrderedSet that uses Iterable items made of T sub-items, and only considers a sub-item (for equality and hashing purposes) if that sub-item satisfies a predicate. This can also edit the sub-items that pass the filter, such as by normalizing their data during comparisons (and hashing). You will usually want to call setFilter(ObjPredicate) and/or setEditor(ObjToSameFunction) to change the behavior of hashing and equality before you enter any items, unless you have specified the filter and/or editor you want in the constructor. Calling setModifiers(ObjPredicate, ObjToSameFunction) is recommended if you need to set both the filter and the editor; you could also set them in the constructor.
This class is related to FilteredStringOrderedSet, which can be seen as using a String as an item and the characters of that String as its sub-items. That means this is also similar to CaseInsensitiveOrderedSet, which is essentially a specialized version of FilteredIterableOrderedSet (which can be useful for serialization).
This is very similar to FilteredIterableSet, except that this class maintains insertion order and can be sorted with ObjectOrderedSet.sort(), ObjectOrderedSet.sort(Comparator), etc. Note that because each Iterable is stored in here in its original form (not modified to make it use the filter and editor), the sorted order might be different than you expect. You can use FilteredComparators.makeComparator(Comparator, ObjPredicate, ObjToSameFunction) to create a Comparator for I Iterable items that uses the same rules this class does.
  • Field Details

    • filter

      protected com.github.tommyettinger.function.ObjPredicate<T> filter
    • editor

      protected com.github.tommyettinger.function.ObjToSameFunction<T> editor
  • Constructor Details

    • FilteredIterableOrderedSet

      public FilteredIterableOrderedSet(OrderType type)
      Creates a new set with an initial capacity of Utilities.getDefaultTableCapacity() and a load factor of Utilities.getDefaultLoadFactor(). This considers all sub-items in an Iterable item and does not edit any sub-items.
      Parameters:
      type - either OrderType.BAG to use unreliable ordering with faster deletion, or anything else to use a list type that takes longer to delete but maintains insertion order reliably
    • FilteredIterableOrderedSet

      public FilteredIterableOrderedSet(int initialCapacity, OrderType type)
      Creates a new set with the specified initial capacity and a load factor of Utilities.getDefaultLoadFactor(). This set will hold initialCapacity items before growing the backing table. This considers all sub-items in an Iterable item and does not edit any sub-items.
      Parameters:
      initialCapacity - If not a power of two, it is increased to the next nearest power of two.
      type - either OrderType.BAG to use unreliable ordering with faster deletion, or anything else to use a list type that takes longer to delete but maintains insertion order reliably
    • FilteredIterableOrderedSet

      public FilteredIterableOrderedSet(int initialCapacity, float loadFactor, OrderType type)
      Creates a new set with the specified initial capacity and load factor. This set will hold initialCapacity items before growing the backing table. This considers all sub-items in an Iterable item and does not edit any sub-items.
      Parameters:
      initialCapacity - If not a power of two, it is increased to the next nearest power of two.
      loadFactor - what fraction of the capacity can be filled before this has to resize; 0 < loadFactor <= 1
      type - either OrderType.BAG to use unreliable ordering with faster deletion, or anything else to use a list type that takes longer to delete but maintains insertion order reliably
    • FilteredIterableOrderedSet

      public FilteredIterableOrderedSet(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, OrderType type)
      Creates a new set with an initial capacity of Utilities.getDefaultTableCapacity() and a load factor of Utilities.getDefaultLoadFactor(). This uses the specified filter and editor.
      Parameters:
      filter - a ObjPredicate that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction that will be given a sub-item and may return a potentially different T sub-item
      type - either OrderType.BAG to use unreliable ordering with faster deletion, or anything else to use a list type that takes longer to delete but maintains insertion order reliably
    • FilteredIterableOrderedSet

      public FilteredIterableOrderedSet(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, int initialCapacity, OrderType type)
      Creates a new set with the specified initial capacity and a load factor of Utilities.getDefaultLoadFactor(). This set will hold initialCapacity items before growing the backing table. This uses the specified filter and editor.
      Parameters:
      filter - a ObjPredicate that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction that will be given a sub-item and may return a potentially different T sub-item
      initialCapacity - If not a power of two, it is increased to the next nearest power of two.
      type - either OrderType.BAG to use unreliable ordering with faster deletion, or anything else to use a list type that takes longer to delete but maintains insertion order reliably
    • FilteredIterableOrderedSet

      public FilteredIterableOrderedSet(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, int initialCapacity, float loadFactor, OrderType type)
      Creates a new set with the specified initial capacity and load factor. This set will hold initialCapacity items before growing the backing table. This uses the specified filter and editor.
      Parameters:
      filter - a ObjPredicate that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction that will be given a sub-item and may return a potentially different T sub-item
      initialCapacity - If not a power of two, it is increased to the next nearest power of two.
      loadFactor - what fraction of the capacity can be filled before this has to resize; 0 < loadFactor <= 1
      type - either OrderType.BAG to use unreliable ordering with faster deletion, or anything else to use a list type that takes longer to delete but maintains insertion order reliably
    • FilteredIterableOrderedSet

      public FilteredIterableOrderedSet(FilteredIterableOrderedSet<T,? extends I> set, OrderType type)
      Creates a new set identical to the specified set.
      Parameters:
      set - another FilteredIterableOrderedSet to copy
      type - either OrderType.BAG to use unreliable ordering with faster deletion, or anything else to use a list type that takes longer to delete but maintains insertion order reliably
    • FilteredIterableOrderedSet

      public FilteredIterableOrderedSet(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, Collection<? extends I> coll, OrderType type)
      Creates a new set that contains all distinct elements in coll. This uses the specified filter and editor, including while it enters the items in coll.
      Parameters:
      filter - a ObjPredicate that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction that will be given a sub-item and may return a potentially different T sub-item
      coll - a Collection implementation to copy, such as an ObjectList or a Set that isn't a FilteredIterableOrderedSet
      type - either OrderType.BAG to use unreliable ordering with faster deletion, or anything else to use a list type that takes longer to delete but maintains insertion order reliably
    • FilteredIterableOrderedSet

      public FilteredIterableOrderedSet(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, I[] array, int offset, int length, OrderType type)
      Creates a new set using length items from the given array, starting at offset (inclusive). This uses the specified filter and editor, including while it enters the items in array.
      Parameters:
      filter - a ObjPredicate that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction that will be given a sub-item and may return a potentially different T sub-item
      array - an array to draw items from
      offset - the first index in array to draw an item from
      length - how many items to take from array; bounds-checking is the responsibility of the using code
      type - either OrderType.BAG to use unreliable ordering with faster deletion, or anything else to use a list type that takes longer to delete but maintains insertion order reliably
    • FilteredIterableOrderedSet

      public FilteredIterableOrderedSet(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, I[] array, OrderType type)
      Creates a new set containing all the items in the given array. This uses the specified filter and editor, including while it enters the items in array.
      Parameters:
      filter - a ObjPredicate that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction that will be given a sub-item and may return a potentially different T sub-item
      array - an array that will be used in full, except for duplicate items
      type - either OrderType.BAG to use unreliable ordering with faster deletion, or anything else to use a list type that takes longer to delete but maintains insertion order reliably
    • FilteredIterableOrderedSet

      public FilteredIterableOrderedSet()
      Creates a new set with an initial capacity of Utilities.getDefaultTableCapacity() and a load factor of Utilities.getDefaultLoadFactor(). This considers all sub-items in an Iterable item and does not edit any sub-items.
    • FilteredIterableOrderedSet

      public FilteredIterableOrderedSet(int initialCapacity)
      Creates a new set with the specified initial capacity and a load factor of Utilities.getDefaultLoadFactor(). This set will hold initialCapacity items before growing the backing table. This considers all sub-items in an Iterable item and does not edit any sub-items.
      Parameters:
      initialCapacity - If not a power of two, it is increased to the next nearest power of two.
    • FilteredIterableOrderedSet

      public FilteredIterableOrderedSet(int initialCapacity, float loadFactor)
      Creates a new set with the specified initial capacity and load factor. This set will hold initialCapacity items before growing the backing table. This considers all sub-items in an Iterable item and does not edit any sub-items.
      Parameters:
      initialCapacity - If not a power of two, it is increased to the next nearest power of two.
      loadFactor - what fraction of the capacity can be filled before this has to resize; 0 < loadFactor <= 1
    • FilteredIterableOrderedSet

      public FilteredIterableOrderedSet(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor)
      Creates a new set with an initial capacity of Utilities.getDefaultTableCapacity() and a load factor of Utilities.getDefaultLoadFactor(). This uses the specified filter and editor.
      Parameters:
      filter - a ObjPredicate that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction that will be given a sub-item and may return a potentially different T sub-item
    • FilteredIterableOrderedSet

      public FilteredIterableOrderedSet(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, int initialCapacity)
      Creates a new set with the specified initial capacity and a load factor of Utilities.getDefaultLoadFactor(). This set will hold initialCapacity items before growing the backing table. This uses the specified filter and editor.
      Parameters:
      filter - a ObjPredicate that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction that will be given a sub-item and may return a potentially different T sub-item
      initialCapacity - If not a power of two, it is increased to the next nearest power of two.
    • FilteredIterableOrderedSet

      public FilteredIterableOrderedSet(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, int initialCapacity, float loadFactor)
      Creates a new set with the specified initial capacity and load factor. This set will hold initialCapacity items before growing the backing table. This uses the specified filter and editor.
      Parameters:
      filter - a ObjPredicate that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction that will be given a sub-item and may return a potentially different T sub-item
      initialCapacity - If not a power of two, it is increased to the next nearest power of two.
      loadFactor - what fraction of the capacity can be filled before this has to resize; 0 < loadFactor <= 1
    • FilteredIterableOrderedSet

      public FilteredIterableOrderedSet(FilteredIterableOrderedSet<T,? extends I> set)
      Creates a new set identical to the specified set.
      Parameters:
      set - another FilteredIterableOrderedSet to copy
    • FilteredIterableOrderedSet

      public FilteredIterableOrderedSet(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, Collection<? extends I> coll)
      Creates a new set that contains all distinct elements in coll. This uses the specified filter and editor, including while it enters the items in coll.
      Parameters:
      filter - a ObjPredicate that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction that will be given a sub-item and may return a potentially different T sub-item
      coll - a Collection implementation to copy, such as an ObjectList or a Set that isn't a FilteredIterableOrderedSet
    • FilteredIterableOrderedSet

      public FilteredIterableOrderedSet(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, I[] array, int offset, int length)
      Creates a new set using length items from the given array, starting at offset (inclusive). This uses the specified filter and editor, including while it enters the items in array.
      Parameters:
      filter - a ObjPredicate that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction that will be given a sub-item and may return a potentially different T sub-item
      array - an array to draw items from
      offset - the first index in array to draw an item from
      length - how many items to take from array; bounds-checking is the responsibility of the using code
    • FilteredIterableOrderedSet

      public FilteredIterableOrderedSet(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, I[] array)
      Creates a new set containing all the items in the given array. This uses the specified filter and editor, including while it enters the items in array.
      Parameters:
      filter - a ObjPredicate that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction that will be given a sub-item and may return a potentially different T sub-item
      array - an array that will be used in full, except for duplicate items
  • Method Details

    • getFilter

      public com.github.tommyettinger.function.ObjPredicate<T> getFilter()
    • setFilter

      public FilteredIterableOrderedSet<T,I> setFilter(com.github.tommyettinger.function.ObjPredicate<T> filter)
      Sets the filter that determines which sub-items in an Iterable are considered for equality and hashing, then returns this object, for chaining. ObjPredicate filters could be lambdas or method references that take a sub-item and return true if that sub-item will be used for hashing/equality, or return false to ignore it. The default filter always returns true. If the filter changes, that invalidates anything previously entered into this, so before changing the filter this clears the entire data structure, removing all existing items.
      Parameters:
      filter - a ObjPredicate that should return true iff a sub-item should be considered for equality/hashing
      Returns:
      this, for chaining
    • getEditor

      public com.github.tommyettinger.function.ObjToSameFunction<T> getEditor()
    • setEditor

      public FilteredIterableOrderedSet<T,I> setEditor(com.github.tommyettinger.function.ObjToSameFunction<T> editor)
      Sets the editor that can alter the sub-items in an Iterable item when they are being used for equality and hashing. This does not apply any changes to the items in this data structure; it only affects how they are hashed or compared. An editor could be a lambda or method reference; the only real requirement is that it takes a T sub-item and returns a T sub-item. The default filter returns the sub-item it is passed without changes. If the editor changes, that invalidates anything previously entered into this, so before changing the editor this clears the entire data structure, removing all existing items.
      Parameters:
      editor - a ObjToSameFunction that will be given a sub-item and may return a potentially different T sub-item
      Returns:
      this, for chaining
    • setModifiers

      public FilteredIterableOrderedSet<T,I> setModifiers(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor)
      Equivalent to calling mySet.setFilter(filter).setEditor(editor), but only clears the data structure once.
      Parameters:
      filter - a ObjPredicate that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction that will be given a sub-item and may return a potentially different T sub-item
      Returns:
      this, for chaining
      See Also:
    • hashHelper

      protected int hashHelper(I s)
    • place

      protected int place(Object item)
      Description copied from class: ObjectSet
      Returns an index >= 0 and <= ObjectSet.mask for the specified item, mixed.
      Overrides:
      place in class ObjectSet<I extends Iterable<T>>
      Parameters:
      item - a non-null Object; its hashCode() method should be used by most implementations
      Returns:
      an index between 0 and ObjectSet.mask (both inclusive)
    • equate

      public boolean equate(Object left, Object right)
      Compares two objects for equality by the rules this filtered data structure uses for keys. This will return true if the arguments are reference-equivalent or both null. Otherwise, it requires that both are Iterables and compares them using the filter and editor of this object.
      Overrides:
      equate in class ObjectSet<I extends Iterable<T>>
      Parameters:
      left - must be non-null; typically a key being compared, but not necessarily
      right - may be null; typically a key being compared, but can often be null for an empty key slot, or some other type
      Returns:
      true if left and right are equivalent according to the rules this filtered type uses
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Collection<T>
      Specified by:
      hashCode in interface Set<T>
      Overrides:
      hashCode in class ObjectOrderedSet<I extends Iterable<T>>
    • with

      public static <T, I extends Iterable<T>> FilteredIterableOrderedSet<T,I> with(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor)
      Constructs a new FilteredIterableOrderedSet with the given filter and editor, without contents, and returns the set.
      Type Parameters:
      T - the type of sub-items
      I - the type of items, which must be either Iterable or an implementing class, containing T sub-items
      Parameters:
      filter - a ObjPredicate<T> that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction<T> that will be given a sub-item and may return a potentially different T sub-item
      Returns:
      a new FilteredIterableOrderedSet containing nothing
    • with

      public static <T, I extends Iterable<T>> FilteredIterableOrderedSet<T,I> with(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, I item)
      Constructs a new FilteredIterableOrderedSet with the given filter and editor, inserts item into it, and returns the set.
      Type Parameters:
      T - the type of sub-items
      I - the type of items, which must be either Iterable or an implementing class, containing T sub-items
      Parameters:
      filter - a ObjPredicate<T> that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction<T> that will be given a sub-item and may return a potentially different T sub-item
      item - the one item to initially include in the set
      Returns:
      a new FilteredIterableOrderedSet containing item
    • with

      public static <T, I extends Iterable<T>> FilteredIterableOrderedSet<T,I> with(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, I item0, I item1)
      Constructs a new FilteredIterableOrderedSet with the given filter and editor, inserts items into it, and returns the set.
      Type Parameters:
      T - the type of sub-items
      I - the type of items, which must be either Iterable or an implementing class, containing T sub-items
      Parameters:
      filter - a ObjPredicate<T> that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction<T> that will be given a sub-item and may return a potentially different T sub-item
      item0 - an Iterable of T to initially include in the set
      item1 - an Iterable of T to initially include in the set
      Returns:
      a new FilteredIterableOrderedSet containing the given items
    • with

      public static <T, I extends Iterable<T>> FilteredIterableOrderedSet<T,I> with(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, I item0, I item1, I item2)
      Constructs a new FilteredIterableOrderedSet with the given filter and editor, inserts items into it, and returns the set.
      Type Parameters:
      T - the type of sub-items
      I - the type of items, which must be either Iterable or an implementing class, containing T sub-items
      Parameters:
      filter - a ObjPredicate<T> that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction<T> that will be given a sub-item and may return a potentially different T sub-item
      item0 - an Iterable of T to initially include in the set
      item1 - an Iterable of T to initially include in the set
      item2 - an Iterable of T to initially include in the set
      Returns:
      a new FilteredIterableOrderedSet containing the given items
    • with

      public static <T, I extends Iterable<T>> FilteredIterableOrderedSet<T,I> with(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, I item0, I item1, I item2, I item3)
      Constructs a new FilteredIterableOrderedSet with the given filter and editor, inserts items into it, and returns the set.
      Type Parameters:
      T - the type of sub-items
      I - the type of items, which must be either Iterable or an implementing class, containing T sub-items
      Parameters:
      filter - a ObjPredicate<T> that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction<T> that will be given a sub-item and may return a potentially different T sub-item
      item0 - an Iterable of T to initially include in the set
      item1 - an Iterable of T to initially include in the set
      item2 - an Iterable of T to initially include in the set
      item3 - an Iterable of T to initially include in the set
      Returns:
      a new FilteredIterableOrderedSet containing the given items
    • with

      public static <T, I extends Iterable<T>> FilteredIterableOrderedSet<T,I> with(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, I item0, I item1, I item2, I item3, I item4)
      Constructs a new FilteredIterableOrderedSet with the given filter and editor, inserts items into it, and returns the set.
      Type Parameters:
      T - the type of sub-items
      I - the type of items, which must be either Iterable or an implementing class, containing T sub-items
      Parameters:
      filter - a ObjPredicate<T> that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction<T> that will be given a sub-item and may return a potentially different T sub-item
      item0 - an Iterable of T to initially include in the set
      item1 - an Iterable of T to initially include in the set
      item2 - an Iterable of T to initially include in the set
      item3 - an Iterable of T to initially include in the set
      item4 - an Iterable of T to initially include in the set
      Returns:
      a new FilteredIterableOrderedSet containing the given items
    • with

      public static <T, I extends Iterable<T>> FilteredIterableOrderedSet<T,I> with(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, I item0, I item1, I item2, I item3, I item4, I item5)
      Constructs a new FilteredIterableOrderedSet with the given filter and editor, inserts items into it, and returns the set.
      Type Parameters:
      T - the type of sub-items
      I - the type of items, which must be either Iterable or an implementing class, containing T sub-items
      Parameters:
      filter - a ObjPredicate<T> that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction<T> that will be given a sub-item and may return a potentially different T sub-item
      item0 - an Iterable of T to initially include in the set
      item1 - an Iterable of T to initially include in the set
      item2 - an Iterable of T to initially include in the set
      item3 - an Iterable of T to initially include in the set
      item4 - an Iterable of T to initially include in the set
      item5 - an Iterable of T to initially include in the set
      Returns:
      a new FilteredIterableOrderedSet containing the given items
    • with

      public static <T, I extends Iterable<T>> FilteredIterableOrderedSet<T,I> with(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, I item0, I item1, I item2, I item3, I item4, I item5, I item6)
      Constructs a new FilteredIterableOrderedSet with the given filter and editor, inserts items into it, and returns the set.
      Type Parameters:
      T - the type of sub-items
      I - the type of items, which must be either Iterable or an implementing class, containing T sub-items
      Parameters:
      filter - a ObjPredicate<T> that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction<T> that will be given a sub-item and may return a potentially different T sub-item
      item0 - an Iterable of T to initially include in the set
      item1 - an Iterable of T to initially include in the set
      item2 - an Iterable of T to initially include in the set
      item3 - an Iterable of T to initially include in the set
      item4 - an Iterable of T to initially include in the set
      item5 - an Iterable of T to initially include in the set
      item6 - an Iterable of T to initially include in the set
      Returns:
      a new FilteredIterableOrderedSet containing the given items
    • with

      public static <T, I extends Iterable<T>> FilteredIterableOrderedSet<T,I> with(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, I item0, I item1, I item2, I item3, I item4, I item5, I item6, I item7)
      Constructs a new FilteredIterableOrderedSet with the given filter and editor, inserts items into it, and returns the set.
      Type Parameters:
      T - the type of sub-items
      I - the type of items, which must be either Iterable or an implementing class, containing T sub-items
      Parameters:
      filter - a ObjPredicate<T> that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction<T> that will be given a sub-item and may return a potentially different T sub-item
      item0 - an Iterable of T to initially include in the set
      item1 - an Iterable of T to initially include in the set
      item2 - an Iterable of T to initially include in the set
      item3 - an Iterable of T to initially include in the set
      item4 - an Iterable of T to initially include in the set
      item5 - an Iterable of T to initially include in the set
      item6 - an Iterable of T to initially include in the set
      item7 - an Iterable of T to initially include in the set
      Returns:
      a new FilteredIterableOrderedSet containing the given items
    • with

      @SafeVarargs public static <T, I extends Iterable<T>> FilteredIterableOrderedSet<T,I> with(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, I... items)
      This is the same as FilteredIterableOrderedSet(ObjPredicate, ObjToSameFunction, Iterable[]), but can take the array argument as either an array or as varargs. It can be useful for code-generation scenarios.
      Type Parameters:
      T - the type of sub-items
      I - the type of items, which must be either Iterable or an implementing class, containing T sub-items
      Parameters:
      filter - a ObjPredicate<T> that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction<T> that will be given a sub-item and may return a potentially different T sub-item
      items - an array or varargs of I that will be used in the new set
      Returns:
      a new FilteredIterableOrderedSet containing the entirety of items, as the filter and editor permit
    • parse

      public static <T, I extends Iterable<T>> FilteredIterableOrderedSet<T,I> parse(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, String str, String delimiter, PartialParser<I> parser)
      Type Parameters:
      T - the type of item in each Iterable
      I - the Iterable of T type this holds
      Parameters:
      filter - a ObjPredicate<T> that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction<T> that will be given a sub-item and may return a potentially different T sub-item
      str - a String that will be parsed in full
      delimiter - the delimiter between items in str
      parser - a PartialParser that returns an I item from a section of str
      Returns:
      a new collection parsed from str
    • parse

      public static <T, I extends Iterable<T>> FilteredIterableOrderedSet<T,I> parse(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, String str, String delimiter, PartialParser<I> parser, boolean brackets)
      Creates a new HolderSet using extractor and fills it by calling EnhancedCollection.addLegible(String, String, PartialParser, int, int) on either all of str (if brackets is false) or str without its first and last chars (if brackets is true). Each item is expected to be separated by delimiter.
      Type Parameters:
      T - the type of item in each Iterable
      I - the Iterable of T type this holds
      Parameters:
      filter - a ObjPredicate<T> that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction<T> that will be given a sub-item and may return a potentially different T sub-item
      str - a String that will be parsed in full (depending on brackets)
      delimiter - the delimiter between items in str
      parser - a PartialParser that returns an I item from a section of str
      brackets - if true, the first and last chars in str will be ignored
      Returns:
      a new collection parsed from str
    • parse

      public static <T, I extends Iterable<T>> FilteredIterableOrderedSet<T,I> parse(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, String str, String delimiter, PartialParser<I> parser, int offset, int length)
      Creates a new HolderSet using extractor and fills it by calling EnhancedCollection.addLegible(String, String, PartialParser, int, int) with the other five parameters as-is.
      Type Parameters:
      T - the type of item in each Iterable
      I - the Iterable of T type this holds
      Parameters:
      filter - a ObjPredicate<T> that should return true iff a sub-item should be considered for equality/hashing
      editor - a ObjToSameFunction<T> that will be given a sub-item and may return a potentially different T sub-item
      str - a String that will have the given section parsed
      delimiter - the delimiter between items in str
      parser - a PartialParser that returns an I item from a section of str
      offset - the first position to parse in str, inclusive
      length - how many chars to parse, starting from offset
      Returns:
      a new collection parsed from str