예제 #1
0
        public void AddAllAndRemoveAll()
        {
            Set <int> subject = new Set <int>();

            subject.AddAll(new int[] { 1, 2, 3 });
            Assert.AreEqual(3, subject.Count);

            subject.AddAll(new int[] { 4 });
            Assert.AreEqual(4, subject.Count);

            subject.RemoveAll(new int[] { 4 });
            Assert.AreEqual(3, subject.Count);

            subject.RemoveAll(new int[] { 1, 2, 3, 4, 5 });
            Assert.AreEqual(0, subject.Count);
        }
예제 #2
0
        /// <summary>
        /// Gets both parents and children nodes
        /// </summary>
        public Set <V> GetNeighbors(V v)
        {
            // TODO: pity we have to copy the sets... is there a combination set?
            ReadOnlyCollection <V> children = GetChildren(v);
            ReadOnlyCollection <V> parents  = GetParents(v);

            if (children == null && parents == null)
            {
                return(null);
            }
            Set <V> neighbors = innerMapFactory.NewSet();

            neighbors.AddAll(children);
            neighbors.AddAll(parents);
            return(neighbors);
        }
예제 #3
0
        public void walk(KokDugumu dugum, String olusan)
        {
            String tester = (olusan + dugum.getHarf()).Trim();

            walkCount++;
            if (dugum != null)
            {
                dugumSayisi++;
                if (dugum.getKok() != null)
                {
                    /*              if (dugum.getKelime() != null &&
                     *                              !dugum.getKelime().equals(dugum.getKok().icerik())){
                     *                      System.out.println("!!!!! " + dugum.getKelime() + " - " + dugum.getKok().icerik());
                     *              }*/
                    kokTasiyanDugumSayisi++;
                    if (set != null)
                    {
                        set.Add(dugum.getKok());
                    }
                }
                if (dugum.getEsSesliler() != null)
                {
                    esSesliTasiyanDugumSayisi++;
                    if (set != null)
                    {
                        set.AddAll(dugum.getEsSesliler());
                    }
                }
                if (!dugum.altDugumVarMi())
                {
                    ucDugumSayisi++;
                }
                else
                {
                    KokDugumu[] altDugumler = dugum.altDugumDizisiGetir();
                    int         top         = 0;
                    foreach (KokDugumu altDugum in altDugumler)
                    {
                        if (altDugum != null)
                        {
                            top++;
                        }
                    }
                    dugumSayilari[top]++;
                }
            }
            KokDugumu[] altDugumlerX = dugum.altDugumDizisiGetir();
            if (altDugumlerX != null)
            {
                foreach (KokDugumu altDugum in altDugumlerX)
                {
                    if (altDugum != null)
                    {
                        this.walk(altDugum, tester);
                    }
                }
            }
        }
예제 #4
0
 public void RetainAll()
 {
     Set.AddAll(UniqueStuff);
     Set.RetainAll(new object [] { StuffOne, StuffTwo });
     Assert.IsTrue(Set.Count == 2);
     Assert.IsTrue(Set.Contains(StuffOne));
     Assert.IsTrue(Set.Contains(StuffTwo));
     Assert.IsFalse(Set.Contains(StuffThree));
 }
예제 #5
0
 public void Remove()
 {
     Set.AddAll(UniqueStuff);
     Set.Remove(StuffOne);
     Assert.IsTrue(Set.Count == (UniqueStuff.Length - 1));
     Assert.IsFalse(Set.Contains(StuffOne));
     Assert.IsTrue(Set.Contains(StuffTwo));
     Assert.IsTrue(Set.Contains(StuffThree));
 }
예제 #6
0
        public TregexPattern ChildrenDisj()
        {
            var children = new List <TregexPattern>();
            // When we keep track of the known variables to assert that
            // variables are not redefined, or that links are only set to known
            // variables, we want to separate those done in different parts of the
            // disjunction.  Variables set in one part won't be set in the next
            // part if it gets there, since disjunctions exit once known.
            var originalKnownVariables = new Set <string>(knownVariables);
            // However, we want to keep track of all the known variables, so that after
            // the disjunction is over, we know them all.
            var           allKnownVariables = new Set <string>(knownVariables);
            TregexPattern child             = ChildrenConj();

            children.Add(child);
            allKnownVariables.AddAll(knownVariables);
            //label_3:
            while (true)
            {
                if (Jj_2_2(2))
                {
                    ;
                }
                else
                {
                    //break label_3;
                    break;
                }
                knownVariables = new Set <string>(originalKnownVariables);
                Jj_consume_token(12);
                child = ChildrenConj();
                children.Add(child);
                allKnownVariables.AddAll(knownVariables);
            }
            knownVariables = allKnownVariables;
            if (children.Count == 1)
            {
                return(child);
            }
            else
            {
                return(new CoordinationPattern(children, false));
            }
        }
