The following illustrates the use of memory management with element operation classes.
Suppose you want to use your own element operation class to provide a special form of memory management. For example, you want an entire collection (the collection body plus the elements) to reside in a database, or in shared memory. To do this you can code:
IGSequenceAsList<Element, MyOperationsClass>
where MyOperationsClass is an element operations class you have coded, which provides your own element allocate and deallocate operations. This class may or may not inherit from previously described template classes, except that it must inherit from IStdMemOps.
A certain instance of your collection is instantiated together with an instance of your MyOperationsClass. You can retrieve the this pointer of this instance of MyOperationsClass to find out where the collection is instantiated, and you can use this address in your implementation of the allocate element function to allocate your elements in the same memory pool where your collection resides.
Introduction
to the Collection Classes
Overall
Implementation Structure
Element
Functions and Key-Type Functions
Collection Characteristics
Ordering
of Collection Elements
Access
by Key
Equality
Relation
Uniqueness of Entries
Flat
Collections
Trees
Defining Equality
Relation
Defining Key or
Element Equality
Defining an
Operations Class
Using or
Defining an Element Operation Class