# CompositeEntityCollection

#### new Cesium.CompositeEntityCollection(collections, owner)
DataSources/CompositeEntityCollection.js 120

Non-destructively composites multiple `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 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
DataSources/CompositeEntityCollection.js 140

Gets the event that is fired when entities are added or removed from the collection. The generated event is a `EntityCollection.collectionChangedEventCallback`.

#### readonly id : String
DataSources/CompositeEntityCollection.js 151

Gets a globally unique identifier for this collection.

#### readonly owner : DataSource|CompositeEntityCollection
DataSources/CompositeEntityCollection.js 174

Gets the owner of this composite entity collection, ie. the data source or composite entity collection which created it.

#### readonly values : Array.<Entity>
DataSources/CompositeEntityCollection.js 163

Gets the array of Entity instances in the collection. This array should not be modified directly.

### Methods

#### addCollection(collection, index)
DataSources/CompositeEntityCollection.js 190

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
DataSources/CompositeEntityCollection.js 436

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.

#### contains(entity) → Boolean
DataSources/CompositeEntityCollection.js 256

Returns true if the provided entity is in this collection, false otherwise.

Name | Type | Description
--- | --- | ---
`entity` | Entity | The entity.

##### Returns:

true if the provided entity is in this collection, false otherwise.

#### containsCollection(collection) → Boolean
DataSources/CompositeEntityCollection.js 246

Checks to see if the composite contains a given collection.

Name | Type | Description
--- | --- | ---
`collection` | EntityCollection | the collection to check for.

##### Returns:

true if the composite contains the collection, false otherwise.

#### getById(id) → Entity|undefined
DataSources/CompositeEntityCollection.js 446

Gets an entity with the specified id.

Name | Type | Description
--- | --- | ---
`id` | String | The id of the entity to retrieve.

##### Returns:

The entity with the provided id or undefined if the id did not exist in the collection.

#### getCollection(index)
DataSources/CompositeEntityCollection.js 275

Gets a collection by index from the composite.

Name | Type | Description
--- | --- | ---
`index` | Number | the index to retrieve.

#### getCollectionsLength()
DataSources/CompositeEntityCollection.js 288

Gets the number of collections in this composite.

#### indexOfCollection(collection) → Number
DataSources/CompositeEntityCollection.js 266

Determines the index of a given collection in the composite.

Name | Type | Description
--- | --- | ---
`collection` | EntityCollection | The collection to find the index of.

##### Returns:

The index of the collection in the composite, or -1 if the collection does not exist in the composite.

#### lowerCollection(collection)
DataSources/CompositeEntityCollection.js 345

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.

#### lowerCollectionToBottom(collection)
DataSources/CompositeEntityCollection.js 375

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.

#### raiseCollection(collection)
DataSources/CompositeEntityCollection.js 333

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.

#### raiseCollectionToTop(collection)
DataSources/CompositeEntityCollection.js 357

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.

#### removeAllCollections()
DataSources/CompositeEntityCollection.js 235

Removes all collections from this composite.

#### removeCollection(collection) → Boolean
DataSources/CompositeEntityCollection.js 222

Removes a collection from this composite, if present.

Name | Type | Description
--- | --- | ---
`collection` | EntityCollection | The collection to remove.

##### Returns:

true if the collection was in the composite and was removed, false if the collection was not in the composite.

#### resumeEvents()
DataSources/CompositeEntityCollection.js 411

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 can not be called before suspendEvents.

#### suspendEvents()
DataSources/CompositeEntityCollection.js 396

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`.