ComponentSet class
This is a simple wrapper over QueryableOrderedSet
to be used by
Component.
Instead of immediately modifying the component list, all insertion and removal operations are queued to be performed on the next tick.
This will avoid any concurrent modification exceptions while the game iterates through the component list.
- Inheritance
-
- Object
- IterableMixin<
Component> - OrderedSet<
Component> - QueryableOrderedSet<
Component> - ComponentSet
Constructors
- ComponentSet({int comparator(Component e1, Component e2)?, bool? strictMode})
- With default settings, creates a ComponentSet with the compare function that uses the Component's priority for sorting.
Properties
- first → Component
-
The first element.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
Whether this collection has no elements.
no setterinherited
- isNotEmpty → bool
-
Whether the component set contains components or that there are components
marked to be added later.
no setteroverride
-
iterator
→ Iterator<
Component> -
A new
Iterator
that allows iterating the elements of thisIterable
.no setterinherited - last → Component
-
The last element.
no setterinherited
- length → int
-
Gets the current length of this.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- single → Component
-
Checks that this iterable has only one element, and returns that element.
no setterinherited
- strictMode → bool
-
Controls whether running an unregistered query throws an error or
performs just-in-time filtering.
finalinherited
Methods
-
add(
Component component) → bool -
Marked as internal, because the users shouldn't be able to add elements
into the ComponentSet directly, bypassing the normal lifecycle handling.
override
-
addAll(
Iterable< Component> components) → int -
Marked as internal, because the users shouldn't be able to add elements
into the ComponentSet directly, bypassing the normal lifecycle handling.
override
-
any(
bool test(Component element)) → bool -
Checks whether any element of this iterable satisfies
test
.inherited -
cast<
R> () → Iterable< R> -
A view of this iterable as an iterable of
R
instances.inherited -
clear(
) → void -
Marked as internal, because the users shouldn't be able to remove elements
from the ComponentSet directly, bypassing the normal lifecycle handling.
override
-
contains(
Object? element) → bool -
Whether the collection contains an element equal to
element
.inherited -
elementAt(
int index) → Component -
Returns the
index
th element.inherited -
every(
bool test(Component element)) → bool -
Checks whether every element of this iterable satisfies
test
.inherited -
expand<
T> (Iterable< T> toElements(Component element)) → Iterable<T> -
Expands each element of this Iterable into zero or more elements.
inherited
-
firstWhere(
bool test(Component element), {Component orElse()?}) → Component -
The first element that satisfies the given predicate
test
.inherited -
fold<
T> (T initialValue, T combine(T previousValue, Component element)) → T -
Reduces a collection to a single value by iteratively combining each
element of the collection with an existing value
inherited
-
followedBy(
Iterable< Component> other) → Iterable<Component> -
Creates the lazy concatenation of this iterable and
other
.inherited -
forEach(
void action(Component element)) → void -
Invokes
action
on each element of this iterable in iteration order.inherited -
isRegistered<
C> () → bool -
Whether type
C
is registered as a cacheinherited -
join(
[String separator = ""]) → String -
Converts each element to a String and concatenates the strings.
inherited
-
lastWhere(
bool test(Component element), {Component orElse()?}) → Component -
The last element that satisfies the given predicate
test
.inherited -
map<
T> (T toElement(Component e)) → Iterable< T> -
The current elements of this iterable modified by
toElement
.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
query<
C extends Component> () → Iterable< C> -
Queries the component set (typically Component.children) for
components of type
C
.override -
rebalanceAll(
) → void -
Allows you to rebalance the whole tree. If you are dealing with
non-deterministic compare functions, you probably need to consider
rebalancing.
If the result of the priority function for some elements
changes, rebalancing is needed.
In general, be careful with using comparing functions that can change.
If only a few known elements need rebalancing, you can use
rebalanceWhere
. Note: rebalancing is not stable.inherited -
rebalanceWhere(
bool test(Component element)) → void -
Allows you to rebalance only a portion of the tree. If you are dealing
with non-deterministic compare functions, you probably need to consider
rebalancing.
If the priority function changed for certain known elements but not all,
you can use this instead of
rebalanceAll
. In general be careful with using comparing functions that can change. Note: rebalancing is not stable.inherited -
reduce(
Component combine(Component value, Component element)) → Component -
Reduces a collection to a single value by iteratively combining elements
of the collection using the provided function.
inherited
-
register<
C extends T> () → void -
Adds a new cache for a subtype
C
ofT
, allowing you to callquery
. If the cache already exists this operation is a no-op.inherited -
remove(
Component component) → bool -
Marked as internal, because the users shouldn't be able to remove elements
from the ComponentSet directly, bypassing the normal lifecycle handling.
override
-
removeAll(
Iterable< Component> components) → Iterable<Component> -
Marked as internal, because the users shouldn't be able to remove elements
from the ComponentSet directly, bypassing the normal lifecycle handling.
override
-
removeAt(
int index) → bool -
Removes the element at
index
.inherited -
removeWhere(
bool test(Component element)) → Iterable< Component> -
Marked as internal, because the users shouldn't be able to remove elements
from the ComponentSet directly, bypassing the normal lifecycle handling.
override
-
reorder(
) → void -
Sorts the components according to their
priority
s. This method is invoked by the framework when it knows that the priorities of the components in this set has changed. -
reversed(
) → Iterable< Component> -
The tree's elements in reversed order, cached when possible.
inherited
-
singleWhere(
bool test(Component element), {Component orElse()?}) → Component -
The single element that satisfies
test
.inherited -
skip(
int count) → Iterable< Component> -
Creates an Iterable that provides all but the first
count
elements.inherited -
skipWhile(
bool test(Component value)) → Iterable< Component> -
Creates an
Iterable
that skips leading elements whiletest
is satisfied.inherited -
take(
int count) → Iterable< Component> -
Creates a lazy iterable of the
count
first elements of this iterable.inherited -
takeWhile(
bool test(Component value)) → Iterable< Component> -
Creates a lazy iterable of the leading elements satisfying
test
.inherited -
toList(
{bool growable = true}) → List< Component> -
Creates a List containing the elements of this Iterable.
inherited
-
toSet(
) → Set< Component> -
Creates a Set containing the same elements as this iterable.
inherited
-
toString(
) → String -
Returns a string representation of (some of) the elements of
this
.inherited -
where(
bool test(Component element)) → Iterable< Component> -
Creates a new lazy Iterable with all elements that satisfy the
predicate
test
.inherited -
whereType<
C> () → Iterable< C> -
Creates a new lazy Iterable with all elements that have type
C
.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- defaultStrictMode ↔ bool
-
getter/setter pair