Ejemplo n.º 1
0
        public static List <T> SortByRandom <T>(Random Rnd, List <T> aList)
        {
            List <T> aNew = new List <T>();

            int[] aOrder = CRandomUnique.GenerateRandomlyOrdered(Rnd, 0, aList.Count);
            for (int i = 0; i < aOrder.Length; i++)
            {
                aNew.Add(aList[aOrder[i]]);
            }

            return(aNew);
        }
Ejemplo n.º 2
0
        public static DataTable SortByRandom(Random Rnd, DataTable dt)
        {
            DataTable dtNew = dt.Clone();

            int[] aOrder = CRandomUnique.GenerateRandomlyOrdered(Rnd, 0, dt.Rows.Count);
            for (int i = 0; i < aOrder.Length; i++)
            {
                dtNew.ImportRow(dt.Rows[aOrder[i]]);
            }

            return(dtNew);
        }
Ejemplo n.º 3
0
        public static Dictionary <TKey, TValue> SortByRandom <TKey, TValue>(Random Rnd, Dictionary <TKey, TValue> aDictionary)
        {
            Dictionary <TKey, TValue> aNew = new Dictionary <TKey, TValue>();

            int[]       aOrder = CRandomUnique.GenerateRandomlyOrdered(Rnd, 0, aDictionary.Count);
            List <TKey> aKey   = aDictionary.Keys.ToList();

            for (int i = 0; i < aOrder.Length; i++)
            {
                TKey Key = aKey[aOrder[i]];
                aNew.Add(Key, aDictionary[Key]);
            }

            return(aNew);
        }