# EntityCollection

#### new Cesium.EntityCollection(owner)
DataSources/EntityCollection.js 53

  An observable collection of `Entity` instances where each entity has a unique id.

  Name | Type | Description
  --- | --- | ---
  `owner` | DataSource | CompositeEntityCollection | optional The data source (or composite entity collection) which created this collection.

### Members

#### readonlycollectionChanged : Event
DataSources/EntityCollection.js 115

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

#### readonlyid : String
DataSources/EntityCollection.js 126

  Gets a globally unique identifier for this collection.

#### readonlyowner : DataSource|CompositeEntityCollection
DataSources/EntityCollection.js 149

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

#### readonlyvalues : Array.<Entity>
DataSources/EntityCollection.js 138

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

### Methods

#### staticCesium.EntityCollection.collectionChangedEventCallback(collection, added, removed, changed)
DataSources/EntityCollection.js 105

  The signature of the event generated by `EntityCollection#collectionChanged`.

  Name | Type | Description
  --- | --- | ---
  `collection` | EntityCollection | The collection that triggered the event.
  `added` | Array.<Entity> | The array of `Entity` instances that have been added to the collection.
  `removed` | Array.<Entity> | The array of `Entity` instances that have been removed from the collection.
  `changed` | Array.<Entity> | The array of `Entity` instances that have been modified.

#### add(entity) → Entity
DataSources/EntityCollection.js 202

  Add an entity to the collection.

  Name | Type | Description
  --- | --- | ---
  `entity` | Entity | The entity to be added.

  ##### Returns:

  The entity that was added.

  ##### Throws:

  - DeveloperError : An entity with already exists in this collection.

#### computeAvailability() → TimeInterval
DataSources/EntityCollection.js 164

  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/EntityCollection.js 250

  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.

#### getById(id) → Entity
DataSources/EntityCollection.js 322

  Gets an entity with the specified id.

  Name | Type | Description
  --- | --- | ---
  `id` | Object | 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.

#### getOrCreateEntity(id) → Entity
DataSources/EntityCollection.js 338

  Gets an entity with the specified id or creates it and adds it to the collection if it does not exist.

  Name | Type | Description
  --- | --- | ---
  `id` | Object | The id of the entity to retrieve or create.

  ##### Returns:

  The new or existing object.

#### remove(entity) → Boolean
DataSources/EntityCollection.js 237

  Removes an entity from the collection.

  Name | Type | Description
  --- | --- | ---
  `entity` | Entity | The entity to be removed.

  ##### Returns:

  true if the item was removed, false if it did not exist in the collection.

#### removeAll()
DataSources/EntityCollection.js 290

  Removes all Entities from the collection.

#### removeById(id) → Boolean
DataSources/EntityCollection.js 265

  Removes an entity with the provided id from the collection.

  Name | Type | Description
  --- | --- | ---
  `id` | Object | The id of the entity to remove.

  ##### Returns:

  true if the item was removed, false if no item with the provided id existed in the collection.

#### resumeEvents()
DataSources/EntityCollection.js 85

  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 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/EntityCollection.js 72

  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. This function can be safely called multiple times as long as there are corresponding calls to `EntityCollection#resumeEvents`.