Package net.minecraft.util.collection
Class TypeFilterableList<T>
java.lang.Object
java.util.AbstractCollection<T>
net.minecraft.util.collection.TypeFilterableList<T>
- Type Parameters:
T- thecommon element type
- All Implemented Interfaces:
Iterable<T>,Collection<T>
public class TypeFilterableList<T> extends AbstractCollection<T>
A collection allowing getting all elements of a specific type. Backed
by
ArrayLists.
This implementation is not efficient for frequent modifications. You
shouldn't use this if you don't call getAllOfType(Class).
- See Also:
getAllOfType(Class)
-
Field Summary
Fields Modifier and Type Field Description private List<T>allElementsprivate Map<Class<?>,List<T>>elementsByTypeprivate Class<T>elementType -
Constructor Summary
Constructors Constructor Description TypeFilterableList(Class<T> elementType) -
Method Summary
Methods inherited from class java.util.AbstractCollection
addAll, clear, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Field Details
-
elementsByType
-
elementType
-
allElements
-
-
Constructor Details
-
TypeFilterableList
-
-
Method Details
-
add
- Specified by:
addin interfaceCollection<T>- Overrides:
addin classAbstractCollection<T>
-
remove
- Specified by:
removein interfaceCollection<T>- Overrides:
removein classAbstractCollection<T>
-
contains
- Specified by:
containsin interfaceCollection<T>- Overrides:
containsin classAbstractCollection<T>- Throws:
IllegalArgumentException- ifois not an instance ofelementType
-
getAllOfType
Returns all elements in this collection that are instances oftype. The result is unmodifiable.The
type, orS, must extend the class' type parameterT.- Type Parameters:
S- the specialized type, effectivelyS extends T- Parameters:
type- the specialized type, must extendelementType- Returns:
- this collection's elements that are instances of
type - Throws:
IllegalArgumentException- whentypedoes not extendelementType
-
iterator
- Specified by:
iteratorin interfaceCollection<T>- Specified by:
iteratorin interfaceIterable<T>- Specified by:
iteratorin classAbstractCollection<T>
-
method_29903
-
size
public int size()- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein classAbstractCollection<T>
-