Collection Class Library Exceptions

This file contains information about the following subjects:

Exceptions Defined and Used by the Collection Classes

The exceptions defined and used in the Collection Class Library are shown in the table below (classes defined by the Collection Class Library are shown in bold). They all derive from IException, directly or indirectly.

Hierarchy of Exceptions Defined and Used by the Collection Classes

IException
   ICollectionResourceException
   ICollectionLockException
   ICollectionUnlockException
   ICollectionLockTimeOutException*
   IPreconditionViolation
      IChildAlreadyExistsException
      ICursorInvalidException
      IEmptyException
      IFullException
      IIdenticalCollectionException
      InvalidReplacementException
      IKeyAlreadyExistsException
      INotBoundedException
      INotContainsKeyException
      IPositionInvalidException
      IRootAlreadyExistsException
   IResourceExhausted
      IOutOfMemory

*not on .

Exception Causes

A precondition of a called function is a condition that the function requires to be true when it is called. The calling function must assure that this condition holds. The called function implementation may assume that the condition holds without further checking it. If a precondition does not hold, the called function's behavior is undefined.

If you want to make your programs more robust and to locate errors in the test phase, the functions your program calls should check to ensure that their preconditions hold. The Collection Class Library enables this checking through macro definitions. Because this checking often requires significant overhead, it is turned off by default. You need only use it while you are testing the system and verifying that preconditions are always met.

A call to a function that violates the function's preconditions has two possible results:

Precondition-Violations

The Collection Classes include the following precondition-violation exceptions:

Other Exceptions

The following lists the causes of the other exceptions defined or used by the Collection Classes:

Exceptions Caused by System Failures and Restrictions

System failures and restrictions are different from precondition violations. You cannot usually anticipate them, and you have no opportunity to verify that such situations, for example storage overflow, will not occur. These exceptions need to be checked for, and an exception should be thrown if they occur.



Introduction to the Collection Classes
Collection Characteristics
Adding Elements
Removing Elements
Replacing Elements
Thread Safety and the Collection Classes


Enabling Exception Checking
Implementing Bounded Collections
Guard Objects
Instantiating a Guard Object
Using Guard Objects
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
Cursors vs. Exception Handling
Instantiating the Collection Classes