Package org.comroid.mutatio.span
Class Span<T>
- java.lang.Object
-
- org.comroid.mutatio.span.Span<T>
-
- All Implemented Interfaces:
java.lang.Iterable<T>,java.util.Collection<T>,java.util.function.Supplier<T>,org.comroid.api.SelfDeclared<Reference<T>>,org.comroid.api.Specifiable<Reference<T>>,Pipeable<T>,Reference<T>,ReferenceIndex<T>
public class Span<T> extends java.lang.Object implements java.util.Collection<T>, ReferenceIndex<T>, Reference<T>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSpan.API<T>static classSpan.DefaultModifyPolicyclassSpan.Iterator-
Nested classes/interfaces inherited from interface org.comroid.mutatio.pipe.Pipeable
Pipeable.From<T>
-
Nested classes/interfaces inherited from interface org.comroid.mutatio.ref.Reference
Reference.Settable<T>, Reference.Support
-
Nested classes/interfaces inherited from interface org.comroid.mutatio.ref.ReferenceIndex
ReferenceIndex.Support
-
-
Field Summary
Fields Modifier and Type Field Description static Span.DefaultModifyPolicyDEFAULT_MODIFY_POLICYstatic intUNFIXED_SIZE
-
Constructor Summary
Constructors Modifier Constructor Description Span()Span(int fixedCapacity)protectedSpan(ReferenceIndex<? extends T> data, int fixedCapacity, ModifyPolicy modifyPolicy)Span(ReferenceIndex<? extends T> data, ModifyPolicy modifyPolicy, boolean fixedSize)Span(ReferenceIndex<T> referenceIndex, ModifyPolicy modifyPolicy)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(T it)booleanaddAll(@NotNull java.util.Collection<? extends T> objects)voidcleanup()voidclear()Deletes all elementsstatic <T> java.util.stream.Collector<T,?,Span<T>>collector()booleancontains(java.lang.Object o)booleancontainsAll(@NotNull java.util.Collection<?> objects)static <T> Span<T>empty()Tget()Reference<T>getReference(int index)static <T> Span<T>immutable(java.util.Collection<T> of)static <T> Span<T>immutable(T... of)<C extends java.util.Collection<T>>
Cinto(java.util.function.Supplier<C> collectionSupplier)booleanisEmpty()booleanisFixedSize()booleanisNotSingle()booleanisSingle()@NotNull Span.Iteratoriterator()static <T> Span.API<T>make()Pipe<?,T>pipe()Span<T>range(int startIncl, int endExcl)Span.API<T>reconfigure()booleanremove(java.lang.Object other)booleanremoveAll(@NotNull java.util.Collection<?> objects)TrequireNonNull()booleanretainAll(@NotNull java.util.Collection<?> keep)static <T> Span<T>singleton(T it)intsize()voidsort(java.util.Comparator<T> comparator)java.util.stream.Stream<T>stream()@NotNull java.lang.Object[]toArray()<R> @NotNull R[]toArray(@NotNull R[] dummy)java.lang.StringtoString()java.util.List<T>unwrap()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, toArray
-
Methods inherited from interface org.comroid.mutatio.ref.Reference
into, invocable, isNull, orElse, orElseGet, process, provider, requireNonNull, test, wrap
-
Methods inherited from interface org.comroid.mutatio.ref.ReferenceIndex
get, requireNonNull, requireNonNull, subset, subset, wrap
-
-
-
-
Field Detail
-
UNFIXED_SIZE
public static final int UNFIXED_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_MODIFY_POLICY
public static final Span.DefaultModifyPolicy DEFAULT_MODIFY_POLICY
-
-
Constructor Detail
-
Span
public Span()
-
Span
public Span(int fixedCapacity)
-
Span
public Span(ReferenceIndex<T> referenceIndex, ModifyPolicy modifyPolicy)
-
Span
public Span(ReferenceIndex<? extends T> data, ModifyPolicy modifyPolicy, boolean fixedSize)
-
Span
protected Span(ReferenceIndex<? extends T> data, int fixedCapacity, ModifyPolicy modifyPolicy)
-
-
Method Detail
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfacejava.util.Collection<T>
-
isSingle
public final boolean isSingle()
-
isNotSingle
public final boolean isNotSingle()
-
isFixedSize
public final boolean isFixedSize()
-
collector
public static <T> java.util.stream.Collector<T,?,Span<T>> collector()
-
make
public static <T> Span.API<T> make()
-
empty
public static <T> Span<T> empty()
-
singleton
public static <T> Span<T> singleton(T it)
-
immutable
public static <T> Span<T> immutable(java.util.Collection<T> of)
-
immutable
@SafeVarargs public static <T> Span<T> immutable(T... of)
-
contains
public boolean contains(java.lang.Object o)
- Specified by:
containsin interfacejava.util.Collection<T>
-
containsAll
public boolean containsAll(@NotNull @NotNull java.util.Collection<?> objects)- Specified by:
containsAllin interfacejava.util.Collection<T>
-
addAll
public boolean addAll(@NotNull @NotNull java.util.Collection<? extends T> objects)- Specified by:
addAllin interfacejava.util.Collection<T>
-
removeAll
public boolean removeAll(@NotNull @NotNull java.util.Collection<?> objects)- Specified by:
removeAllin interfacejava.util.Collection<T>
-
retainAll
public boolean retainAll(@NotNull @NotNull java.util.Collection<?> keep)- Specified by:
retainAllin interfacejava.util.Collection<T>
-
unwrap
public java.util.List<T> unwrap()
- Specified by:
unwrapin interfaceReferenceIndex<T>
-
size
@Contract public final int size()
- Specified by:
sizein interfacejava.util.Collection<T>- Specified by:
sizein interfaceReferenceIndex<T>
-
iterator
@NotNull public final @NotNull Span.Iterator iterator()
-
toArray
@NotNull public final @NotNull java.lang.Object[] toArray()
- Specified by:
toArrayin interfacejava.util.Collection<T>
-
toArray
@NotNull public final <R> @NotNull R[] toArray(@NotNull @NotNull R[] dummy)- Specified by:
toArrayin interfacejava.util.Collection<T>
-
add
public final boolean add(T it)
- Specified by:
addin interfacejava.util.Collection<T>- Specified by:
addin interfaceReferenceIndex<T>
-
remove
public final boolean remove(java.lang.Object other)
- Specified by:
removein interfacejava.util.Collection<T>- Specified by:
removein interfaceReferenceIndex<T>
-
clear
public final void clear()
Description copied from interface:ReferenceIndexDeletes all elements- Specified by:
clearin interfacejava.util.Collection<T>- Specified by:
clearin interfaceReferenceIndex<T>
-
stream
public java.util.stream.Stream<T> stream()
-
getReference
public Reference<T> getReference(int index)
- Specified by:
getReferencein interfaceReferenceIndex<T>
-
toString
public final java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
get
@Nullable public final T get()
-
requireNonNull
@NotNull public T requireNonNull() throws java.lang.NullPointerException
- Specified by:
requireNonNullin interfaceReference<T>- Throws:
java.lang.NullPointerException
-
sort
@Contract(mutates="this") public void sort(java.util.Comparator<T> comparator)
-
cleanup
@Contract(mutates="this") public final void cleanup()
-
into
public final <C extends java.util.Collection<T>> C into(java.util.function.Supplier<C> collectionSupplier)
-
-