Class ListSet<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
com.fren_gor.ultimateAdvancementAPI.nms.util.ListSet<E>
- Type Parameters:
E
- The type of the elements of thisSet
.
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,Set<E>
Immutable copy of the non-null elements of a
Set
.
The implementation uses an immutable array-based list to store the elements of the original Set
in order to minimize the copy operation cost.
Since ListSet
is immutable and contains only the elements of one other Set
,
it respects all the properties of a Set
.
This class is thread safe.
-
Constructor Summary
-
Method Summary
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Constructor Details
-
ListSet
Creates a newListSet
containing the elements of the providedSet
.- Parameters:
elements
- The elements to copy into thisSet
.null
elements are not added to theListSet
.- Throws:
IllegalArgumentException
- If the providedSet
isnull
.
-
-
Method Details
-
fromWrapperSet
@NotNull @Contract(pure=true, value="_ -> new") public static <T extends AbstractWrapper> @NotNull ListSet<?> fromWrapperSet(@NotNull @NotNull Set<T> elements) Creates a newListSet
containing the NMS objects associated with the elements of the providedSet
.AbstractWrapper.toNMS()
is called on every non-null element of the providedSet
.- Type Parameters:
T
- The type of the elements in the providedSet
.- Parameters:
elements
- TheAbstractWrapper
s to convert to their NMS associated- Returns:
- A new
ListSet
containing the NMS objects associated with the elements of the providedSet
. - Throws:
IllegalArgumentException
- If the providedSet
isnull
.
-
iterator
-
size
public int size()- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceSet<E>
- Specified by:
size
in classAbstractCollection<E>
-