### Support for Notifications

The Collection Classes include special classes that support notifications. For every concrete flat collection class (for example ISequence), there is a corresponding notification-enabled collection class (for example IVSequence).

All collection methods that modify a collection send notifications to observers. The class IVCollection defines four notification IDs for collection classes:

- addId--Sent if an element is added to the collection
- removeId--Sent if an element is removed from the collection
- replaceId--Sent if an element is replaced in the collection
- modifyId--Sent if a collection is changed in any way other than those mentioned above.

For notifications addId, removeId and replaceId, you can use INotificationEvent::eventData to access event data generated by collections. This event data is an object that includes a cursor method to access a collection cursor. The cursor points to the element referred to by the modification method. For example, if addId is the notification, the cursor points to the added element. The replaceId notification also gives you access to a copy of the element that was replaced.

Collection notifications addId, removeId and replaceId pass a pointer to the class IVCollectionEventData.

For the notifications addId and modifyId, the library sends notification after the modification occurs. For the notification removedId and replaceId the library sends notification before the collection is changed, otherwise you would not be able to use the cursor to refer to the element being removed.

Notifications are only sent if the collection is changed by the method. The following methods do not create a notification:

- removeAll for an empty collection
- add, when add does not actually add an element (for example, because the element already exists in a unique collection, or because the collection is full)
- remove if the element is not in the collection
- locateOrAdd if the element is already in the collection

Introduction to the Collection Classes
Adding Elements
Removing Elements
Replacing Elements

Adding an Element to a Collection
Removing an Element from a Collection
Using Cursors to Locate and Access Elements
Using Cursors to Iterate Over a Collection
Using allElementsDo and Applicators to Iterate Over a Collection
Instantiating the Collection Classes