예제 #1
0
        static void Main()
        {
            DrugList drugs = new DrugList("RXQT1402.txt");

            drugs.SelectSort();
            foreach (Drug d in drugs.ToArray())
            {
                Console.WriteLine(d);
            }
        }
예제 #2
0
        // Sort this list by insertion sorts
        public void InsertSort()
        {
            //this method places the Drug object in a new Node of the linked list
            //just before the first element greater than the new element under
            //the comparison method.
            DrugList sortedList = new DrugList();
            Drug     tmp        = RemoveFirst();

            while (tmp != null)
            {
                sortedList.InsertInOrder(tmp);
                tmp = RemoveFirst();
            }

            head  = sortedList.head;
            tail  = sortedList.tail;
            count = sortedList.count;
        }
예제 #3
0
        // Methods which sort the list:
        // Sort this list by selection sort.
        public void SelectSort()
        {
            //this methods keeps on calling the removemin method
            //it always places the new min in the beginning of the list
            //in order to have a sorted list
            DrugList sortedList = new DrugList();
            Drug     tmp        = RemoveMin();


            while (tmp != null)
            {
                Console.WriteLine(count);
                sortedList.Append(tmp);
                tmp = RemoveMin();
            }

            head  = sortedList.head;
            tail  = sortedList.tail;
            count = sortedList.count;
        }