Presentation is loading. Please wait.

Presentation is loading. Please wait.

2004 A.M. Turing Award Winners Vinton G. Cerf Robert E. Kahn Citation For pioneering work on internetworking, including the design and implementation of.

Similar presentations


Presentation on theme: "2004 A.M. Turing Award Winners Vinton G. Cerf Robert E. Kahn Citation For pioneering work on internetworking, including the design and implementation of."— Presentation transcript:

1 2004 A.M. Turing Award Winners Vinton G. Cerf Robert E. Kahn Citation For pioneering work on internetworking, including the design and implementation of the Internet's basic communications protocols, TCP/IP, and for inspired leadership in networking. Press Release New York Times Article Biographical Information: Vinton G. CerfVinton G. Cerf, MCI Robert E. KahnRobert E. Kahn, CNRI

2 Linked List - II

3 Default Memberwise Assignment Assignment operator (=) –Can assign one object to another of same type –Default: memberwise assignment Each right member assigned individually to left member Passing, returning objects –Default: pass-by-value Copy of object passed, returned Compiler-generated copy constructor –You must provide your own copy constructor when there are member pointer variables And destructor too

4 Deep Copy (1 of 3) front ABC 0 itemlinkitemlinkitemlinksize 3 slist1 slist2 front XY 0 itemlinkitemlinksize 2 Consider the following two ShoppingList objects What would the result of slist2 = slist1; be if the default copy behavior took place?

5 Deep Copy (2 of 3) front ABC 0 itemlinkitemlinkitemlinksize 3 slist1 slist2 front XY 0 itemlinkitemlinksize 3 slist2 becomes a “shallow copy” of slist1 slist2 doesn’t get a copy of slist1 data All references to slist2 data are lost!

6 Deep Copy (3 of 3) front ABC 0 itemlinkitemlinkitemlinksize 3 slist1 slist2 frontsize 3 Here is what slist2 would look like as a “deep copy” of slist1 Note that slist2 has its own set of data ABC 0 itemlinkitemlinkitemlink

7 Clone Example (1 of 8) ShoppingList::ShoppingList(const ShoppingList &slist) { Node *cur1, *cur2; front ABC 0 itemlinkitemlinkitemlinksize 3 slist *this front XY 0 itemlinkitemlinksize 2 cur1 ? cur2 ?

8 Clone Example (2 of 8) this->deleteAll(); this->size = slist.size; front ABC 0 itemlinkitemlinkitemlinksize 3 front 0 size 3 cur1 ? cur2 ? slist *this

9 Clone Example (3 of 8) this->front = new Node(*(slist.front).item); front ABC 0 itemlinkitemlinkitemlinksize 3 frontsize 3 cur1 ? cur2 ? A itemlink 0 slist *this

10 Clone Example (4 of 8) cur1 = this->front; cur2 = slist.front; front ABC 0 itemlinkitemlinkitemlinksize 3 frontsize 3 cur1cur2 A itemlink 0 slist *this

11 Clone Example (5 of 8) while (cur2->link) { cur2 = cur2->link; cur1->link = new Node(*cur2); cur1 = cur1->link; } front ABC 0 itemlinkitemlinkitemlinksize 3 frontsize 3 cur1cur2 A itemlink slist *this B itemlink 0 First iteration

12 Clone Example (6 of 8) while (cur2->link) { cur2 = cur2->link; cur1->link = new Node(*cur2); cur1 = cur1->link; } front ABC 0 itemlinkitemlinkitemlinksize 3 frontsize 3 cur1cur2 A itemlink slist *this B itemlink Second iteration C 0 itemlink

13 Clone Example (7 of 8) cur1 = cur2 = 0; front ABC 0 itemlinkitemlinkitemlinksize 3 frontsize 3 cur1 0 cur2 0 A itemlink slist *this B itemlink C 0 itemlink

14 Clone Example (8 of 8) } front ABC 0 itemlinkitemlinkitemlinksize 3 frontsize 3 A itemlink slist *this B itemlink C 0 itemlink

15 Doubly Linked List Each node has 2 pointers, one to the node before and one to the node after No longer limited to left-to-right pointer movement Typically, a rear pointer is employed to simplify reverse traversals front A datarlinkllink B datarlinkllink C datarlinkllink rear

16 Circular Linked List “Last” node’s link points at the “front” node Concept of “front” optional cur A datalink B datalink C datalink E datalink D datalink


Download ppt "2004 A.M. Turing Award Winners Vinton G. Cerf Robert E. Kahn Citation For pioneering work on internetworking, including the design and implementation of."

Similar presentations


Ads by Google