/// <summary> /// Registers all pending labels. /// Called once per frame during LateUpdate by the <see cref="PerceptionUpdater"/>. /// </summary> public void RegisterPendingLabels() { if (m_RegisteredLabels.Count == 0) { m_NextObjectIndex = k_StartingIndex; } foreach (var unregisteredLabel in m_LabelsPendingRegistration) { if (m_RegisteredLabels.Contains(unregisteredLabel)) { continue; } var instanceId = m_NextObjectIndex++; RecursivelyInitializeGameObjects( unregisteredLabel.gameObject, new MaterialPropertyBlock(), unregisteredLabel, instanceId); unregisteredLabel.SetInstanceId(instanceId); m_RegisteredLabels.Add(unregisteredLabel); } m_LabelsPendingRegistration.Clear(); }
public void Reset() { // Clear event subscriptions _onReset = null; _onExit = null; // Forget all instances that have been previously registered _registeredInstances.Clear(); }
private IList <int[]> HandleCube(int[][] childIndexes) { var enumerationSorted = new List <int[]>(); var size = ChildNodes.Count; var e = new NumberAscCombinationEnumeration(size); while (e.MoveNext()) { enumerationSorted.Add(e.Current); } enumerationSorted.SortInPlace( (o1, o2) => { int shared = Math.Min(o1.Length, o2.Length); for (int i = 0; i < shared; i++) { if (o1[i] < o2[i]) { return(-1); } if (o1[i] > o2[i]) { return(1); } } if (o1.Length > o2.Length) { return(-1); } if (o1.Length < o2.Length) { return(1); } return(0); }); var rollup = new List <int[]>(enumerationSorted.Count + 1); var keys = new LinkedHashSet <int>(); foreach (var item in enumerationSorted) { keys.Clear(); foreach (int index in item) { int[] childIndex = childIndexes[index]; foreach (int childIndexItem in childIndex) { keys.Add(childIndexItem); } } rollup.Add(CollectionUtil.IntArray(keys)); } return(rollup); }
/// <summary>Normalizes text decoration values.</summary> /// <param name="value">the text decoration value</param> /// <returns>a set of normalized decoration values</returns> private static ICollection <String> NormalizeTextDecoration(String value) { String[] parts = iText.IO.Util.StringUtil.Split(value, "\\s+"); // LinkedHashSet to make order invariant of JVM ICollection <String> merged = new LinkedHashSet <String>(); merged.AddAll(JavaUtil.ArraysAsList(parts)); // if none and any other decoration are used together, none is displayed if (merged.Contains(CommonCssConstants.NONE)) { merged.Clear(); } return(merged); }
public void LinkedHashSet_Generic_TrimExcess_AfterClearingAndAddingAllElementsBack(int setLength) { if (setLength > 0) { LinkedHashSet <T> set = (LinkedHashSet <T>)GenericISetFactory(setLength); set.TrimExcess(); set.Clear(); set.TrimExcess(); Assert.Equal(0, set.Count); AddToCollection(set, setLength); set.TrimExcess(); Assert.Equal(setLength, set.Count); } }
/// <summary> /// Returns a set of ModifyEnumerable delegates that modify the enumerable passed to them. /// </summary> protected override IEnumerable <ModifyEnumerable> GetModifyEnumerables(ModifyOperation operations) { if ((operations & ModifyOperation.Clear) == ModifyOperation.Clear) { yield return((IEnumerable enumerable) => { LinkedHashSet <string> casted = ((LinkedHashSet <string>)enumerable); if (casted.Count > 0) { casted.Clear(); return true; } return false; }); } }
public void TestGetSuper() { var classes = new LinkedHashSet <Type>(); BeanEventType.GetSuper(typeof(ISupportAImplSuperGImplPlus), classes); Assert.AreEqual(6, classes.Count); EPAssertionUtil.AssertEqualsAnyOrder( classes.ToArray(), new[] { typeof(ISupportAImplSuperG), typeof(ISupportBaseAB), typeof(ISupportA), typeof(ISupportB), typeof(ISupportC), typeof(Object) } ); classes.Clear(); BeanEventType.GetSuper(typeof(Object), classes); Assert.AreEqual(0, classes.Count); }
private IList<int[]> HandleRollup(int[][] childIndexes) { var size = ChildNodes.Count; IList<int[]> rollup = new List<int[]>(size + 1); ISet<int> keyset = new LinkedHashSet<int>(); for (var i = 0; i < size; i++) { keyset.Clear(); for (var j = 0; j < size - i; j++) { var childIndex = childIndexes[j]; foreach (var aChildIndex in childIndex) { keyset.Add(aChildIndex); } } rollup.Add(CollectionUtil.IntArray(keyset)); } return rollup; }
private static List <IAtomContainer> MakeCut(IBond cut, IAtomContainer mol, Dictionary <IAtom, int> idx, int[][] adjlist) { var beg = cut.Begin; var end = cut.End; var bvisit = new LinkedHashSet <IAtom>(); var evisit = new LinkedHashSet <IAtom>(); var queue = new ArrayDeque <IAtom>(); bvisit.Add(beg); evisit.Add(end); queue.Add(beg); bvisit.Add(end); // stop visits while (queue.Any()) { var atom = queue.Poll(); bvisit.Add(atom); foreach (var w in adjlist[idx[atom]]) { var nbr = mol.Atoms[w]; if (!bvisit.Contains(nbr)) { queue.Add(nbr); } } } bvisit.Remove(end); queue.Add(end); evisit.Add(beg); // stop visits while (queue.Any()) { var atom = queue.Poll(); evisit.Add(atom); foreach (var w in adjlist[idx[atom]]) { var nbr = mol.Atoms[w]; if (!evisit.Contains(nbr)) { queue.Add(nbr); } } } evisit.Remove(beg); var bldr = mol.Builder; var bfrag = bldr.NewAtomContainer(); var efrag = bldr.NewAtomContainer(); int diff = bvisit.Count - evisit.Count; if (diff < -10) { evisit.Clear(); } else if (diff > 10) { bvisit.Clear(); } if (bvisit.Any()) { bfrag.Atoms.Add(bldr.NewPseudoAtom()); foreach (var atom in bvisit) { bfrag.Atoms.Add(atom); } bfrag.AddBond(bfrag.Atoms[0], bfrag.Atoms[1], cut.Order); bfrag.Bonds[0].SetProperty(PropertyName_CutBond, cut); } if (evisit.Any()) { efrag.Atoms.Add(bldr.NewPseudoAtom()); foreach (var atom in evisit) { efrag.Atoms.Add(atom); } efrag.AddBond(efrag.Atoms[0], efrag.Atoms[1], cut.Order); efrag.Bonds[0].SetProperty(PropertyName_CutBond, cut); } foreach (var bond in mol.Bonds) { var a1 = bond.Begin; var a2 = bond.End; if (bvisit.Contains(a1) && bvisit.Contains(a2)) { bfrag.Bonds.Add(bond); } else if (evisit.Contains(a1) && evisit.Contains(a2)) { efrag.Bonds.Add(bond); } } var res = new List <IAtomContainer>(); if (!bfrag.IsEmpty()) { res.Add(bfrag); } if (!efrag.IsEmpty()) { res.Add(efrag); } return(res); }
public static void LinkedHashSetTest() { int[] setEmpty = { }; int[] set1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; int[] set2 = { 1, 2, 3, 4, 5, 6, 6, 8, 9 }; int[] set3 = { 1, 2, 3, 4, 5, 6, 8, 9, 0 }; LinkedHashSet <int> lhsEmpty = new LinkedHashSet <int>(); LinkedHashSet <int> lhs1 = new LinkedHashSet <int>(set1); LinkedHashSet <int> lhs2 = new LinkedHashSet <int>(set2); LinkedHashSet <int> lhs3 = new LinkedHashSet <int>(set3); HashSet <int> hsEmpty = new HashSet <int>(); HashSet <int> hs1 = new HashSet <int>(set1); HashSet <int> hs2 = new HashSet <int>(set2); HashSet <int> hs3 = new HashSet <int>(set3); #region Pseudo-LINQ-Extensions Assert.AreEqual(1, lhs1.First()); Assert.AreEqual(9, lhs1.Last()); Assert.AreEqual(0, lhs3.Last()); Assert.Throws <InvalidOperationException>(() => lhsEmpty.First()); Assert.Throws <InvalidOperationException>(() => lhsEmpty.Last()); Assert.DoesNotThrow(() => lhsEmpty.FirstOrDefault()); Assert.DoesNotThrow(() => lhsEmpty.LastOrDefault()); Assert.AreEqual(default(int), lhsEmpty.FirstOrDefault()); Assert.AreEqual(default(int), lhsEmpty.LastOrDefault()); Assert.DoesNotThrow(() => lhsEmpty.Reverse()); List <int> reversed = new List <int>(lhs3.Reverse()); Assert.AreEqual(lhs3.Count, reversed.Count); Assert.AreEqual(0, reversed[0]); Assert.AreEqual(9, reversed[1]); Assert.AreEqual(8, reversed[2]); Assert.AreEqual(6, reversed[3]); Assert.AreEqual(5, reversed[4]); Assert.AreEqual(4, reversed[5]); Assert.AreEqual(3, reversed[6]); Assert.AreEqual(2, reversed[7]); Assert.AreEqual(1, reversed[8]); #endregion #region SetEquals Assert.IsTrue(lhsEmpty.SetEquals(lhsEmpty)); Assert.IsTrue(lhs1.SetEquals(lhs1)); Assert.IsTrue(lhs2.SetEquals(lhs2)); Assert.IsTrue(lhs3.SetEquals(lhs3)); Assert.IsTrue(lhsEmpty.SetEquals(hsEmpty)); Assert.IsTrue(lhs1.SetEquals(hs1)); Assert.IsTrue(lhs2.SetEquals(hs2)); Assert.IsTrue(lhs3.SetEquals(hs3)); Assert.IsTrue(lhsEmpty.SetEquals(setEmpty)); Assert.IsTrue(lhs1.SetEquals(set1)); Assert.IsTrue(lhs2.SetEquals(set2)); Assert.IsTrue(lhs3.SetEquals(set3)); Assert.IsTrue(lhsEmpty.SetEquals(GetEnumerator(setEmpty))); Assert.IsTrue(lhs1.SetEquals(GetEnumerator(set1))); Assert.IsTrue(lhs2.SetEquals(GetEnumerator(set2))); Assert.IsTrue(lhs3.SetEquals(GetEnumerator(set3))); Assert.IsFalse(lhsEmpty.SetEquals(lhs1)); Assert.IsFalse(lhsEmpty.SetEquals(lhs2)); Assert.IsFalse(lhsEmpty.SetEquals(lhs3)); Assert.IsFalse(lhsEmpty.SetEquals(hs1)); Assert.IsFalse(lhsEmpty.SetEquals(hs2)); Assert.IsFalse(lhsEmpty.SetEquals(hs3)); Assert.IsFalse(lhsEmpty.SetEquals(set1)); Assert.IsFalse(lhsEmpty.SetEquals(set2)); Assert.IsFalse(lhsEmpty.SetEquals(set3)); Assert.IsFalse(lhsEmpty.SetEquals(GetEnumerator(set1))); Assert.IsFalse(lhsEmpty.SetEquals(GetEnumerator(set2))); Assert.IsFalse(lhsEmpty.SetEquals(GetEnumerator(set3))); Assert.IsFalse(lhs1.SetEquals(lhsEmpty)); Assert.IsFalse(lhs1.SetEquals(lhs2)); Assert.IsFalse(lhs1.SetEquals(lhs3)); Assert.IsFalse(lhs1.SetEquals(hsEmpty)); Assert.IsFalse(lhs1.SetEquals(hs2)); Assert.IsFalse(lhs1.SetEquals(hs3)); Assert.IsFalse(lhs1.SetEquals(setEmpty)); Assert.IsFalse(lhs1.SetEquals(set2)); Assert.IsFalse(lhs1.SetEquals(set3)); Assert.IsFalse(lhs1.SetEquals(GetEnumerator(setEmpty))); Assert.IsFalse(lhs1.SetEquals(GetEnumerator(set2))); Assert.IsFalse(lhs1.SetEquals(GetEnumerator(set3))); Assert.IsFalse(lhs2.SetEquals(lhsEmpty)); Assert.IsFalse(lhs2.SetEquals(lhs1)); Assert.IsFalse(lhs2.SetEquals(lhs3)); Assert.IsFalse(lhs2.SetEquals(hsEmpty)); Assert.IsFalse(lhs2.SetEquals(hs1)); Assert.IsFalse(lhs2.SetEquals(hs3)); Assert.IsFalse(lhs2.SetEquals(setEmpty)); Assert.IsFalse(lhs2.SetEquals(set1)); Assert.IsFalse(lhs2.SetEquals(set3)); Assert.IsFalse(lhs2.SetEquals(GetEnumerator(setEmpty))); Assert.IsFalse(lhs2.SetEquals(GetEnumerator(set1))); Assert.IsFalse(lhs2.SetEquals(GetEnumerator(set3))); Assert.IsFalse(lhs3.SetEquals(lhsEmpty)); Assert.IsFalse(lhs3.SetEquals(lhs1)); Assert.IsFalse(lhs3.SetEquals(lhs2)); Assert.IsFalse(lhs3.SetEquals(hsEmpty)); Assert.IsFalse(lhs3.SetEquals(hs1)); Assert.IsFalse(lhs3.SetEquals(hs2)); Assert.IsFalse(lhs3.SetEquals(setEmpty)); Assert.IsFalse(lhs3.SetEquals(set1)); Assert.IsFalse(lhs3.SetEquals(set2)); Assert.IsFalse(lhs3.SetEquals(GetEnumerator(setEmpty))); Assert.IsFalse(lhs3.SetEquals(GetEnumerator(set1))); Assert.IsFalse(lhs3.SetEquals(GetEnumerator(set2))); #endregion #region Overlaps Assert.IsFalse(lhsEmpty.Overlaps(lhsEmpty)); Assert.IsTrue(lhs1.Overlaps(lhs1)); Assert.IsTrue(lhs2.Overlaps(lhs2)); Assert.IsTrue(lhs3.Overlaps(lhs3)); Assert.IsFalse(lhsEmpty.Overlaps(hsEmpty)); Assert.IsTrue(lhs1.Overlaps(hs1)); Assert.IsTrue(lhs2.Overlaps(hs2)); Assert.IsTrue(lhs3.Overlaps(hs3)); Assert.IsFalse(lhsEmpty.Overlaps(setEmpty)); Assert.IsTrue(lhs1.Overlaps(set1)); Assert.IsTrue(lhs2.Overlaps(set2)); Assert.IsTrue(lhs3.Overlaps(set3)); Assert.IsFalse(lhsEmpty.Overlaps(GetEnumerator(setEmpty))); Assert.IsTrue(lhs1.Overlaps(GetEnumerator(set1))); Assert.IsTrue(lhs2.Overlaps(GetEnumerator(set2))); Assert.IsTrue(lhs3.Overlaps(GetEnumerator(set3))); Assert.IsFalse(lhsEmpty.Overlaps(lhs1)); Assert.IsFalse(lhsEmpty.Overlaps(lhs2)); Assert.IsFalse(lhsEmpty.Overlaps(lhs3)); Assert.IsFalse(lhsEmpty.Overlaps(hs1)); Assert.IsFalse(lhsEmpty.Overlaps(hs2)); Assert.IsFalse(lhsEmpty.Overlaps(hs3)); Assert.IsFalse(lhsEmpty.Overlaps(set1)); Assert.IsFalse(lhsEmpty.Overlaps(set2)); Assert.IsFalse(lhsEmpty.Overlaps(set3)); Assert.IsFalse(lhsEmpty.Overlaps(GetEnumerator(set1))); Assert.IsFalse(lhsEmpty.Overlaps(GetEnumerator(set2))); Assert.IsFalse(lhsEmpty.Overlaps(GetEnumerator(set3))); Assert.IsFalse(lhs1.Overlaps(lhsEmpty)); Assert.IsTrue(lhs1.Overlaps(lhs2)); Assert.IsTrue(lhs1.Overlaps(lhs3)); Assert.IsFalse(lhs1.Overlaps(hsEmpty)); Assert.IsTrue(lhs1.Overlaps(hs2)); Assert.IsTrue(lhs1.Overlaps(hs3)); Assert.IsFalse(lhs1.Overlaps(setEmpty)); Assert.IsTrue(lhs1.Overlaps(set2)); Assert.IsTrue(lhs1.Overlaps(set3)); Assert.IsFalse(lhs1.Overlaps(GetEnumerator(setEmpty))); Assert.IsTrue(lhs1.Overlaps(GetEnumerator(set2))); Assert.IsTrue(lhs1.Overlaps(GetEnumerator(set3))); Assert.IsFalse(lhs2.Overlaps(lhsEmpty)); Assert.IsTrue(lhs2.Overlaps(lhs1)); Assert.IsTrue(lhs2.Overlaps(lhs3)); Assert.IsFalse(lhs2.Overlaps(hsEmpty)); Assert.IsTrue(lhs2.Overlaps(hs1)); Assert.IsTrue(lhs2.Overlaps(hs3)); Assert.IsFalse(lhs2.Overlaps(setEmpty)); Assert.IsTrue(lhs2.Overlaps(set1)); Assert.IsTrue(lhs2.Overlaps(set3)); Assert.IsFalse(lhs2.Overlaps(GetEnumerator(setEmpty))); Assert.IsTrue(lhs2.Overlaps(GetEnumerator(set1))); Assert.IsTrue(lhs2.Overlaps(GetEnumerator(set3))); Assert.IsFalse(lhs3.Overlaps(lhsEmpty)); Assert.IsTrue(lhs3.Overlaps(lhs1)); Assert.IsTrue(lhs3.Overlaps(lhs2)); Assert.IsFalse(lhs3.Overlaps(hsEmpty)); Assert.IsTrue(lhs3.Overlaps(hs1)); Assert.IsTrue(lhs3.Overlaps(hs2)); Assert.IsFalse(lhs3.Overlaps(setEmpty)); Assert.IsTrue(lhs3.Overlaps(set1)); Assert.IsTrue(lhs3.Overlaps(set2)); Assert.IsFalse(lhs3.Overlaps(GetEnumerator(setEmpty))); Assert.IsTrue(lhs3.Overlaps(GetEnumerator(set1))); Assert.IsTrue(lhs3.Overlaps(GetEnumerator(set2))); #endregion #region IsSubsetOf Assert.IsTrue(lhsEmpty.IsSubsetOf(lhsEmpty)); Assert.IsTrue(lhs1.IsSubsetOf(lhs1)); Assert.IsTrue(lhs2.IsSubsetOf(lhs2)); Assert.IsTrue(lhs3.IsSubsetOf(lhs3)); Assert.IsTrue(lhsEmpty.IsSubsetOf(hsEmpty)); Assert.IsTrue(lhs1.IsSubsetOf(hs1)); Assert.IsTrue(lhs2.IsSubsetOf(hs2)); Assert.IsTrue(lhs3.IsSubsetOf(hs3)); Assert.IsTrue(lhsEmpty.IsSubsetOf(setEmpty)); Assert.IsTrue(lhs1.IsSubsetOf(set1)); Assert.IsTrue(lhs2.IsSubsetOf(set2)); Assert.IsTrue(lhs3.IsSubsetOf(set3)); Assert.IsTrue(lhsEmpty.IsSubsetOf(GetEnumerator(setEmpty))); Assert.IsTrue(lhs1.IsSubsetOf(GetEnumerator(set1))); Assert.IsTrue(lhs2.IsSubsetOf(GetEnumerator(set2))); Assert.IsTrue(lhs3.IsSubsetOf(GetEnumerator(set3))); Assert.IsTrue(lhsEmpty.IsSubsetOf(lhs1)); Assert.IsTrue(lhsEmpty.IsSubsetOf(lhs2)); Assert.IsTrue(lhsEmpty.IsSubsetOf(lhs3)); Assert.IsTrue(lhsEmpty.IsSubsetOf(hs1)); Assert.IsTrue(lhsEmpty.IsSubsetOf(hs2)); Assert.IsTrue(lhsEmpty.IsSubsetOf(hs3)); Assert.IsTrue(lhsEmpty.IsSubsetOf(set1)); Assert.IsTrue(lhsEmpty.IsSubsetOf(set2)); Assert.IsTrue(lhsEmpty.IsSubsetOf(set3)); Assert.IsTrue(lhsEmpty.IsSubsetOf(GetEnumerator(set1))); Assert.IsTrue(lhsEmpty.IsSubsetOf(GetEnumerator(set2))); Assert.IsTrue(lhsEmpty.IsSubsetOf(GetEnumerator(set3))); Assert.IsFalse(lhs1.IsSubsetOf(lhsEmpty)); Assert.IsFalse(lhs1.IsSubsetOf(lhs2)); Assert.IsFalse(lhs1.IsSubsetOf(lhs3)); Assert.IsFalse(lhs1.IsSubsetOf(hsEmpty)); Assert.IsFalse(lhs1.IsSubsetOf(hs2)); Assert.IsFalse(lhs1.IsSubsetOf(hs3)); Assert.IsFalse(lhs1.IsSubsetOf(setEmpty)); Assert.IsFalse(lhs1.IsSubsetOf(set2)); Assert.IsFalse(lhs1.IsSubsetOf(set3)); Assert.IsFalse(lhs1.IsSubsetOf(GetEnumerator(setEmpty))); Assert.IsFalse(lhs1.IsSubsetOf(GetEnumerator(set2))); Assert.IsFalse(lhs1.IsSubsetOf(GetEnumerator(set3))); Assert.IsFalse(lhs2.IsSubsetOf(lhsEmpty)); Assert.IsTrue(lhs2.IsSubsetOf(lhs1)); Assert.IsTrue(lhs2.IsSubsetOf(lhs3)); Assert.IsFalse(lhs2.IsSubsetOf(hsEmpty)); Assert.IsTrue(lhs2.IsSubsetOf(hs1)); Assert.IsTrue(lhs2.IsSubsetOf(hs3)); Assert.IsFalse(lhs2.IsSubsetOf(setEmpty)); Assert.IsTrue(lhs2.IsSubsetOf(set1)); Assert.IsTrue(lhs2.IsSubsetOf(set3)); Assert.IsFalse(lhs2.IsSubsetOf(GetEnumerator(setEmpty))); Assert.IsTrue(lhs2.IsSubsetOf(GetEnumerator(set1))); Assert.IsTrue(lhs2.IsSubsetOf(GetEnumerator(set3))); Assert.IsFalse(lhs3.IsSubsetOf(lhsEmpty)); Assert.IsFalse(lhs3.IsSubsetOf(lhs1)); Assert.IsFalse(lhs3.IsSubsetOf(lhs2)); Assert.IsFalse(lhs3.IsSubsetOf(hsEmpty)); Assert.IsFalse(lhs3.IsSubsetOf(hs1)); Assert.IsFalse(lhs3.IsSubsetOf(hs2)); Assert.IsFalse(lhs3.IsSubsetOf(setEmpty)); Assert.IsFalse(lhs3.IsSubsetOf(set1)); Assert.IsFalse(lhs3.IsSubsetOf(set2)); Assert.IsFalse(lhs3.IsSubsetOf(GetEnumerator(setEmpty))); Assert.IsFalse(lhs3.IsSubsetOf(GetEnumerator(set1))); Assert.IsFalse(lhs3.IsSubsetOf(GetEnumerator(set2))); #endregion #region IsProperSubsetOf Assert.IsFalse(lhsEmpty.IsProperSubsetOf(lhsEmpty)); Assert.IsFalse(lhs1.IsProperSubsetOf(lhs1)); Assert.IsFalse(lhs2.IsProperSubsetOf(lhs2)); Assert.IsFalse(lhs3.IsProperSubsetOf(lhs3)); Assert.IsFalse(lhsEmpty.IsProperSubsetOf(hsEmpty)); Assert.IsFalse(lhs1.IsProperSubsetOf(hs1)); Assert.IsFalse(lhs2.IsProperSubsetOf(hs2)); Assert.IsFalse(lhs3.IsProperSubsetOf(hs3)); Assert.IsFalse(lhsEmpty.IsProperSubsetOf(setEmpty)); Assert.IsFalse(lhs1.IsProperSubsetOf(set1)); Assert.IsFalse(lhs2.IsProperSubsetOf(set2)); Assert.IsFalse(lhs3.IsProperSubsetOf(set3)); Assert.IsFalse(lhsEmpty.IsProperSubsetOf(GetEnumerator(setEmpty))); Assert.IsFalse(lhs1.IsProperSubsetOf(GetEnumerator(set1))); Assert.IsFalse(lhs2.IsProperSubsetOf(GetEnumerator(set2))); Assert.IsFalse(lhs3.IsProperSubsetOf(GetEnumerator(set3))); Assert.IsTrue(lhsEmpty.IsProperSubsetOf(lhs1)); Assert.IsTrue(lhsEmpty.IsProperSubsetOf(lhs2)); Assert.IsTrue(lhsEmpty.IsProperSubsetOf(lhs3)); Assert.IsTrue(lhsEmpty.IsProperSubsetOf(hs1)); Assert.IsTrue(lhsEmpty.IsProperSubsetOf(hs2)); Assert.IsTrue(lhsEmpty.IsProperSubsetOf(hs3)); Assert.IsTrue(lhsEmpty.IsProperSubsetOf(set1)); Assert.IsTrue(lhsEmpty.IsProperSubsetOf(set2)); Assert.IsTrue(lhsEmpty.IsProperSubsetOf(set3)); Assert.IsTrue(lhsEmpty.IsProperSubsetOf(GetEnumerator(set1))); Assert.IsTrue(lhsEmpty.IsProperSubsetOf(GetEnumerator(set2))); Assert.IsTrue(lhsEmpty.IsProperSubsetOf(GetEnumerator(set3))); Assert.IsFalse(lhs1.IsProperSubsetOf(lhsEmpty)); Assert.IsFalse(lhs1.IsProperSubsetOf(lhs2)); Assert.IsFalse(lhs1.IsProperSubsetOf(lhs3)); Assert.IsFalse(lhs1.IsProperSubsetOf(hsEmpty)); Assert.IsFalse(lhs1.IsProperSubsetOf(hs2)); Assert.IsFalse(lhs1.IsProperSubsetOf(hs3)); Assert.IsFalse(lhs1.IsProperSubsetOf(setEmpty)); Assert.IsFalse(lhs1.IsProperSubsetOf(set2)); Assert.IsFalse(lhs1.IsProperSubsetOf(set3)); Assert.IsFalse(lhs1.IsProperSubsetOf(GetEnumerator(setEmpty))); Assert.IsFalse(lhs1.IsProperSubsetOf(GetEnumerator(set2))); Assert.IsFalse(lhs1.IsProperSubsetOf(GetEnumerator(set3))); Assert.IsFalse(lhs2.IsProperSubsetOf(lhsEmpty)); Assert.IsTrue(lhs2.IsProperSubsetOf(lhs1)); Assert.IsTrue(lhs2.IsProperSubsetOf(lhs3)); Assert.IsFalse(lhs2.IsProperSubsetOf(hsEmpty)); Assert.IsTrue(lhs2.IsProperSubsetOf(hs1)); Assert.IsTrue(lhs2.IsProperSubsetOf(hs3)); Assert.IsFalse(lhs2.IsProperSubsetOf(setEmpty)); Assert.IsTrue(lhs2.IsProperSubsetOf(set1)); Assert.IsTrue(lhs2.IsProperSubsetOf(set3)); Assert.IsFalse(lhs2.IsProperSubsetOf(GetEnumerator(setEmpty))); Assert.IsTrue(lhs2.IsProperSubsetOf(GetEnumerator(set1))); Assert.IsTrue(lhs2.IsProperSubsetOf(GetEnumerator(set3))); Assert.IsFalse(lhs3.IsProperSubsetOf(lhsEmpty)); Assert.IsFalse(lhs3.IsProperSubsetOf(lhs1)); Assert.IsFalse(lhs3.IsProperSubsetOf(lhs2)); Assert.IsFalse(lhs3.IsProperSubsetOf(hsEmpty)); Assert.IsFalse(lhs3.IsProperSubsetOf(hs1)); Assert.IsFalse(lhs3.IsProperSubsetOf(hs2)); Assert.IsFalse(lhs3.IsProperSubsetOf(setEmpty)); Assert.IsFalse(lhs3.IsProperSubsetOf(set1)); Assert.IsFalse(lhs3.IsProperSubsetOf(set2)); Assert.IsFalse(lhs3.IsProperSubsetOf(GetEnumerator(setEmpty))); Assert.IsFalse(lhs3.IsProperSubsetOf(GetEnumerator(set1))); Assert.IsFalse(lhs3.IsProperSubsetOf(GetEnumerator(set2))); #endregion #region IsSupersetOf Assert.IsTrue(lhsEmpty.IsSupersetOf(lhsEmpty)); Assert.IsTrue(lhs1.IsSupersetOf(lhs1)); Assert.IsTrue(lhs2.IsSupersetOf(lhs2)); Assert.IsTrue(lhs3.IsSupersetOf(lhs3)); Assert.IsTrue(lhsEmpty.IsSupersetOf(hsEmpty)); Assert.IsTrue(lhs1.IsSupersetOf(hs1)); Assert.IsTrue(lhs2.IsSupersetOf(hs2)); Assert.IsTrue(lhs3.IsSupersetOf(hs3)); Assert.IsTrue(lhsEmpty.IsSupersetOf(setEmpty)); Assert.IsTrue(lhs1.IsSupersetOf(set1)); Assert.IsTrue(lhs2.IsSupersetOf(set2)); Assert.IsTrue(lhs3.IsSupersetOf(set3)); Assert.IsTrue(lhsEmpty.IsSupersetOf(GetEnumerator(setEmpty))); Assert.IsTrue(lhs1.IsSupersetOf(GetEnumerator(set1))); Assert.IsTrue(lhs2.IsSupersetOf(GetEnumerator(set2))); Assert.IsTrue(lhs3.IsSupersetOf(GetEnumerator(set3))); Assert.IsFalse(lhsEmpty.IsSupersetOf(lhs1)); Assert.IsFalse(lhsEmpty.IsSupersetOf(lhs2)); Assert.IsFalse(lhsEmpty.IsSupersetOf(lhs3)); Assert.IsFalse(lhsEmpty.IsSupersetOf(hs1)); Assert.IsFalse(lhsEmpty.IsSupersetOf(hs2)); Assert.IsFalse(lhsEmpty.IsSupersetOf(hs3)); Assert.IsFalse(lhsEmpty.IsSupersetOf(set1)); Assert.IsFalse(lhsEmpty.IsSupersetOf(set2)); Assert.IsFalse(lhsEmpty.IsSupersetOf(set3)); Assert.IsFalse(lhsEmpty.IsSupersetOf(GetEnumerator(set1))); Assert.IsFalse(lhsEmpty.IsSupersetOf(GetEnumerator(set2))); Assert.IsFalse(lhsEmpty.IsSupersetOf(GetEnumerator(set3))); Assert.IsTrue(lhs1.IsSupersetOf(lhsEmpty)); Assert.IsTrue(lhs1.IsSupersetOf(lhs2)); Assert.IsFalse(lhs1.IsSupersetOf(lhs3)); Assert.IsTrue(lhs1.IsSupersetOf(hsEmpty)); Assert.IsTrue(lhs1.IsSupersetOf(hs2)); Assert.IsFalse(lhs1.IsSupersetOf(hs3)); Assert.IsTrue(lhs1.IsSupersetOf(setEmpty)); Assert.IsTrue(lhs1.IsSupersetOf(set2)); Assert.IsFalse(lhs1.IsSupersetOf(set3)); Assert.IsTrue(lhs1.IsSupersetOf(GetEnumerator(setEmpty))); Assert.IsTrue(lhs1.IsSupersetOf(GetEnumerator(set2))); Assert.IsFalse(lhs1.IsSupersetOf(GetEnumerator(set3))); Assert.IsTrue(lhs2.IsSupersetOf(lhsEmpty)); Assert.IsFalse(lhs2.IsSupersetOf(lhs1)); Assert.IsFalse(lhs2.IsSupersetOf(lhs3)); Assert.IsTrue(lhs2.IsSupersetOf(hsEmpty)); Assert.IsFalse(lhs2.IsSupersetOf(hs1)); Assert.IsFalse(lhs2.IsSupersetOf(hs3)); Assert.IsTrue(lhs2.IsSupersetOf(setEmpty)); Assert.IsFalse(lhs2.IsSupersetOf(set1)); Assert.IsFalse(lhs2.IsSupersetOf(set3)); Assert.IsTrue(lhs2.IsSupersetOf(GetEnumerator(setEmpty))); Assert.IsFalse(lhs2.IsSupersetOf(GetEnumerator(set1))); Assert.IsFalse(lhs2.IsSupersetOf(GetEnumerator(set3))); Assert.IsTrue(lhs3.IsSupersetOf(lhsEmpty)); Assert.IsFalse(lhs3.IsSupersetOf(lhs1)); Assert.IsTrue(lhs3.IsSupersetOf(lhs2)); Assert.IsTrue(lhs3.IsSupersetOf(hsEmpty)); Assert.IsFalse(lhs3.IsSupersetOf(hs1)); Assert.IsTrue(lhs3.IsSupersetOf(hs2)); Assert.IsTrue(lhs3.IsSupersetOf(setEmpty)); Assert.IsFalse(lhs3.IsSupersetOf(set1)); Assert.IsTrue(lhs3.IsSupersetOf(set2)); Assert.IsTrue(lhs3.IsSupersetOf(GetEnumerator(setEmpty))); Assert.IsFalse(lhs3.IsSupersetOf(GetEnumerator(set1))); Assert.IsTrue(lhs3.IsSupersetOf(GetEnumerator(set2))); #endregion #region IsProperSupersetOf Assert.IsFalse(lhsEmpty.IsProperSupersetOf(lhsEmpty)); Assert.IsFalse(lhs1.IsProperSupersetOf(lhs1)); Assert.IsFalse(lhs2.IsProperSupersetOf(lhs2)); Assert.IsFalse(lhs3.IsProperSupersetOf(lhs3)); Assert.IsFalse(lhsEmpty.IsProperSupersetOf(hsEmpty)); Assert.IsFalse(lhs1.IsProperSupersetOf(hs1)); Assert.IsFalse(lhs2.IsProperSupersetOf(hs2)); Assert.IsFalse(lhs3.IsProperSupersetOf(hs3)); Assert.IsFalse(lhsEmpty.IsProperSupersetOf(setEmpty)); Assert.IsFalse(lhs1.IsProperSupersetOf(set1)); Assert.IsFalse(lhs2.IsProperSupersetOf(set2)); Assert.IsFalse(lhs3.IsProperSupersetOf(set3)); Assert.IsFalse(lhsEmpty.IsProperSupersetOf(GetEnumerator(setEmpty))); Assert.IsFalse(lhs1.IsProperSupersetOf(GetEnumerator(set1))); Assert.IsFalse(lhs2.IsProperSupersetOf(GetEnumerator(set2))); Assert.IsFalse(lhs3.IsProperSupersetOf(GetEnumerator(set3))); Assert.IsFalse(lhsEmpty.IsProperSupersetOf(lhs1)); Assert.IsFalse(lhsEmpty.IsProperSupersetOf(lhs2)); Assert.IsFalse(lhsEmpty.IsProperSupersetOf(lhs3)); Assert.IsFalse(lhsEmpty.IsProperSupersetOf(hs1)); Assert.IsFalse(lhsEmpty.IsProperSupersetOf(hs2)); Assert.IsFalse(lhsEmpty.IsProperSupersetOf(hs3)); Assert.IsFalse(lhsEmpty.IsProperSupersetOf(set1)); Assert.IsFalse(lhsEmpty.IsProperSupersetOf(set2)); Assert.IsFalse(lhsEmpty.IsProperSupersetOf(set3)); Assert.IsFalse(lhsEmpty.IsProperSupersetOf(GetEnumerator(set1))); Assert.IsFalse(lhsEmpty.IsProperSupersetOf(GetEnumerator(set2))); Assert.IsFalse(lhsEmpty.IsProperSupersetOf(GetEnumerator(set3))); Assert.IsTrue(lhs1.IsProperSupersetOf(lhsEmpty)); Assert.IsTrue(lhs1.IsProperSupersetOf(lhs2)); Assert.IsFalse(lhs1.IsProperSupersetOf(lhs3)); Assert.IsTrue(lhs1.IsProperSupersetOf(hsEmpty)); Assert.IsTrue(lhs1.IsProperSupersetOf(hs2)); Assert.IsFalse(lhs1.IsProperSupersetOf(hs3)); Assert.IsTrue(lhs1.IsProperSupersetOf(setEmpty)); Assert.IsTrue(lhs1.IsProperSupersetOf(set2)); Assert.IsFalse(lhs1.IsProperSupersetOf(set3)); Assert.IsTrue(lhs1.IsProperSupersetOf(GetEnumerator(setEmpty))); Assert.IsTrue(lhs1.IsProperSupersetOf(GetEnumerator(set2))); Assert.IsFalse(lhs1.IsProperSupersetOf(GetEnumerator(set3))); Assert.IsTrue(lhs2.IsProperSupersetOf(lhsEmpty)); Assert.IsFalse(lhs2.IsProperSupersetOf(lhs1)); Assert.IsFalse(lhs2.IsProperSupersetOf(lhs3)); Assert.IsTrue(lhs2.IsProperSupersetOf(hsEmpty)); Assert.IsFalse(lhs2.IsProperSupersetOf(hs1)); Assert.IsFalse(lhs2.IsProperSupersetOf(hs3)); Assert.IsTrue(lhs2.IsProperSupersetOf(setEmpty)); Assert.IsFalse(lhs2.IsProperSupersetOf(set1)); Assert.IsFalse(lhs2.IsProperSupersetOf(set3)); Assert.IsTrue(lhs2.IsProperSupersetOf(GetEnumerator(setEmpty))); Assert.IsFalse(lhs2.IsProperSupersetOf(GetEnumerator(set1))); Assert.IsFalse(lhs2.IsProperSupersetOf(GetEnumerator(set3))); Assert.IsTrue(lhs3.IsProperSupersetOf(lhsEmpty)); Assert.IsFalse(lhs3.IsProperSupersetOf(lhs1)); Assert.IsTrue(lhs3.IsProperSupersetOf(lhs2)); Assert.IsTrue(lhs3.IsProperSupersetOf(hsEmpty)); Assert.IsFalse(lhs3.IsProperSupersetOf(hs1)); Assert.IsTrue(lhs3.IsProperSupersetOf(hs2)); Assert.IsTrue(lhs3.IsProperSupersetOf(setEmpty)); Assert.IsFalse(lhs3.IsProperSupersetOf(set1)); Assert.IsTrue(lhs3.IsProperSupersetOf(set2)); Assert.IsTrue(lhs3.IsProperSupersetOf(GetEnumerator(setEmpty))); Assert.IsFalse(lhs3.IsProperSupersetOf(GetEnumerator(set1))); Assert.IsTrue(lhs3.IsProperSupersetOf(GetEnumerator(set2))); #endregion #region Remove, Add and Contains Assert.IsTrue(lhs1.Remove(7)); Assert.AreEqual(lhs1.Count, 8); Assert.IsTrue(lhs1.SetEquals(lhs2)); Assert.IsFalse(lhs1.Remove(7)); Assert.AreEqual(lhs1.Count, 8); Assert.IsTrue(lhs1.Add(0)); Assert.AreEqual(lhs1.Count, 9); Assert.IsTrue(lhs1.SetEquals(lhs3)); Assert.IsFalse(lhs1.Add(0)); Assert.AreEqual(lhs1.Count, 9); Assert.IsTrue(lhs1.Contains(3)); Assert.IsTrue(lhs1.Contains(0)); Assert.IsFalse(lhs1.Contains(7)); Assert.IsFalse(lhs3.Contains(7)); lhs1.Clear(); Assert.AreEqual(lhs1.Count, 0); Assert.IsTrue(lhs1.SetEquals(lhsEmpty)); #endregion #region ExceptWith lhs1 = new LinkedHashSet <int>(set1); lhs2 = new LinkedHashSet <int>(set2); lhs3 = new LinkedHashSet <int>(set3); lhs1.ExceptWith(lhs2); Assert.AreEqual(lhs1.Count, 1); Assert.IsTrue(lhs1.Contains(7)); lhs2.ExceptWith(lhs1); Assert.IsTrue(lhs2.SetEquals(set2)); lhs1.ExceptWith(lhs3); Assert.AreEqual(lhs1.Count, 1); Assert.IsTrue(lhs1.Contains(7)); lhs3.ExceptWith(lhs2); Assert.AreEqual(lhs3.Count, 1); Assert.IsTrue(lhs3.Contains(0)); #endregion #region UnionWith lhs1 = new LinkedHashSet <int>(set1); lhs2 = new LinkedHashSet <int>(set2); lhs3 = new LinkedHashSet <int>(set3); lhs1.UnionWith(lhs2); Assert.IsTrue(lhs1.SetEquals(set1)); lhs3.UnionWith(lhs2); Assert.IsTrue(lhs3.SetEquals(set3)); lhs3.UnionWith(lhs1); Assert.IsTrue(lhs3.Contains(7)); Assert.IsTrue(lhs3.Contains(0)); Assert.AreEqual(lhs3.Count, 10); #endregion #region IntersectWith lhs1 = new LinkedHashSet <int>(set1); lhs2 = new LinkedHashSet <int>(set2); lhs3 = new LinkedHashSet <int>(set3); lhs1.IntersectWith(lhs2); Assert.IsTrue(lhs1.SetEquals(set2)); lhs3.IntersectWith(lhs2); Assert.IsTrue(lhs3.SetEquals(set2)); lhs1 = new LinkedHashSet <int>(set1); lhs2 = new LinkedHashSet <int>(set2); lhs3 = new LinkedHashSet <int>(set3); lhs3.IntersectWith(lhs1); Assert.IsFalse(lhs3.Contains(7)); Assert.IsFalse(lhs3.Contains(0)); Assert.AreEqual(lhs3.Count, 8); Assert.IsTrue(lhs3.SetEquals(set2)); #endregion #region SymmetricExceptWith lhs1 = new LinkedHashSet <int>(set1); lhs2 = new LinkedHashSet <int>(set2); lhs3 = new LinkedHashSet <int>(set3); lhs1.SymmetricExceptWith(lhs3); Assert.AreEqual(lhs1.Count, 2); Assert.IsTrue(lhs1.Contains(0)); Assert.IsTrue(lhs1.Contains(7)); lhs1.SymmetricExceptWith(lhs2); Assert.AreEqual(lhs1.Count, 10); #endregion LinkedHashSet <int> lhs = new LinkedHashSet <int>(); for (int i = 0; i < set1.Length; i++) { lhs.Add(set1[i]); } List <int> set1a = new List <int>(); foreach (var i in lhs) { set1a.Add(i); } for (int i = 0; i < set1.Length; i++) { Assert.AreEqual(set1[i], set1a[i]); } lhs.Remove(7); lhs.Add(0); set1a.Clear(); foreach (var i in lhs) { set1a.Add(i); } for (int i = 0; i < set3.Length; i++) { Assert.AreEqual(set3[i], set1a[i]); } }