new CompositeEntityCollection(collections, owner)
非破坏性地将多个 EntityCollection 实例合成为一个集合。
如果一个具有相同 ID 的实体存在于多个集合中,它会被非破坏性地合并为一个新的实体实例。
如果一个实体在多个集合中具有相同的属性,则会使用该实体在其所属列表的最后一个集合中的属性。
CompositeEntityCollection 几乎可以在任何需要使用实体集合的地方使用。
| Name | Type | Description |
|---|---|---|
collections |
Array.<EntityCollection> |
可选
要合并的实体集合实例的初始列表。 |
owner |
DataSource | CompositeEntityCollection |
可选
创建此集合的数据源(或复合实体集合)。 |
Members
-
readonly collectionChangedEvent
-
获取从集合中添加或删除实体时触发的事件。生成的事件是一个
EntityCollection.collectionChangedEventCallback。 -
readonly idString
-
获取该集合的全局唯一标识符。
-
readonly ownerDataSource CompositeEntityCollection
-
获取此复合实体集合的所有者,即创建它的数据源或复合实体集合。
-
readonly valuesArray.<Entity>
-
获取集合中实体实例的数组。这个数组不能被直接修改。
Methods
-
addCollection(collection, index)
-
将集合添加到组合文件中。
Name Type Description collectionEntityCollection 要添加的集合。
indexNumber 可选 要添加集合的索引。如果省略,集合将被添加在所有现有集合的顶部。
Throws:
-
索引(如果提供)必须大于或等于零,且小于或等于集合数。
- Type
- DeveloperError
-
-
computeAvailability(){TimeInterval}
-
计算集合中实体的最大可用性。 如果集合中包含无限可用数据和非无限数据,则只返回与非无限数据相关的时间间隔。 如果所有数据都是无限的,则将返回无限区间。
Returns:
Type Description TimeInterval 集合中实体的可用性。 -
contains(entity){Boolean}
-
如果提供的实体在此集合中,则返回true,否则返回false。
Name Type Description entityEntity 实体。
Returns:
Type Description Boolean 如果提供的实体在此集合中,则为True,否则为false。 -
containsCollection(collection){Boolean}
-
检查复合内容是否包含给定的集合。
Name Type Description collectionEntityCollection 要检查的集合。
Returns:
Type Description Boolean 如果组合包含该集合,则为True,否则为false。 -
getById(id){Entity}
-
获取具有指定 id 的实体。
Name Type Description idObject 要检索的实体的 id。
Returns:
Type Description Entity 具有所提供 id 的实体;如果集合中不存在 id,则未定义。 -
getCollection(index)
-
按索引从复合数据中获取集合。
Name Type Description indexNumber 要检索的索引。
-
getCollectionsLength()
-
获取此合成中的集合数量。
-
indexOfCollection(collection){Number}
-
确定组合中给定集合的索引。
Name Type Description collectionEntityCollection 要查找索引的集合。
Returns:
Type Description Number 集合在组合文件中的索引;如果集合不存在于组合文件中,则索引为-1。 -
lowerCollection(collection)
-
将集合在合成中的位置降低一个。
Name Type Description collectionEntityCollection 移动的集合。
Throws:
-
本综合样本中没有该系列。
- Type
- DeveloperError
-
-
lowerCollectionToBottom(collection)
-
将集合下放到合成体底部。
Name Type Description collectionEntityCollection 移动的集合。
Throws:
-
本综合样本中没有该系列。
- Type
- DeveloperError
-
-
raiseCollection(collection)
-
将集合在合成中的位置向上提升一个。
Name Type Description collectionEntityCollection 移动的集合。
Throws:
-
本综合样本中没有该系列。
- Type
- DeveloperError
-
-
raiseCollectionToTop(collection)
-
将一个集合提升到合成的顶部。
Name Type Description collectionEntityCollection 移动的集合。
Throws:
-
本综合样本中没有该系列。
- Type
- DeveloperError
-
-
removeAllCollections()
-
移除该合成中的所有集合。
-
removeCollection(collection){Boolean}
-
如果存在,则从该复合元素中移除一个集合。
Name Type Description collectionEntityCollection 要移除的集合。
Returns:
Type Description Boolean 如果集合在合成中并已被移除,则为 true;如果集合不在合成中,则为 false。 -
resumeEvents()
-
当添加或删除一个项目时,立即恢复引发
EntityCollection#collectionChanged事件。 任何在事件暂停期间进行的修改,都将在调用此函数时作为单个事件触发。 如果事件也被恢复,该函数还能确保集合被重新组合。 该函数是引用计数函数,只要有相应的EntityCollection#resumeEvents调用,就可以安全地多次调用。Throws:
-
resumeEvents can not be called before suspendEvents.
- Type
- DeveloperError
-
-
suspendEvents()
-
防止
EntityCollection#collectionChanged事件被触发,直到对EntityCollection#resumeEvents进行了相应的调用。这样就能有效地添加和删除许多项目。 当事件暂停时,集合的重新组合也将暂停,因为这可能是一个代价高昂的操作。 只要有相应的EntityCollection#resumeEvents调用,就可以安全地多次调用该函数。