Ejemplo n.º 1
0
        public static void Main()
        {
            linkedList l1 = new linkedList();
            linkedList l2 = new linkedList();

            Console.WriteLine("enter 1 to add data to linked list");
            int x = Convert.ToInt32(Console.ReadLine());

            for (int i = 0; i < 5; i++)
            {
                Console.WriteLine("enter the value to be entered");
                int val = Convert.ToInt32(Console.ReadLine());

                l1.insertNode(val);
            }
            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine("enter the value to be entered");
                int val = Convert.ToInt32(Console.ReadLine());

                l2.insertNode(val);
            }
            l1.display();
            l2.display();
            l1.merge(l2);
            l1.display();
            Console.ReadKey();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            node n1 = new node(7);

            Console.WriteLine(n1.value);
            Console.WriteLine(n1.next == null);
            linkedList list3 = new linkedList(1);

            list3.insertFirst(2);
            linkedList list = new linkedList(28);

            list.insertLast(3);
            list.insertLast(10);
            list.insertLast(4);
            list.insertFirst(1);
            list.insertAfter(list.findNode(10), 11);
            Console.WriteLine(list.exists(4));
            node FoundIt = list.findNode(4);

            if (FoundIt != null)
            {
                Console.WriteLine(FoundIt.value);
            }
            else
            {
                Console.WriteLine("NOT FOUND !!!");
            }
            list.printList();
            list.removeFirst();
            list.printList();
            list.remove(10);
            list.printList();
            Console.WriteLine("***********************");
            linkedList list2 = new linkedList(8);

            list2.addSorted(1);
            list2.addSorted(10);
            list2.addSorted(9);
            list2.addSorted(19);
            list2.printList();
            list2.deleteList();
            list2.addSorted(1);
            list2.printList();
        }
Ejemplo n.º 3
0
            public void display()
            {
                linkedList ptr = new linkedList();

                this.ptr = this.head;
                if (this.head == null)
                {
                    Console.WriteLine("--------linked list empty--------");
                }
                else
                {
                    while (this.ptr.next != null)
                    {
                        Console.Write(this.ptr.data + "-->");
                        this.ptr = this.ptr.next;
                    }
                    Console.Write(this.ptr.data);
                }
            }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            int[] arr = { 1, 3, 5, 7, 9 };
            //arr.add   is not a thing...
            Node someNode    = new Node(7); //this is an instance
            Node anotherNode = new Node(11);

            anotherNode.Next = someNode;    //dot notation to get to property
            anotherNode.Method();           //dot notation to get to method

            linkedList mylist = new linkedList();

            mylist.Print();
            try
            {
                mylist.DeleteFirst();
            }catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            mylist.AddFirst(1);
            try
            {
                mylist.DeleteLast();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            mylist.AddFirst(2);
            mylist.AddFirst(3);
            mylist.Print();

            mylist.Append(10);
            mylist.Append(20);
            mylist.Append(30);
            mylist.Print();


            mylist.Insert(100, 20);
            mylist.Print();
        }
Ejemplo n.º 5
0
        // Driver code
        public static void Main(String[] args)
        {
            linkedList li = new linkedList();

            /*
             * Let us create a unsorted linked list to test the functions
             * created. The list shall be a: 2->3->20->5->10->15
             */
            li.push(15);
            li.push(10);
            li.push(5);
            li.push(20);
            li.push(3);
            li.push(2);

            // Apply merge Sort
            li.head = li.mergeSort(li.head);
            Console.Write("\n Sorted Linked List is: \n");
            li.printList(li.head);
        }
Ejemplo n.º 6
0
        public void linkedListRealise1()
        {
            linkedList <int> list = new linkedList <int>();
            Random           rand = new Random(DateTime.Now.Millisecond);

            for (int i = 0; i < 10000; i++)
            {
                if (rand.Next(0, 20) > 10)
                {
                    list.add(i);
                }
                else
                {
                    list.delete(rand.Next(0, i));
                }
            }
            int coutOfEl = list.countOfElements;

            list.add(11);
            Assert.IsTrue(coutOfEl == list.countOfElements - 1);
            //Assert.Pass();
        }
Ejemplo n.º 7
0
            public void merge(linkedList l)
            {
                //int c = 0;
                ptr   = this.head;
                L2ptr = l.head;
                node n = new node(0);

                if (this.head.data <= l.head.data)
                {
                    while (ptr.next != null && L2ptr.next != null)
                    {
                        while (ptr.data <= L2ptr.data)
                        {
                            preptr = ptr;
                            ptr    = ptr.next;
                        }
                        n.next = preptr.next;
                        n.data = L2ptr.data;
                        preptr = n;
                        L2ptr  = L2ptr.next;
                    }
                }
            }
Ejemplo n.º 8
0
    // Start is called before the first frame update
    void Start()
    {
        linkedList list      = new linkedList();
        windInfo   the_info  = new windInfo(4.0, 6.0);
        windInfo   the_info2 = new windInfo(2.0, 3.0);

        list.add_windData(the_info);
        list.add_windData(the_info2);

        list.display_info();

        Text tempForecastURL = Instantiate(T1);

        // tempT1.transform.SetParent(canvas, false);
        // Text tempT2 = Instantiate(T2);
        // tempT2.transform.SetParent(canvas, false);
        // tempT1.transform.position += new Vector3(0.0f, -40.0f, 0.0f);
        // tempT2.transform.position += new Vector3(0.0f, -40.0f, 0.0f);


        StartCoroutine(GetRequest("https://api.weather.gov/points/45.7534,-121.9908", ForecastURL));
        //StartCoroutine(GetRequest("https://api.weather.gov/points/44.8869,-124.0258", tempT1, tempT2));
        //StartCoroutine(GetRequest("https://api.weather.gov/points/44.9287,-124.0386"));
    }