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); }
/// <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); }
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); } } } }
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)); }
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)); }
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)); } }
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)); }
public void RemoveNull() { if (SupportsNull) { Set.AddAll(UniqueStuff); Assert.IsFalse(Set.Remove(null)); Set.Add(null); Assert.IsTrue(Set.Remove(null)); } }
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); }
/// <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); }
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); }
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); }
// 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); } }
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."); } }
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."); } }
/// <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); }
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."); }
/// <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); }
public void Contains() { Set.AddAll(UniqueStuff); Assert.IsTrue(Set.Contains(StuffThree)); Assert.IsFalse(Set.Contains("SourDough")); }
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); } }
public void ContainsAll() { Set.AddAll(UniqueStuff); Assert.IsTrue(Set.ContainsAll(new object [] { StuffThree, StuffTwo, StuffOne })); }
public void Clear() { Set.AddAll(UniqueStuff); Set.Clear(); Assert.IsTrue(Set.Count == 0, "Calling Clear () did not remove all of the elements."); }
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."); }