// file: $isip/doc/examples/class/dstr/dstr_example_01/example.cc // version: $Id: example.cc 5947 2000-12-17 17:53:55Z hamaker $ // // isip include files // #include #include // main program starts here: // this example produces a linked list of randomly generated nonsense strings // note that the linked list has two modes - USER and SYSTEM. // we use USER mode here to demonstrate the way that memory can be // controlled by the user while still taking advantage of our dstr // classes // int main() { // declare a USER mode DoubleLinkedList // DoubleLinkedList list_string(DoubleLinkedList::USER); // add 10 randomly generated strings, all with lengths on the range [5,20], // to the linked list // for (long i = 0; i < 10; i++) { // generate the random string // String* tmp_str = new String(); tmp_str->rand(5,20); // add the random string to the list. this inserts at the current location // and changes the current location to be this item. // list_string.insert(tmp_str); } // display the contents of the list // list_string.debug(L"list of random strings"); // free the memory allocated for the list // String* tmp_str = (String*)NULL; while (list_string.removeFirst(tmp_str)) { delete tmp_str; } // exit gracefully // Integral::exit(); }