Beispiel #1
0
        //param  (StockList) listToCompare     : StockList which has to comared for similarity index
        //summary      : finds the similar number of nodes between two lists
        //return       : similarty index
        //return type  : int
        public int Similarity(StockList listToCompare)
        {
            int similarityIndex = 0;

            var firstCurrent  = this.head;
            var tempFirst     = firstCurrent;
            var secondCurrent = listToCompare.head;
            var tempSecond    = secondCurrent;

            while (firstCurrent != null)
            {
                while (secondCurrent != null)
                {
                    if (Assn2_Utility.Compare(secondCurrent.StockHolding, firstCurrent.StockHolding))
                    {
                        similarityIndex += 1;
                    }

                    secondCurrent = secondCurrent.Next;
                }

                firstCurrent  = firstCurrent.Next;
                secondCurrent = tempSecond;
            }


            return(similarityIndex);
        }
Beispiel #2
0
        // FOR STUDENTS

        //param        : NA
        //summary      : Sort the list by descending number of holdings
        //return       : NA
        //return type  : NA
        public void SortByValue()
        {
            Assn2_Utility.MergeSort(this.head);
            this.head = Assn2_Utility.ReverseList(this.head);
        }