예제 #7
0
 public void RemoveAll()
 {
     Set.AddAll(UniqueStuff);
     object [] removed = new object [] { StuffOne, StuffTwo };
     Set.RemoveAll(removed);
     Assert.IsTrue(Set.Count == (UniqueStuff.Length - removed.Length));
     Assert.IsFalse(Set.Contains(StuffOne));
     Assert.IsFalse(Set.Contains(StuffTwo));
     Assert.IsTrue(Set.Contains(StuffThree));
 }
예제 #8
0
 public void RemoveNull()
 {
     if (SupportsNull)
     {
         Set.AddAll(UniqueStuff);
         Assert.IsFalse(Set.Remove(null));
         Set.Add(null);
         Assert.IsTrue(Set.Remove(null));
     }
 }
예제 #9
0
        public void Intersect()
        {
            Set.AddAll(UniqueStuff);
            SetForSetOps.AddAll(new object [] { "Bar", StuffOne });
            ISet intersection = Set.Intersect(SetForSetOps);

            Assert.IsTrue(intersection.Count == 1);
            Assert.IsFalse(object.ReferenceEquals(intersection, Set), "Got back same instance after set operation.");
            Assert.IsTrue(Set.Count == UniqueStuff.Length);
            Assert.IsTrue(SetForSetOps.Count == 2);
        }
예제 #10
0
        /// <summary>
        /// Constructs a new instance of the target set.
        /// </summary>
        /// <returns>The new <see cref="Spring.Collections.ISet"/> instance.</returns>
        protected override object CreateInstance()
        {
            if (this._sourceSet == null)
            {
                throw new ArgumentException("The 'SourceSet' property cannot be null (Nothing in Visual Basic.NET).");
            }
            Set result = (Set)ObjectUtils.InstantiateType(this._targetSetType);

            result.AddAll(this._sourceSet);
            return(result);
        }
예제 #11
0
        public void Minus()
        {
            Set.AddAll(UniqueStuff);
            SetForSetOps.AddAll(new object [] { "Bar", StuffOne });
            ISet minus = Set.Minus(SetForSetOps);

            Assert.IsTrue(minus.Count == UniqueStuff.Length - 1);
            Assert.IsFalse(object.ReferenceEquals(minus, Set), "Got back same instance after set operation.");
            Assert.IsTrue(Set.Count == UniqueStuff.Length);
            Assert.IsTrue(SetForSetOps.Count == 2);
        }
예제 #12
0
        public void ExclusiveOr()
        {
            Set.AddAll(UniqueStuff);
            SetForSetOps.AddAll(new object [] { "Bar", StuffOne });
            ISet xor = Set.ExclusiveOr(SetForSetOps);

            Assert.IsTrue(xor.Count == 3);
            Assert.IsTrue(xor.ContainsAll(new object [] { "Bar", StuffTwo, StuffThree }));
            Assert.IsFalse(object.ReferenceEquals(xor, Set), "Got back same instance after set operation.");
            Assert.IsTrue(Set.Count == UniqueStuff.Length);
            Assert.IsTrue(SetForSetOps.Count == 2);
        }
예제 #13
0
파일: Sets.cs 프로젝트: sestoft/C5
 // MySet union (+), difference (-), and intersection (*):
 public static Set <T> operator +(Set <T> s1, Set <T> s2)
 {
     if (s1 == null || s2 == null)
     {
         throw new ArgumentNullException("MySet+MySet");
     }
     else
     {
         var res = new Set <T>(s1);
         res.AddAll(s2);
         return(res);
     }
 }
예제 #14
0
 public void EnumeratesNull()
 {
     if (SupportsNull)
     {
         Set.AddAll(new object [] { StuffOne, null, StuffTwo });
         bool gotNull = false;
         foreach (object o in Set)
         {
             if (o == null)
             {
                 gotNull = true;
                 break;
             }
         }
         Assert.IsTrue(gotNull, "Stuffed a null value into the set but didn't get it back when enumerating over the set.");
     }
 }
예제 #15
0
 public void CopiesNull()
 {
     if (SupportsNull)
     {
         object [] expected = new object [] { StuffOne, null, StuffTwo };
         Set.AddAll(expected);
         object [] actual = new object [expected.Length];
         Set.CopyTo(actual, 0);
         bool gotNull = false;
         foreach (object o in actual)
         {
             if (o == null)
             {
                 gotNull = true;
                 break;
             }
         }
         Assert.IsTrue(gotNull, "Copied a set with a null value into an array, but the resulting array did not contain a a null.");
     }
 }
