Beispiel #1
0
        public void FindIdenticalPairs1()
        {
            int[]     numbers = { 3, 5, 6, 3, 3, 5 };
            const int result  = 4;

            Assert.AreEqual(result, PairElement.FindIdenticalPairs(numbers));
        }
        public SetPair ComposedRelationship(SetPair ab, SetPair bc)
        {
            SetPair composed = new SetPair();

            for (int i = 0; i < ab.ListPair.Count; i++)
            {
                for (int j = 0; j < bc.ListPair.Count; j++)
                {
                    if (ab.ListPair[i].Codomain.Value == bc.ListPair[j].Domain.Value)
                    {
                        PairElement newPair = new PairElement(ab.ListPair[i].Domain, bc.ListPair[j].Codomain);

                        int repeatedCounter = 0;
                        for (int k = 0; k < composed.ListPair.Count && repeatedCounter == 0; k++)
                        {
                            if (composed.ListPair[k].Equal(newPair))
                            {
                                repeatedCounter++;
                            }
                        }

                        if (repeatedCounter == 0)
                        {
                            composed.ListPair.Add(newPair);
                        }
                    }
                }
            }

            LastOperation = composed;
            return(composed);
        }
Beispiel #3
0
 public static PairElement Reverse(this PairElement element)
 {
     return((element == PairElement.First) ? PairElement.Second : PairElement.First);
 }
 public bool Equal(PairElement pairElement)
 {
     return((pairElement.Domain.Value == Domain.Value && pairElement.Codomain.Value == Codomain.Value) ? true : false);
 }