Ejemplo n.º 1
0
        public static void TestIsProperSupersetEnum()
        {
            RandomTGenerator <int> intGenerator = new RandomTGenerator <int>(InstanceCreators.IntGenerator);

            int[]         startingElements           = intGenerator.MakeNewTs(MaxStartSize);
            int[]         stuffToCheckProperSuperset = intGenerator.GenerateSelectionSubset(startingElements, InitialSetSize_small);
            HashSet <int> theSet = new HashSet <int>();

            theSet.UnionWith(startingElements);

            foreach (var iteration in Benchmark.Iterations)
            {
                using (iteration.StartMeasurement())
                    theSet.IsProperSupersetOf(stuffToCheckProperSuperset);
            }
        }
Ejemplo n.º 2
0
        public static void Remove(int initialSetSize, int countToRemove)
        {
            RandomTGenerator <int> intGenerator = new RandomTGenerator <int>(InstanceCreators.IntGenerator);

            int[] startingElements = intGenerator.MakeNewTs(initialSetSize);
            int[] stuffToRemove    = intGenerator.GenerateSelectionSubset(startingElements, countToRemove);

            foreach (var iteration in Benchmark.Iterations)
            {
                HashSet <int> theSet = new HashSet <int>(startingElements);

                using (iteration.StartMeasurement())
                {
                    foreach (int thing in stuffToRemove)
                    {
                        theSet.Remove(thing);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public static void Contains_True(int initialSetSize, int countToCheck)
        {
            RandomTGenerator <int> intGenerator = new RandomTGenerator <int>(InstanceCreators.IntGenerator);

            int[] startingElements = intGenerator.MakeNewTs(initialSetSize);
            int[] subsetToCheck    = intGenerator.GenerateSelectionSubset(startingElements, countToCheck);
            bool  present;

            foreach (var iteration in Benchmark.Iterations)
            {
                HashSet <int> theSet = new HashSet <int>(startingElements);

                using (iteration.StartMeasurement())
                {
                    foreach (int thing in subsetToCheck)
                    {
                        present = theSet.Contains(thing);
                    }
                }
            }
        }