module Entitas::Helper::Entities(TEntity)
Direct including types
Defined in:
entitas/helpers/entities.crInstance Method Summary
-
#count : Int32
See
#size
- #each(&block : TEntity -> Nil)
-
#get_entities
Returns all entities which are currently in the context.
-
#has_entity?(entity : TEntity) : Bool
Determines whether the context has the specified entity.
-
#size
Returns the total number of
TEntity
in thisGroup
-
#sort(&block : TEntity, TEntity -> U) : Array(TEntity) forall U
Returns a new array with all elements sorted based on the comparator in the given block.
Instance Method Detail
def sort(&block : TEntity, TEntity -> U) : Array(TEntity) forall U
#
Returns a new array with all elements sorted based on the comparator in the given block.
The block must implement a comparison between two elements a and b,
where a < b
returns -1
, a == b
returns 0
, and a > b
returns 1
.
The comparison operator <=>
can be used for this.
a = [3, 1, 2]
b = a.sort { |a, b| b <=> a }
b # => [3, 2, 1]
a # => [3, 1, 2]