예제 #16
0
        /// <summary>
        /// Create a SemanticHeadFinder
        /// </summary>
        /// <param name="tlp">
        /// The TreebankLanguagePack, used by the superclass to get basic category of constituents
        /// </param>
        /// <param name="noCopulaHead">
        /// If true, a copular verb (be, seem, appear, stay, remain, resemble, become)
        /// is not treated as head when it has an AdjP or NP complement.  If false,
        /// a copula verb is still always treated as a head.  But it will still
        /// be treated as an auxiliary in periphrastic tenses with a VP complement.
        /// </param>
        public SemanticHeadFinder(AbstractTreebankLanguagePack tlp, bool noCopulaHead) : base(tlp)
        {
            RuleChanges();

            // make a distinction between auxiliaries and copula verbs to
            // get the NP has semantic head in sentences like "Bill is an honest man".  (Added "sha" for "shan't" May 2009
            verbalAuxiliaries = new Util.HashSet <string>(Auxiliaries);

            passiveAuxiliaries = new Util.HashSet <string>(BeGetVerbs);

            //copula verbs having an NP complement
            copulars = new Util.HashSet <string>();
            if (noCopulaHead)
            {
                copulars.AddAll(CopulaVerbs);
            }

            // TODO: reverse the polarity of noCopulaHead
            this.makeCopulaHead = !noCopulaHead;

            verbalTags = new Util.HashSet <string>(VerbTags);
            unambiguousAuxiliaryTags = new Util.HashSet <string>(UnambiguousAuxTags);
        }
예제 #17
0
 public void AddAll()
 {
     Assert.IsTrue(Set.AddAll(UniqueStuff));
     Assert.IsTrue(Set.Count == UniqueStuff.Length, "Added 3 unique items, but the Count property wasn't sitting at 3.");
 }
예제 #18
0
        /// <summary>
        /// Create a SemanticHeadFinder
        /// </summary>
        /// <param name="tlp">
        /// The TreebankLanguagePack, used by the superclass to get basic category of constituents
        /// </param>
        /// <param name="noCopulaHead">
        /// If true, a copular verb (be, seem, appear, stay, remain, resemble, become)
        /// is not treated as head when it has an AdjP or NP complement.  If false,
        /// a copula verb is still always treated as a head.  But it will still
        /// be treated as an auxiliary in periphrastic tenses with a VP complement.
        /// </param>
        public SemanticHeadFinder(AbstractTreebankLanguagePack tlp, bool noCopulaHead) : base(tlp)
        {
            RuleChanges();

            // make a distinction between auxiliaries and copula verbs to
            // get the NP has semantic head in sentences like "Bill is an honest man".  (Added "sha" for "shan't" May 2009
            verbalAuxiliaries = new Util.HashSet<string>(Auxiliaries);

            passiveAuxiliaries = new Util.HashSet<string>(BeGetVerbs);

            //copula verbs having an NP complement
            copulars = new Util.HashSet<string>();
            if (noCopulaHead)
            {
                copulars.AddAll(CopulaVerbs);
            }

            // TODO: reverse the polarity of noCopulaHead
            this.makeCopulaHead = !noCopulaHead;

            verbalTags = new Util.HashSet<string>(VerbTags);
            unambiguousAuxiliaryTags = new Util.HashSet<string>(UnambiguousAuxTags);
        }
예제 #19
0
 public void Contains()
 {
     Set.AddAll(UniqueStuff);
     Assert.IsTrue(Set.Contains(StuffThree));
     Assert.IsFalse(Set.Contains("SourDough"));
 }
예제 #20
0
 public TregexPattern ChildrenDisj()
 {
     var children = new List<TregexPattern>();
     // When we keep track of the known variables to assert that
     // variables are not redefined, or that links are only set to known
     // variables, we want to separate those done in different parts of the
     // disjunction.  Variables set in one part won't be set in the next
     // part if it gets there, since disjunctions exit once known.
     var originalKnownVariables = new Set<string>(knownVariables);
     // However, we want to keep track of all the known variables, so that after
     // the disjunction is over, we know them all.
     var allKnownVariables = new Set<string>(knownVariables);
     TregexPattern child = ChildrenConj();
     children.Add(child);
     allKnownVariables.AddAll(knownVariables);
     //label_3:
     while (true)
     {
         if (Jj_2_2(2))
         {
             ;
         }
         else
         {
             //break label_3;
             break;
         }
         knownVariables = new Set<string>(originalKnownVariables);
         Jj_consume_token(12);
         child = ChildrenConj();
         children.Add(child);
         allKnownVariables.AddAll(knownVariables);
     }
     knownVariables = allKnownVariables;
     if (children.Count == 1)
     {
         return child;
     }
     else
     {
         return new CoordinationPattern(children, false);
     }
 }
예제 #21
0
 public void ContainsAll()
 {
     Set.AddAll(UniqueStuff);
     Assert.IsTrue(Set.ContainsAll(new object [] { StuffThree, StuffTwo, StuffOne }));
 }
예제 #22
0
 public void Clear()
 {
     Set.AddAll(UniqueStuff);
     Set.Clear();
     Assert.IsTrue(Set.Count == 0, "Calling Clear () did not remove all of the elements.");
 }
예제 #23
0
 public void AddAllDuplicated()
 {
     Assert.IsTrue(Set.AddAll(DuplicatedStuff));
     Assert.IsTrue(Set.Count == 2, "Added 3 (2 duplicated) items, but the Count property wasn't sitting at 2.");
 }