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.
This wrapper also guaranteed that Component.prepare, Loadable.onLoad
and all the lifecycle methods are called properly.
- Inheritance
-
- Object
- IterableMixin<
Component> - OrderedSet<
Component> - QueryableOrderedSet<
Component> - ComponentSet
- Available Extensions
Constructors
Properties
-
addLater
→ UnmodifiableListView<
Component> -
All the children that has been queued to be added to the component set.
no setter
- first → Component
-
The first element.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
Whether the component set is empty and that there are no components marked
to be added later.
no setteroverride
- 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
- parent → Component
-
This is the "prepare" function that will be called before the
component is added to the component list by the add/addAll methods.
It is also called when the component changes parent.
final
- 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 c) → bool -
Prepares and registers one component to be added on the next game tick.
override
-
addAll(
Iterable< Component> components) → int -
Prepares and registers a list of components to be added on the next game
tick.
override
-
addChild(
Component component) → Future< void> - Prepares and registers one component to be added on the next game tick.
-
addChildren(
Iterable< Component> components) → Future<void> - Prepares and registers a list of component to be added on the next game tick.
-
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 -
changePriority(
Component component, int priority) → bool -
Changes the priority of
component
and reorders the games component list. -
clear(
) → void -
Marks all existing components to be removed from the components list on
the next game tick.
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 T> () → List< C> -
Allow you to find a subset of this set with all the elements
e
for which the conditione is C
is true. This is equivalent toinherited -
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.
override
-
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.
override
-
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 call query. If the cache already exists this operation is a no-op.inherited -
remove(
Component c) → bool -
Marks a component to be removed from the components list on the next game
tick.
override
-
removeAll(
Iterable< Component> components) → Iterable<Component> -
Marks a list of components to be removed from the components list on the
next game tick. This will return the same list as sent in.
override
-
removeWhere(
bool test(Component element)) → Iterable< Component> -
Remove all elements that match the
test
condition; returns the removed elements.inherited -
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 -
updateComponentList(
) → void - Call this on your update method.
-
where(
bool test(Component element)) → Iterable< Component> -
Creates a new lazy Iterable with all elements that satisfy the
predicate
test
.inherited -
whereType<
T> () → Iterable< T> -
Creates a new lazy Iterable with all elements that have type
T
.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
createDefault(
Component parent, {bool strictMode = true}) → ComponentSet - Creates a ComponentSet with a default value for the compare function, using the Component's priority for sorting.