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

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 this Iterable.
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> c) int
Prohibit method addAll() inherited from the QueryableOrderedSet. If this was allowed, then the user would be able to bypass standard lifecycle methods of the Component class.
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
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 indexth 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 cache
inherited
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 condition e is C is true. This is equivalent to
inherited
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 of T, allowing you to call query. 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>
Prohibit method removeAll() inherited from the QueryableOrderedSet. If this was allowed, then the user would be able to bypass standard lifecycle methods of the Component class.
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 while test 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 Properties

defaultStrictMode bool
getter/setter pair

Static Methods

createDefault() ComponentSet