C # linked list

Source: Internet
Author: User

1 public struct test
2 {
3 public string name;
4 public string num;
5}
6 public struct test1
7 {
8 public test st;
9 public string name;
10}
11 static void Main (string [] args)
12 {
13 shortlist <test> t = new shortlist <test> ();
14 test t1, t2;
15 test1 tt1, tt2;
16 t1.name = "t1 ";
17 t1.num = "1 ";
18 t2.name = "t2 ";
19 t2.num = "2 ";
20 t. AddFirst (t1 );
21 t. AddFirst (t2 );
22
23 tt1.st = t1;
24 tt2.st = t2;
25 tt1.name = "tt1 ";
26 tt2.name = "tt2 ";
27 shortlist <test1> tt = new shortlist <test1> ();
28 tt. AddFirst (tt1 );
29 tt. AddFirst (tt2 );
30 bytes listnode <test1> current11 = tt. FindLast (tt1 );
31 test1 tr1 = current11.Value;
32
33 bytes listnode <test> current1 = t. FindLast (t1 );
34 test tr = current1.Value;
35
36
37 string [] words = {"the", "fox", "jumped", "over", "the", "dog "};
38 shortlist <string> sentence = new shortlist <string> (words );
39 Display (sentence );
40
41 Console. WriteLine ("sentence. Contains (" jumped ") = {0 }",
42 sentence. Contains ("jumped "));
43
44 // Add the word "today" to the beginning of the linked list.
45 // Remove the new node, and add it to the end of the list.
46 sentence. AddFirst ("today ");
47 Display (sentence );
48
49 listen listnode <string> mark1 = sentence. First;
50 sentence. RemoveFirst ();
51 sentence. AddLast (mark1 );
52 Display (sentence );
53
54 sentence. RemoveLast ();
55 sentence. AddLast ("yesterday ");
56 Display (sentence );
57
58 mark1 = sentence. Last;
59 sentence. RemoveLast ();
60 sentence. AddFirst (mark1 );
61 Display (sentence );
62
63 sentence. RemoveFirst ();
64
65 bytes listnode <string> current = sentence. FindLast ("");
66 DisplayNode (current );
67
68 // sentence. Remove (current );
69
70 sentence. AddAfter (current, "old ");
71 sentence. AddAfter (current, "lazy ");
72 DisplayNode (current );
73
74 current = sentence. Find ("fox ");
75 DisplayNode (current );
76
77 sentence. AddBefore (current, "quick ");
78 sentence. AddBefore (current, "brown ");
79 DisplayNode (current );
80
81 // Keep a reference to the current node, "fox", and to
82 // previous node in the list. Use the Find method to locate
83 // the node containing the value "dog". Show the position.
84 mark1 = current;
85 & nbs

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.