public void LinkedHashSet_Generic_CopyTo_NegativeCount_ThrowsArgumentOutOfRangeException(int count) { LinkedHashSet <T> set = (LinkedHashSet <T>)GenericISetFactory(count); T[] arr = new T[count]; Assert.Throws <ArgumentOutOfRangeException>(() => set.CopyTo(arr, 0, -1)); Assert.Throws <ArgumentOutOfRangeException>(() => set.CopyTo(arr, 0, int.MinValue)); }
public void LinkedHashSet_Generic_CopyTo_NoIndexDefaultsToZero(int count) { LinkedHashSet <T> set = (LinkedHashSet <T>)GenericISetFactory(count); T[] arr1 = new T[count]; T[] arr2 = new T[count]; set.CopyTo(arr1); set.CopyTo(arr2, 0); Assert.True(arr1.SequenceEqual(arr2)); }
public void LinkedHashSet_Generic_RemoveWhere_NewObject() // Regression Dev10_624201 { object[] array = new object[2]; object obj = new object(); LinkedHashSet <object> set = new LinkedHashSet <object>(); set.Add(obj); set.Remove(obj); foreach (object o in set) { } set.CopyTo(array, 0, 2); set.RemoveWhere((element) => { return(false); }); }
public CategoricalDistribution jointDistribution( params IProposition[] propositions) { ProbabilityTable d = null; IProposition conjProp = ProbUtil .constructConjunction(propositions); LinkedHashSet <RandomVariable> vars = new LinkedHashSet <RandomVariable>( conjProp.getUnboundScope()); if (vars.Count > 0) { RandomVariable[] distVars = new RandomVariable[vars.Count]; vars.CopyTo(distVars); ProbabilityTable ud = new ProbabilityTable(distVars); Object[] values = new Object[vars.Count]; //ProbabilityTable.Iterator di = new ProbabilityTable.Iterator() { // public void iterate(Map<RandomVariable, Object> possibleWorld, // double probability) { // if (conjProp.holds(possibleWorld)) { // int i = 0; // for (RandomVariable rv : vars) { // values[i] = possibleWorld.get(rv); // i++; // } // int dIdx = ud.getIndex(values); // ud.setValue(dIdx, ud.getValues()[dIdx] + probability); // } // } //}; //distribution.iterateOverTable(di); // TODO: d = ud; } else { // No Unbound Variables, therefore just return // the singular probability related to the proposition. d = new ProbabilityTable(); d.setValue(0, prior(propositions)); } return(d); }
public CategoricalDistribution jointDistribution( params IProposition[] propositions) { ProbabilityTable d = null; IProposition conjProp = ProbUtil .constructConjunction(propositions); LinkedHashSet<RandomVariable> vars = new LinkedHashSet<RandomVariable>( conjProp.getUnboundScope()); if (vars.Count > 0) { RandomVariable[] distVars = new RandomVariable[vars.Count]; vars.CopyTo(distVars); ProbabilityTable ud = new ProbabilityTable(distVars); Object[] values = new Object[vars.Count]; //ProbabilityTable.Iterator di = new ProbabilityTable.Iterator() { // public void iterate(Map<RandomVariable, Object> possibleWorld, // double probability) { // if (conjProp.holds(possibleWorld)) { // int i = 0; // for (RandomVariable rv : vars) { // values[i] = possibleWorld.get(rv); // i++; // } // int dIdx = ud.getIndex(values); // ud.setValue(dIdx, ud.getValues()[dIdx] + probability); // } // } //}; //distribution.iterateOverTable(di); // TODO: d = ud; } else { // No Unbound Variables, therefore just return // the singular probability related to the proposition. d = new ProbabilityTable(); d.setValue(0, prior(propositions)); } return d; }