Chapter 23 Data (Abyss web server) Structures and Collections 1151 (Fig.

Chapter 23 Data Structures and Collections 1151 (Fig. 23.4) to set instance variable datato refer to the objectpassed as the first argument and sets the nextreference to null. 3. If the list is not empty, the new node is threaded (not to be confused with multithreading) into the list by setting firstNodeto refer to a new ListNodeobject initialized with insertItem and firstNode (lines 84 85). When the List- Nodeconstructor (lines 23 27 of Fig. 23.4) executes, it sets instance variable data to refer to the object passed as the first argument and performs the insertion by setting the nextreference to the ListNodepassed as the second argument. 1 // Fig. 23.4: LinkedListLibrary.cs 2 // Class ListNode and class List definitions. 3 4 using System; 5 6 namespace LinkedListLibrary 7 { 8 // class to represent one node in a list 9 class ListNode 10 { 11 private object data; 12 private ListNode next; 13 14 // constructor to create ListNode that refers to dataValue 15 // and is last node in list 16 public ListNode( object dataValue ) 17 : this( dataValue, null ) 18 { 19 } 20 21 // constructor to create ListNode that refers to dataValue 22 // and refers to next ListNode in List 23 public ListNode( object dataValue, ListNode nextNode ) 24 { 25 data = dataValue; 26 next = nextNode; 27 } 28 29 // property Next 30 public ListNode Next 31 { 32 get 33 { 34 return next; 35 } 36 37 set 38 { 39 next = value; 40 } 41 } Fig. 23.4 Fig. 23.4Fig. 23FiFi.4g. 23.4g.23.4Definitions of classes ListNode, Listand EmptyListException. (Part 1 of 5.)
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision tomcat hosting services

Leave a Reply