Using of NCollection

Im not very familiar with templates so I´m searching for a simple example. I want a kind of map where I can insert an object of myclass.

What I found in the documentation:
typedef NCollection_DataMap MapOfMyClass;

So what now... How can I initialize the object. How can I insert objects. (iterating over this collection is discribed in the help)

As far as I known I have to overwrite some functions... but which one and how. Some pseudocode would be usefull...

Thx in Advance..

Rob Bachrach's picture

MapOfMyClass myMap; // create an instance of my map
myMap.Bind(1.0, myClass1); // add a class instance under a key of 1.0
myMap.Bind(1.0, myClass2); // update the binding for key 1.0
myMap(1.0) = myClass3; // alternate way of updating an existing binding
bool bExists = myMap.IsBound(1.0); // checks for a key in the map
myClass1 = myMap.Find(1.0); // get the value for a key
myClass1 = myMap(1.0); // alternate way of getting the value for a key
myMap.UnBind(1.0); // removes a key from the map
int items = myMap.Size(); // returns the number of items

// iterate
MapOfMyClass::Iterator it;
while (it.More()) {
cout << it.Key() << "=" << it.Value() << endl;
it.ChangeValue() = myClass4;

StefanKunze's picture

BIG Thx to Rob.....

Going down on my knees, lifting my arms and saying "I´m not worthy, I´m not worthy..." d(^-^)b

P.S. In my eyes this should be included into the help.