home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C++ / Snippets / DynamoArray / Sorcery / DynamoArrayTest.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-02  |  1002 b   |  50 lines  |  [TEXT/CWIE]

  1. /*
  2.     DynamoArrayTest.cpp
  3.     
  4.     Makes app to test out the DynamoArray template class.
  5.     Written by Hiep Dam, From The Witches' Brew
  6.     12/2/95
  7. */
  8.  
  9. #include <iostream>
  10. #include "Class_DynamoArray.cpp"
  11. #ifdef __MWERKS__
  12. #include <SIOUX.h>
  13. #endif
  14.  
  15. typedef long ArrayType;
  16.  
  17. void main() {
  18.     DynamoArray<ArrayType> dArray;
  19.     DynamoArray<ArrayType> copiedArray;
  20.     long arrayItem;
  21.     short i;
  22.     
  23. #ifdef __MWERKS__
  24.     SIOUXSettings.asktosaveonclose = false;
  25. #endif
  26.  
  27.     cout << "Inserting items into array:" << endl;
  28.     for (i = 0; i <= 10; i++) {
  29.         dArray.Append(i);
  30.         cout << i << " ";
  31.     }
  32.     cout << endl << endl;
  33.     
  34.     copiedArray = dArray;
  35.     
  36.     cout << "Removing items from copied array:" << endl;
  37.     i = 0;
  38.     while (copiedArray.SizeOf() > 0) {
  39.         (void)copiedArray.Remove(arrayItem, i);
  40.         cout << arrayItem << " ";
  41.     }
  42.     cout << endl << endl;
  43.     
  44.     cout << "Randomly removing items from original array:" << endl;
  45.     while (dArray.SizeOf() > 0) {
  46.         (void)dArray.RandomRemove(arrayItem);
  47.         cout << arrayItem << " ";
  48.     }
  49.     cout << endl;
  50. } // END main