Code B:
#include
Class it {element * curr; public: inline it (Element * head): curr (} {} inline Bool Hasnext () const {return curr! = 0;} inline int next () {=} (curr == 0) Throw nosuchelementexception (); const project = curr-> datum; curr = curr-> next; return result;}}; element * head; element * tail; public: inline list () {head = tail = 0;} inline Bool iSempty () {return head == 0;} void purge () {Element * curr = head; element * next; while (curr! = 0) {next = curr; curr = next;}
Head = tail = 0;} Inline void append (const INT Datum) {if (head == 0) {head = tail = new element (datum, 0);} else {tail-> next = new element (Datum, 0 ); Tail = tail-> next;}}} void extract (const Int Datum) {if (iSempty ()) throw nosuchelementexception (); element * curr = head; element * pre = 0; while (curr! = 0 && curr -> DATUM! = DATUM) {pre = curr; curr = curr-> next;} if (curr == 0) throw nosuchelementexception (); if (curr == head) {ELEMENT * NEXT = head-> next; delete Head; head = next;} else {pre-> next = curr-> next; delete curr;} if (curr == tail) TAIL = pre;} Void Assign (List * another) {if (this == Another) Return; it * it = another-> iterator (); purge (); while (it));} delete iter;} inline it}}} NEW iTER (HEAD);}}; int main () {list from, to; const length = 100000; const INNNERLOOPS = 100;
INT i; for (i = 0; i Clock_t start, end; double timeuse; For (i = 0; i <3; i ) {printf ("LOOP% D: / N", I); TimeUse = 0; INT K, J; For (k = 0; k TimeUse = 0; for (k = 0; k TimeUse = 0; for (k = 0; k Compilation method: CL / G7 / O2 / ARCH: SSE2 list.cpp Note: I am P4, so / g7 / arch: sSE2, not to remove it, it is