Esempio n. 1
0
        //@author: qing qi
        //param   (StockList)listToMerge : second list to be merged
        //summary      : merge two different list into a single result list
        //return       : merged list
        //return type  : StockList
        public StockList MergeList(StockList listToMerge)
        {
            StockList resultList = new StockList();
            StockNode stockNode  = this.head;

            for (; stockNode != null; stockNode = stockNode.Next)
            {
                if (listToMerge.Contains(stockNode.StockHolding) == null)
                {
                    listToMerge.AddStock(stockNode.StockHolding);
                }
                else
                {
                    continue;
                }
            }
            resultList = listToMerge;
            return(resultList);
        }
Esempio n. 2
0
        //Rahil Shaik
        //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;
            //Creating an instance for current node
            StockNode currentNode = this.head;

            if (listToCompare != null)
            {
                while (currentNode != null)
                {
                    //Checking if the current stock holding is present in the list
                    if (listToCompare.Contains(currentNode.StockHolding) != null)
                    {
                        //Increasing the index count if it is present
                        similarityIndex += 1;
                    }
                    currentNode = currentNode.Next;
                }
            }
            return(similarityIndex);
        }