コード例 #1
0
        // Check the Iterator Pattern for a different version
        public static IEnumerable <T> GetStartSet()
        {
            const int n = 200; // how many values to generate

            myList = new List <T>();
            int index = 0;

            if (typeof(T) == typeof(Person))
            {
                IList <Person> list = new List <Person>();
                foreach (string name in sampleNames)
                {
                    //return (T)(object)String.Empty;
                    list.Add(new Person()
                    {
                        RedniBroj = index + 1, Name = name, Surname = surnameForAll
                    });
                    index++;
                }
                myList = (List <T>)list;
            }

            tipPodatka = TipPod.Others;
            return(myList);
        }
コード例 #2
0
        public static IEnumerable<int> GetReversed()
        {
            const int n = 200; // how many values to generate
            myList = new List<int>();

            List<int> list = new List<int>();
            Random randomGenerator = new Random();

            List<int> range = new List<int>();
            for (int i = 0; i < n; i++)
                range.Add(i);

            int J = range.Count()-1;
            while (range.Count > 0)
            {
                list.Add(J);
                range.Remove(J--);
            }
            myList = list;
            tipPodatka = TipPod.Others;
            return myList;
        }
コード例 #3
0
        public static IEnumerable<int> GetVeryBigData()
        {
            const int n = 1000; // how many values to generate
            myList = new List<int>();
            
            List<int> list = new List<int>();
            Random randomGenerator = new Random();

            List<int> range = new List<int>();
            for (int i = 0; i < n; i++)
                range.Add(i);

            while (range.Count > 0)
            {
                dynamic item = range[randomGenerator.Next(range.Count)];
                list.Add(item);
                range.Remove(item);
            }
            myList = list;
            tipPodatka = TipPod.Big;
            return myList;
        }
コード例 #4
0
        public static IEnumerable<int> GetPartiallySorted()
        {
            myList = new List<int>();

            List<int> list = new List<int>();
            Random randomGenerator = new Random();

            int J = 0;
            while (J != 200)
            {
                dynamic offset = randomGenerator.Next(-10,10);
                int ToInsert = offset + J++;
                if(J > 30 && J < 170)
                {
                    list.Add(ToInsert);
                    continue;
                }
                list.Add(J);
            }
            myList = list;
            tipPodatka = TipPod.Others;
            return myList;
        }