Difference() 공개 메소드

public Difference ( CustomSet, right ) : CustomSet,
right CustomSet,
리턴 CustomSet,
예제 #1
0
    public void Difference_of_a_non_empty_set_and_an_empty_set_is_the_non_empty_set()
    {
        var set2 = new CustomSet();
        var sut  = new CustomSet(new[] { 1, 2, 3, 4 });

        Assert.Equal(new CustomSet(new[] { 1, 2, 3, 4 }), sut.Difference(set2));
    }
예제 #2
0
    public void Difference_of_two_non_empty_sets_is_a_set_of_elements_that_are_only_in_the_first_set()
    {
        var set2 = new CustomSet(new[] { 2, 4 });
        var sut  = new CustomSet(new[] { 3, 2, 1 });

        Assert.Equal(new CustomSet(new[] { 1, 3 }), sut.Difference(set2));
    }
예제 #3
0
    public void Difference_of_two_empty_sets_is_an_empty_set()
    {
        var set2 = new CustomSet();
        var sut  = new CustomSet();

        Assert.Equal(new CustomSet(), sut.Difference(set2));
    }
예제 #4
0
    public void Difference_of_empty_set_and_non_empty_set_is_an_empty_set()
    {
        var set2 = new CustomSet(new[] { 3, 2, 5 });
        var sut  = new CustomSet();

        Assert.Equal(new CustomSet(), sut.Difference(set2));
    }
예제 #5
0
    public void Difference_of_two_non_empty_sets_is_a_set_of_elements_that_are_only_in_the_first_set()
    {
        var left     = new CustomSet <int>(new[] { 3, 2, 1 });
        var right    = new CustomSet <int>(new[] { 2, 4 });
        var expected = new CustomSet <int>(new[] { 1, 3 });

        Assert.True(left.Difference(right).Equals(expected));
    }
예제 #6
0
    public void Difference_of_a_non_empty_set_and_an_empty_set_is_an_empty_set()
    {
        var left     = new CustomSet <int>(new[] { 1, 2, 3, 4 });
        var right    = new CustomSet <int>();
        var expected = new CustomSet <int>(new[] { 1, 2, 3, 4 });

        Assert.True(left.Difference(right).Equals(expected));
    }
예제 #7
0
    public void Difference_of_two_empty_sets_is_an_empty_set()
    {
        var left     = new CustomSet <int>();
        var right    = new CustomSet <int>();
        var expected = new CustomSet <int>();

        Assert.True(left.Difference(right).Equals(expected));
    }
예제 #8
0
    public void Difference_of_an_empty_set_and_non_empty_set_is_an_empty_set()
    {
        var left     = new CustomSet <int>();
        var right    = new CustomSet <int>(new[] { 3, 2, 5 });
        var expected = new CustomSet <int>();

        Assert.That(left.Difference(right), Is.EquivalentTo(expected));
    }
예제 #9
0
        static void Main(string[] args)
        {
            try
            {
                var binarySearch = new BinarySearch();

                int[] searchExpression = { 1, 2, 3, 4, 6 };

                var resultBinarySearch = binarySearch.Find(searchExpression, 4);

                var funcFibonacci = new FuncFibonacci();

                Console.WriteLine("Fibonacci result: ");


                var result = funcFibonacci.GetSequence(-5);


                foreach (var s in funcFibonacci.GetSequence(15))
                {
                    Console.WriteLine(s);
                }

                var stack = new CustomStack <int>();
                stack.Push(4);
                stack.Push(5);

                var myStackCount = stack.Count;
                var myStackPeek  = stack.Peek();
                stack.Pop();
                stack.Push(34);

                var queue = new CustomQueue <int>();
                queue.Enqueue(2);
                queue.Enqueue(3);
                queue.Enqueue(5);
                queue.Enqueue(12);

                var myQueueCount = queue.Count;
                var peek         = queue.Peek();
                var deQueue      = queue.Dequeue();

                var set1 = new CustomSet <int>();

                set1.Add(1);
                set1.Add(2);
                set1.Add(56);

                var set2 = new CustomSet <int>();

                set2.Add(2);
                set2.Add(4);
                set2.Add(6);

                var difference = set1.Difference(set2);

                var intersection = set1.Intersection(set2);
                var union        = set1.Union(set2);

                Console.WriteLine("\nStack:");
                foreach (var s in stack)
                {
                    Console.WriteLine(s);
                }

                Console.WriteLine("\nQueue: ");
                foreach (var s in queue)
                {
                    Console.WriteLine(s);
                }

                Console.WriteLine("\nSet: ");
                foreach (var s in set1)
                {
                    Console.WriteLine(s);
                }

                Console.ReadLine();
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (ArgumentNullException e)
            {
                Console.WriteLine(e.Message);
            }

            catch (ArgumentException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (InvalidOperationException e)
            {
                Console.WriteLine();
            }
        }