예제 #1
0
        public List <T> GetTopIndices()
        {
            if (!isSort)
            {
                MinHeapDouble.heapSort(mhd);
                isSort = true;
            }

            int[] indices  = mhd.getIndices();
            var   itemList = new List <T>();

            Dictionary <int, double> dict = new Dictionary <int, double>();

            for (int i = 0; i < heapSize; i++)
            {
                if (indices[i] != -1)
                {
                    itemList.Add(_itemList[indices[i]]);
                }
            }

            return(itemList);
        }
예제 #2
0
        public Dictionary <T, double> GetSortedDictionary()
        {
            if (!isSort)
            {
                MinHeapDouble.heapSort(mhd);
                isSort = true;
            }

            int[]    indices = mhd.getIndices();
            double[] values  = mhd.getValues();

            Dictionary <T, double> dict = new Dictionary <T, double>();

            for (int i = 0; i < heapSize; i++)
            {
                if (indices[i] != -1)
                {
                    dict.Add(_itemList[indices[i]], factor * values[i]);
                }
            }

            return(dict);
        }