非破坏性复合多个 Non-destructively composites multiple
EntityCollection 实例到单个集合中。如果具有相同 ID 的实体存在于多个集合中,则会以非破坏性方式将其合并到单个新实体实例中。如果一个实体在多个集合中具有相同的属性,则使用该实体所属列表的最后一个集合中的属性。 CompositeEntityCollection 几乎可以在任何使用 EntityCollection 的地方使用。 instances into a single collection. If a Entity with the same ID exists in multiple collections, it is non-destructively merged into a single new entity instance. If an entity has the same property in multiple collections, the property of the Entity in the last collection of the list it belongs to is used. CompositeEntityCollection can be used almost anywhere that a EntityCollection is used.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
collections |
Array.<EntityCollection> | 可选 optional 要合并的 EntityCollection 实例的初始列表。 The initial list of EntityCollection instances to merge. |
owner |
DataSource | CompositeEntityCollection | 可选 optional 创建此集合的数据源(或复合实体集合)。 The data source (or composite entity collection) which created this collection. |
成员 Members
readonly collectionChanged : Event
获取在集合中添加或删除实体时触发的事件。生成的事件是 Gets the event that is fired when entities are added or removed from the collection. The generated event is a
EntityCollection.collectionChangedEventCallback.
获取此集合的全局唯一标识符。 Gets a globally unique identifier for this collection.
readonly owner : DataSource|CompositeEntityCollection
获取此复合实体集合的所有者,即。创建它的数据源或复合实体集合。 Gets the owner of this composite entity collection, ie. the data source or composite entity collection which created it.
readonly values : Array.<Entity>
获取集合中Entity实例的数组。不应直接修改该数组。 Gets the array of Entity instances in the collection. This array should not be modified directly.
方法 Methods
将集合添加到组合中。 Adds a collection to the composite.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
collection |
EntityCollection | 要添加的集合。 the collection to add. |
index |
number | 可选 optional 添加集合的索引。如果省略,该集合将添加到所有现有集合的顶部。 the index to add the collection at. If omitted, the collection will added on top of all existing collections. |
抛出: Throws:
-
DeveloperError :索引(如果提供)必须大于或等于零且小于或等于集合数。 : index, if supplied, must be greater than or equal to zero and less than or equal to the number of collections.
computeAvailability() → TimeInterval
计算集合中实体的最大可用性。如果集合包含无限可用数据和非无限数据的混合,它将仅返回与非无限数据相关的间隔。如果所有数据都是无限的,则将返回无限的间隔。 Computes the maximum availability of the entities in the collection. If the collection contains a mix of infinitely available data and non-infinite data, It will return the interval pertaining to the non-infinite data only. If all data is infinite, an infinite interval will be returned.
返回: Returns:
集合中实体的可用性。 The availability of entities in the collection.
如果提供的实体在此集合中,则返回 true,否则返回 false。 Returns true if the provided entity is in this collection, false otherwise.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
entity |
Entity | 实体。 The entity. |
返回: Returns:
如果提供的实体在此集合中,则为 true,否则为 false。 true if the provided entity is in this collection, false otherwise.
检查组合是否包含给定的集合。 Checks to see if the composite contains a given collection.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
collection |
EntityCollection | 要检查的集合。 the collection to check for. |
返回: Returns:
如果组合包含集合,则为 true,否则为 false。 true if the composite contains the collection, false otherwise.
getById(id) → Entity|undefined
获取具有指定 id 的实体。 Gets an entity with the specified id.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
id |
string | 要检索的实体的 ID。 The id of the entity to retrieve. |
返回: Returns:
具有提供的 id 的实体,如果集合中不存在该 id,则实体未定义。 The entity with the provided id or undefined if the id did not exist in the collection.
从组合中按索引获取集合。 Gets a collection by index from the composite.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
index |
number | 要检索的索引。 the index to retrieve. |
获取此组合中的集合数。 Gets the number of collections in this composite.
确定组合中给定集合的索引。 Determines the index of a given collection in the composite.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
collection |
EntityCollection | 要查找其索引的集合。 The collection to find the index of. |
返回: Returns:
组合中集合的索引,如果组合中不存在该集合,则为 -1。 The index of the collection in the composite, or -1 if the collection does not exist in the composite.
将组合中的集合降低一个位置。 Lowers a collection down one position in the composite.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
collection |
EntityCollection | 要移动的集合。 the collection to move. |
抛出: Throws:
-
DeveloperError :集合不在此组合中。 : collection is not in this composite.
将集合降低到组合的底部。 Lowers a collection to the bottom of the composite.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
collection |
EntityCollection | 要移动的集合。 the collection to move. |
抛出: Throws:
-
DeveloperError :集合不在此组合中。 : collection is not in this composite.
将集合在组合中的位置提升一位。 Raises a collection up one position in the composite.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
collection |
EntityCollection | 要移动的集合。 the collection to move. |
抛出: Throws:
-
DeveloperError :集合不在此组合中。 : collection is not in this composite.
将集合提升到组合的顶部。 Raises a collection to the top of the composite.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
collection |
EntityCollection | 要移动的集合。 the collection to move. |
抛出: Throws:
-
DeveloperError :集合不在此组合中。 : collection is not in this composite.
从此组合中删除所有集合。 Removes all collections from this composite.
从此组合中删除集合(如果存在)。 Removes a collection from this composite, if present.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
collection |
EntityCollection | 要删除的集合。 The collection to remove. |
返回: Returns:
如果集合位于组合中并已被删除,则为 true;如果集合不在组合中,则为 false。 true if the collection was in the composite and was removed, false if the collection was not in the composite.
恢复筹集资金 Resumes raising
EntityCollection#collectionChanged 添加或删除项目时立即发生事件。调用此函数时,在事件暂停期间所做的任何修改都将作为单个事件触发。如果事件也恢复,此函数还确保重新组合集合。该函数是引用计数的,只要有相应的调用,就可以安全地多次调用 events immediately when an item is added or removed. Any modifications made while while events were suspended will be triggered as a single event when this function is called. This function also ensures the collection is recomposited if events are also resumed. This function is reference counted and can safely be called multiple times as long as there are corresponding calls to EntityCollection#resumeEvents.
抛出: Throws:
-
DeveloperError :resumeEvents不能在suspendEvents之前调用。 : resumeEvents can not be called before suspendEvents.
Prevents
EntityCollection#collectionChanged 事件从引发直到进行相应的调用 events from being raised until a corresponding call is made to EntityCollection#resumeEvents,此时将引发一个涵盖所有暂停操作的事件。这允许有效地添加和删除许多项目。当事件暂停时,集合的重新组合也将暂停,因为这可能是一项成本高昂的操作。只要有相应的调用,该函数就可以安全地多次调用 , at which point a single event will be raised that covers all suspended operations. This allows for many items to be added and removed efficiently. While events are suspended, recompositing of the collections will also be suspended, as this can be a costly operation. This function can be safely called multiple times as long as there are corresponding calls to EntityCollection#resumeEvents.
