home *** CD-ROM | disk | FTP | other *** search
- <code DEFINE_MAIN>
- --
- -- sample driver for the collection class guides
- --
- //-----------------------------------------------------------------------------
- // Usage sample.
- //-----------------------------------------------------------------------------
- IBoolean printItem($ELEMENT_TYPE$ const& t, void*)
- {
- <if ($ELEMENT_PTR$)>
- cout << *t << endl;
- <else>
- cout << t << endl;
- </if>
- return true;
- }
-
- main()
- {
- $CLTN_NAME$ i$CLTN_NAME$;
- $CLTN_NAME$::Cursor myCursor(i$CLTN_NAME$);
- --
- -- Define values for element (key) initialization
- --
- <define VAL1>"C.Lau"\</define>
- <define VAL2>"T.Glover"\</define>
- <define VAL3>"C.Piekny"\</define>
- <define VAL4>"D.Birsan"\</define>
- --
- -- Define elements to add
- --
-
- // Use the customized constructor. Revise this if necessary.
- $ELEMENT_CLASS$ element1($VAL1$);
- $ELEMENT_CLASS$ element2($VAL2$);
- $ELEMENT_CLASS$ element3($VAL3$);
- $ELEMENT_CLASS$ element4($VAL4$);
-
- --
- -- Add the elements.
- --
- <if ($ELEMENT_PTR$)>
- i$CLTN_NAME$.add(&element1);
- i$CLTN_NAME$.add(&element1);
- i$CLTN_NAME$.add(&element2);
- i$CLTN_NAME$.add(&element3);
- i$CLTN_NAME$.add(&element4);
- <else>
- i$CLTN_NAME$.add(element1);
- i$CLTN_NAME$.add(element1);
- i$CLTN_NAME$.add(element2);
- i$CLTN_NAME$.add(element3);
- i$CLTN_NAME$.add(element4);
- </if>
-
- // List all the items
- i$CLTN_NAME$.allElementsDo(printItem);
- // List the total number of items
- cout << i$CLTN_NAME$.numberOfElements() << " added" << endl;
-
- // Remove a key item
- <if ($STACK_TYPE$)>
- i$CLTN_NAME$.pop();
- <else>\<if ($QUEUE_TYPE$)>
- i$CLTN_NAME$.removeFirst();
- <else>
- myCursor.setToFirst();
- i$CLTN_NAME$.removeAt(myCursor);
- </if>\</if>
-
- // List the total number of items
- cout << "After remove, the total number of items is: ";
- cout << i$CLTN_NAME$.numberOfElements() << "\n\n";
-
- // List all the items
- i$CLTN_NAME$.allElementsDo(printItem);
- }
-
- //------------------------------------------------------------------------------
- // COLLECTION CLASSES: End of VisualAge C++ SmartGuide generation
- //------------------------------------------------------------------------------
- </code DEFINE_MAIN>