Package com.github.tommyettinger.ds
Class FilteredIterableSet<T,I extends Iterable<T>>
java.lang.Object
com.github.tommyettinger.ds.ObjectSet<I>
com.github.tommyettinger.ds.FilteredIterableSet<T,I>
- All Implemented Interfaces:
EnhancedCollection<I>,Iterable<I>,Collection<I>,Set<I>
A customizable variant on ObjectSet 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
This class is related to
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
FilteredStringSet, 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 CaseInsensitiveSet, which is essentially
a specialized version of FilteredIterableSet (which can be useful for serialization).-
Nested Class Summary
Nested classes/interfaces inherited from class com.github.tommyettinger.ds.ObjectSet
ObjectSet.ObjectSetIterator<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.github.tommyettinger.function.ObjToSameFunction<T>protected com.github.tommyettinger.function.ObjPredicate<T>Fields inherited from class com.github.tommyettinger.ds.ObjectSet
hashMultiplier, iterator1, iterator2, keyTable, loadFactor, mask, shift, size, threshold -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new set with an initial capacity ofUtilities.getDefaultTableCapacity()and a load factor ofUtilities.getDefaultLoadFactor().FilteredIterableSet(int initialCapacity) Creates a new set with the specified initial capacity and a load factor ofUtilities.getDefaultLoadFactor().FilteredIterableSet(int initialCapacity, float loadFactor) Creates a new set with the specified initial capacity and load factor.FilteredIterableSet(FilteredIterableSet<T, ? extends I> set) Creates a new set identical to the specified set.FilteredIterableSet(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor) Creates a new set with an initial capacity ofUtilities.getDefaultTableCapacity()and a load factor ofUtilities.getDefaultLoadFactor().FilteredIterableSet(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 ofUtilities.getDefaultLoadFactor().FilteredIterableSet(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.FilteredIterableSet(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.FilteredIterableSet(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, I[] array, int offset, int length) Creates a new set usinglengthitems from the givenarray, starting at offset (inclusive).FilteredIterableSet(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 incoll. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCompares two objects for equality by the rules this filtered data structure uses for keys.com.github.tommyettinger.function.ObjToSameFunction<T>com.github.tommyettinger.function.ObjPredicate<T>inthashCode()protected inthashHelper(I s) static <T,I extends Iterable<T>>
FilteredIterableSet<T,I> parse(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, String str, String delimiter, PartialParser<I> parser) Callsparse(ObjPredicate, ObjToSameFunction, String, String, PartialParser, boolean)with brackets set to false.static <T,I extends Iterable<T>>
FilteredIterableSet<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 usingextractorand fills it by callingEnhancedCollection.addLegible(String, String, PartialParser, int, int)on either all ofstr(ifbracketsis false) orstrwithout its first and last chars (ifbracketsis true).static <T,I extends Iterable<T>>
FilteredIterableSet<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 usingextractorand fills it by callingEnhancedCollection.addLegible(String, String, PartialParser, int, int)with the other five parameters as-is.protected intReturns an index >= 0 and <=ObjectSet.maskfor the specifieditem, mixed.Sets the editor that can alter the sub-items in an Iterable item when they are being used for equality and hashing.Sets the filter that determines which sub-items in an Iterable are considered for equality and hashing, then returns this object, for chaining.setModifiers(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor) Equivalent to callingmySet.setFilter(filter).setEditor(editor), but only clears the data structure once.static <T,I extends Iterable<T>>
FilteredIterableSet<T,I> with(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor) Constructs a new FilteredIterableSet with the given filter and editor, without contents, and returns the set.static <T,I extends Iterable<T>>
FilteredIterableSet<T,I> with(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, I item) Constructs a new FilteredIterableSet with the given filter and editor, insertsiteminto it, and returns the set.static <T,I extends Iterable<T>>
FilteredIterableSet<T,I> with(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, I... items) This is the same asFilteredIterableSet(ObjPredicate, ObjToSameFunction, Iterable[]), but can take the array argument as either an array or as varargs.static <T,I extends Iterable<T>>
FilteredIterableSet<T,I> with(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, I item0, I item1) Constructs a new FilteredIterableSet with the given filter and editor, inserts items into it, and returns the set.static <T,I extends Iterable<T>>
FilteredIterableSet<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 FilteredIterableSet with the given filter and editor, inserts items into it, and returns the set.static <T,I extends Iterable<T>>
FilteredIterableSet<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 FilteredIterableSet with the given filter and editor, inserts items into it, and returns the set.static <T,I extends Iterable<T>>
FilteredIterableSet<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 FilteredIterableSet with the given filter and editor, inserts items into it, and returns the set.static <T,I extends Iterable<T>>
FilteredIterableSet<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 FilteredIterableSet with the given filter and editor, inserts items into it, and returns the set.static <T,I extends Iterable<T>>
FilteredIterableSet<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 FilteredIterableSet with the given filter and editor, inserts items into it, and returns the set.static <T,I extends Iterable<T>>
FilteredIterableSet<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 FilteredIterableSet with the given filter and editor, inserts items into it, and returns the set.Methods inherited from class com.github.tommyettinger.ds.ObjectSet
add, addAll, addAll, addAll, addAll, addResize, appendTo, clear, clear, contains, containsAll, containsAll, containsAll, containsAny, containsAny, containsAnyIterable, ensureCapacity, equals, first, get, getHashMultiplier, getLoadFactor, getTableSize, isEmpty, iterator, locateKey, notEmpty, parse, parse, parse, remove, removeAll, removeAll, removeAll, resize, retainAll, setHashMultiplier, setLoadFactor, shrink, size, toArray, toArray, toString, truncate, with, with, with, with, with, with, with, with, with, withMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface com.github.tommyettinger.ds.EnhancedCollection
add, add, add, addAll, addAllIterable, addLegible, addLegible, addVarargs, appendTo, appendTo, containsAll, containsAllIterable, containsAny, removeAll, removeAllIterable, removeEach, removeEach, removeEach, removeEachIterable, toString, toString, toStringMethods inherited from interface java.util.Set
spliterator
-
Field Details
-
filter
-
editor
-
-
Constructor Details
-
FilteredIterableSet
public FilteredIterableSet()Creates a new set with an initial capacity ofUtilities.getDefaultTableCapacity()and a load factor ofUtilities.getDefaultLoadFactor(). This considers all sub-items in an Iterable item and does not edit any sub-items. -
FilteredIterableSet
public FilteredIterableSet(int initialCapacity) Creates a new set with the specified initial capacity and a load factor ofUtilities.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.
-
FilteredIterableSet
public FilteredIterableSet(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
-
FilteredIterableSet
public FilteredIterableSet(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor) Creates a new set with an initial capacity ofUtilities.getDefaultTableCapacity()and a load factor ofUtilities.getDefaultLoadFactor(). This uses the specified filter and editor.- Parameters:
filter- a ObjPredicatethat should return true iff a sub-item should be considered for equality/hashing editor- a ObjToSameFunctionthat will be given a sub-item and may return a potentially different Tsub-item
-
FilteredIterableSet
public FilteredIterableSet(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 ofUtilities.getDefaultLoadFactor(). This set will hold initialCapacity items before growing the backing table. This uses the specified filter and editor.- Parameters:
filter- a ObjPredicatethat should return true iff a sub-item should be considered for equality/hashing editor- a ObjToSameFunctionthat will be given a sub-item and may return a potentially different Tsub-iteminitialCapacity- If not a power of two, it is increased to the next nearest power of two.
-
FilteredIterableSet
public FilteredIterableSet(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 ObjPredicatethat should return true iff a sub-item should be considered for equality/hashing editor- a ObjToSameFunctionthat will be given a sub-item and may return a potentially different Tsub-iteminitialCapacity- 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
-
FilteredIterableSet
Creates a new set identical to the specified set.- Parameters:
set- another FilteredIterableSet to copy
-
FilteredIterableSet
public FilteredIterableSet(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 incoll. This uses the specified filter and editor, including while it enters the items in coll.- Parameters:
filter- a ObjPredicatethat should return true iff a sub-item should be considered for equality/hashing editor- a ObjToSameFunctionthat will be given a sub-item and may return a potentially different Tsub-itemcoll- a Collection implementation to copy, such as an ObjectList or a Set that isn't a FilteredIterableSet
-
FilteredIterableSet
public FilteredIterableSet(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, I[] array, int offset, int length) Creates a new set usinglengthitems from the givenarray, starting at offset (inclusive). This uses the specified filter and editor, including while it enters the items in array.- Parameters:
filter- a ObjPredicatethat should return true iff a sub-item should be considered for equality/hashing editor- a ObjToSameFunctionthat will be given a sub-item and may return a potentially different Tsub-itemarray- an array to draw items fromoffset- the first index in array to draw an item fromlength- how many items to take from array; bounds-checking is the responsibility of the using code
-
FilteredIterableSet
public FilteredIterableSet(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 ObjPredicatethat should return true iff a sub-item should be considered for equality/hashing editor- a ObjToSameFunctionthat will be given a sub-item and may return a potentially different Tsub-itemarray- an array that will be used in full, except for duplicate items
-
-
Method Details
-
getFilter
-
setFilter
Sets the filter that determines which sub-items in an Iterable are considered for equality and hashing, then returns this object, for chaining. ObjPredicatefilters 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 ObjPredicatethat should return true iff a sub-item should be considered for equality/hashing - Returns:
- this, for chaining
-
getEditor
-
setEditor
public FilteredIterableSet<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 aTsub-item and returns aTsub-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 ObjToSameFunctionthat will be given a sub-item and may return a potentially different Tsub-item- Returns:
- this, for chaining
-
setModifiers
public FilteredIterableSet<T,I> setModifiers(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor) Equivalent to callingmySet.setFilter(filter).setEditor(editor), but only clears the data structure once.- Parameters:
filter- a ObjPredicatethat should return true iff a sub-item should be considered for equality/hashing editor- a ObjToSameFunctionthat will be given a sub-item and may return a potentially different Tsub-item- Returns:
- this, for chaining
- See Also:
-
hashHelper
-
place
Description copied from class:ObjectSetReturns an index >= 0 and <=ObjectSet.maskfor the specifieditem, mixed. -
equate
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 areIterables and compares them using thefilterandeditorof this object.- Overrides:
equatein classObjectSet<I extends Iterable<T>>- Parameters:
left- must be non-null; typically a key being compared, but not necessarilyright- 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() -
with
public static <T,I extends Iterable<T>> FilteredIterableSet<T,I> with(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor) Constructs a new FilteredIterableSet with the given filter and editor, without contents, and returns the set.- Type Parameters:
T- the type of sub-itemsI- the type of items, which must be either Iterable or an implementing class, containingTsub-items- Parameters:
filter- aObjPredicate<T>that should return true iff a sub-item should be considered for equality/hashingeditor- aObjToSameFunction<T>that will be given a sub-item and may return a potentially differentTsub-item- Returns:
- a new FilteredIterableSet containing nothing
-
with
public static <T,I extends Iterable<T>> FilteredIterableSet<T,I> with(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, I item) Constructs a new FilteredIterableSet with the given filter and editor, insertsiteminto it, and returns the set.- Type Parameters:
T- the type of sub-itemsI- the type of items, which must be either Iterable or an implementing class, containingTsub-items- Parameters:
filter- aObjPredicate<T>that should return true iff a sub-item should be considered for equality/hashingeditor- aObjToSameFunction<T>that will be given a sub-item and may return a potentially differentTsub-itemitem- the one item to initially include in the set- Returns:
- a new FilteredIterableSet containing
item
-
with
public static <T,I extends Iterable<T>> FilteredIterableSet<T,I> with(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, I item0, I item1) Constructs a new FilteredIterableSet with the given filter and editor, inserts items into it, and returns the set.- Type Parameters:
T- the type of sub-itemsI- the type of items, which must be either Iterable or an implementing class, containingTsub-items- Parameters:
filter- aObjPredicate<T>that should return true iff a sub-item should be considered for equality/hashingeditor- aObjToSameFunction<T>that will be given a sub-item and may return a potentially differentTsub-itemitem0- an Iterable of T to initially include in the setitem1- an Iterable of T to initially include in the set- Returns:
- a new FilteredIterableSet containing the given items
-
with
public static <T,I extends Iterable<T>> FilteredIterableSet<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 FilteredIterableSet with the given filter and editor, inserts items into it, and returns the set.- Type Parameters:
T- the type of sub-itemsI- the type of items, which must be either Iterable or an implementing class, containingTsub-items- Parameters:
filter- aObjPredicate<T>that should return true iff a sub-item should be considered for equality/hashingeditor- aObjToSameFunction<T>that will be given a sub-item and may return a potentially differentTsub-itemitem0- an Iterable of T to initially include in the setitem1- an Iterable of T to initially include in the setitem2- an Iterable of T to initially include in the set- Returns:
- a new FilteredIterableSet containing the given items
-
with
public static <T,I extends Iterable<T>> FilteredIterableSet<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 FilteredIterableSet with the given filter and editor, inserts items into it, and returns the set.- Type Parameters:
T- the type of sub-itemsI- the type of items, which must be either Iterable or an implementing class, containingTsub-items- Parameters:
filter- aObjPredicate<T>that should return true iff a sub-item should be considered for equality/hashingeditor- aObjToSameFunction<T>that will be given a sub-item and may return a potentially differentTsub-itemitem0- an Iterable of T to initially include in the setitem1- an Iterable of T to initially include in the setitem2- an Iterable of T to initially include in the setitem3- an Iterable of T to initially include in the set- Returns:
- a new FilteredIterableSet containing the given items
-
with
public static <T,I extends Iterable<T>> FilteredIterableSet<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 FilteredIterableSet with the given filter and editor, inserts items into it, and returns the set.- Type Parameters:
T- the type of sub-itemsI- the type of items, which must be either Iterable or an implementing class, containingTsub-items- Parameters:
filter- aObjPredicate<T>that should return true iff a sub-item should be considered for equality/hashingeditor- aObjToSameFunction<T>that will be given a sub-item and may return a potentially differentTsub-itemitem0- an Iterable of T to initially include in the setitem1- an Iterable of T to initially include in the setitem2- an Iterable of T to initially include in the setitem3- an Iterable of T to initially include in the setitem4- an Iterable of T to initially include in the set- Returns:
- a new FilteredIterableSet containing the given items
-
with
public static <T,I extends Iterable<T>> FilteredIterableSet<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 FilteredIterableSet with the given filter and editor, inserts items into it, and returns the set.- Type Parameters:
T- the type of sub-itemsI- the type of items, which must be either Iterable or an implementing class, containingTsub-items- Parameters:
filter- aObjPredicate<T>that should return true iff a sub-item should be considered for equality/hashingeditor- aObjToSameFunction<T>that will be given a sub-item and may return a potentially differentTsub-itemitem0- an Iterable of T to initially include in the setitem1- an Iterable of T to initially include in the setitem2- an Iterable of T to initially include in the setitem3- an Iterable of T to initially include in the setitem4- an Iterable of T to initially include in the setitem5- an Iterable of T to initially include in the set- Returns:
- a new FilteredIterableSet containing the given items
-
with
public static <T,I extends Iterable<T>> FilteredIterableSet<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 FilteredIterableSet with the given filter and editor, inserts items into it, and returns the set.- Type Parameters:
T- the type of sub-itemsI- the type of items, which must be either Iterable or an implementing class, containingTsub-items- Parameters:
filter- aObjPredicate<T>that should return true iff a sub-item should be considered for equality/hashingeditor- aObjToSameFunction<T>that will be given a sub-item and may return a potentially differentTsub-itemitem0- an Iterable of T to initially include in the setitem1- an Iterable of T to initially include in the setitem2- an Iterable of T to initially include in the setitem3- an Iterable of T to initially include in the setitem4- an Iterable of T to initially include in the setitem5- an Iterable of T to initially include in the setitem6- an Iterable of T to initially include in the set- Returns:
- a new FilteredIterableSet containing the given items
-
with
public static <T,I extends Iterable<T>> FilteredIterableSet<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 FilteredIterableSet with the given filter and editor, inserts items into it, and returns the set.- Type Parameters:
T- the type of sub-itemsI- the type of items, which must be either Iterable or an implementing class, containingTsub-items- Parameters:
filter- aObjPredicate<T>that should return true iff a sub-item should be considered for equality/hashingeditor- aObjToSameFunction<T>that will be given a sub-item and may return a potentially differentTsub-itemitem0- an Iterable of T to initially include in the setitem1- an Iterable of T to initially include in the setitem2- an Iterable of T to initially include in the setitem3- an Iterable of T to initially include in the setitem4- an Iterable of T to initially include in the setitem5- an Iterable of T to initially include in the setitem6- an Iterable of T to initially include in the setitem7- an Iterable of T to initially include in the set- Returns:
- a new FilteredIterableSet containing the given items
-
with
@SafeVarargs public static <T,I extends Iterable<T>> FilteredIterableSet<T,I> with(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, I... items) This is the same asFilteredIterableSet(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-itemsI- the type of items, which must be either Iterable or an implementing class, containingTsub-items- Parameters:
filter- aObjPredicate<T>that should return true iff a sub-item should be considered for equality/hashingeditor- aObjToSameFunction<T>that will be given a sub-item and may return a potentially differentTsub-itemitems- an array or varargs ofIthat will be used in the new set- Returns:
- a new FilteredIterableSet containing the entirety of items, as the filter and editor permit
-
parse
public static <T,I extends Iterable<T>> FilteredIterableSet<T,I> parse(com.github.tommyettinger.function.ObjPredicate<T> filter, com.github.tommyettinger.function.ObjToSameFunction<T> editor, String str, String delimiter, PartialParser<I> parser) Callsparse(ObjPredicate, ObjToSameFunction, String, String, PartialParser, boolean)with brackets set to false.- Type Parameters:
T- the type of item in each IterableI- the Iterable of T type this holds- Parameters:
filter- aObjPredicate<T>that should return true iff a sub-item should be considered for equality/hashingeditor- aObjToSameFunction<T>that will be given a sub-item and may return a potentially differentTsub-itemstr- a String that will be parsed in fulldelimiter- the delimiter between items in strparser- a PartialParser that returns anIitem from a section ofstr- Returns:
- a new collection parsed from str
-
parse
public static <T,I extends Iterable<T>> FilteredIterableSet<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 usingextractorand fills it by callingEnhancedCollection.addLegible(String, String, PartialParser, int, int)on either all ofstr(ifbracketsis false) orstrwithout its first and last chars (ifbracketsis true). Each item is expected to be separated bydelimiter.- Type Parameters:
T- the type of item in each IterableI- the Iterable of T type this holds- Parameters:
filter- aObjPredicate<T>that should return true iff a sub-item should be considered for equality/hashingeditor- aObjToSameFunction<T>that will be given a sub-item and may return a potentially differentTsub-itemstr- a String that will be parsed in full (depending on brackets)delimiter- the delimiter between items in strparser- a PartialParser that returns anIitem from a section ofstrbrackets- 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>> FilteredIterableSet<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 usingextractorand fills it by callingEnhancedCollection.addLegible(String, String, PartialParser, int, int)with the other five parameters as-is.- Type Parameters:
T- the type of item in each IterableI- the Iterable of T type this holds- Parameters:
filter- aObjPredicate<T>that should return true iff a sub-item should be considered for equality/hashingeditor- aObjToSameFunction<T>that will be given a sub-item and may return a potentially differentTsub-itemstr- a String that will have the given section parseddelimiter- the delimiter between items in strparser- a PartialParser that returns anIitem from a section ofstroffset- the first position to parse in str, inclusivelength- how many chars to parse, starting from offset- Returns:
- a new collection parsed from str
-