public bool Contains(KeyValuePair <long, TValue> item) { TValue value; return(TryGetValue(item.Key, out value) && DefaultComparer.Compare(value, item.Value) == 0); }
public void Compare_ForNullArguments_ThrowsNoExceptions() { var comparer = new DefaultComparer(); var difference = comparer.Compare(null, null); Assert.Equal(0, difference); }
public void Compare_ForLineWithoutNumber_ComparesStrings() { var comparer = new DefaultComparer(); var difference = comparer.Compare("Beaver", "Chipmunk"); Assert.Equal(-1, difference); }
public void Compare_ForLineWithoutStringButNumber_TakesNumberForZero2() { var comparer = new DefaultComparer(); var difference = comparer.Compare(" Hello World", "3. Hello World"); Assert.Equal(-1, difference); }
public void Compare_ForEmptyArguments_ThrowsNoExceptions() { var comparer = new DefaultComparer(); var difference = comparer.Compare(string.Empty, string.Empty); Assert.Equal(0, difference); }
public bool Contains(KeyValuePair <byte[], TValue> item) { KeyWalker kw = new KeyWalker(item.Key, item.Key.Length); TValue value = default(TValue); if (base.Find(ref kw, ref value)) { return(DefaultComparer.Compare(value, item.Value) == 0); } return(false); }
public bool Contains(KeyValuePair <string, TValue> item) { KeyWalker kw = StringToBytes(item.Key); TValue value = default(TValue); if (base.Find(ref kw, ref value)) { return(DefaultComparer.Compare(value, item.Value) == 0); } return(false); }
public bool Remove(KeyValuePair <long, TValue> item) { KeyWalker kw = Encode(item.Key); KeyWalker kw2 = kw; TValue value = default(TValue); if (Find(ref kw, ref value) && DefaultComparer.Compare(value, item.Value) == 0) { return(Remove(ref kw2, ref value)); } return(false); }
public bool Remove(KeyValuePair <byte[], TValue> item) { KeyWalker kw = new KeyWalker(item.Key, item.Key.Length); KeyWalker kw2 = kw; TValue value = default(TValue); if (Find(ref kw, ref value) && DefaultComparer.Compare(value, item.Value) == 0) { return(Remove(ref kw2, ref value)); } return(false); }
protected virtual bool UpdateVariableValues(MultivariateTestVariableItem variableItem, out List<ID> modifiedVariations) { Assert.ArgumentNotNull(variableItem, "variableItem"); modifiedVariations = new List<ID>(); List<VariableValueItemStub> variableValues = VariableValues; var list2 = new List<MultivariateTestValueItem>(TestingUtil.MultiVariateTesting.GetVariableValues(variableItem)); var comparer = new DefaultComparer(); list2.Sort((lhs, rhs) => comparer.Compare(lhs, rhs)); int num = (list2.Count > 0) ? (list2[0].InnerItem.Appearance.Sortorder - 1) : Settings.DefaultSortOrder; var templateID = new TemplateID(MultivariateTestValueItem.TemplateID); var list3 = new List<KeyValuePair<MultivariateTestValueItem, VariableValueItemStub>>(); var list4 = new List<KeyValuePair<int, VariableValueItemStub>>(); for (int i = variableValues.Count - 1; i >= 0; i--) { VariableValueItemStub stub = variableValues[i]; ID currentId = stub.Id; int index = list2.FindIndex(item => item.ID == currentId); if (index < 0) { var pair = new KeyValuePair<int, VariableValueItemStub>(num--, stub); list4.Add(pair); } else { MultivariateTestValueItem item = list2[index]; if (IsVariableValueChanged(item, stub)) { list3.Add(new KeyValuePair<MultivariateTestValueItem, VariableValueItemStub>(item, stub)); } list2.RemoveAt(index); } } if (list2.Count != 0) { } foreach (Item item2 in list2) { modifiedVariations.Add(item2.ID); item2.Delete(); } foreach (var pair2 in list4) { VariableValueItemStub variableStub = pair2.Value; int key = pair2.Key; string name = variableStub.Name; if (ContainsNonASCIISymbols(name)) { Item item3 = variableItem.Database.GetItem(templateID.ID); name = (item3 != null) ? item3.Name : "Unnamed item"; } if (!ItemUtil.IsItemNameValid(name)) { try { name = ItemUtil.ProposeValidItemName(name); } catch (Exception) { return false; } } name = ItemUtil.GetUniqueName(variableItem, name); Item item4 = variableItem.InnerItem.Add(name, templateID); Assert.IsNotNull(item4, "newVariableValue"); UpdateVariableValueItem((MultivariateTestValueItem) item4, variableStub, key); } foreach (var pair3 in list3) { MultivariateTestValueItem variableValue = pair3.Key; VariableValueItemStub stub3 = pair3.Value; modifiedVariations.Add(variableValue.ID); UpdateVariableValueItem(variableValue, stub3); } return true; }
/// <summary> /// Overrides <see cref="IComparable{PropVariant}"/>. This comparer uses the <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/bb776517(v=vs.85).aspx">PropVariantCompareEx</a> function to /// compare the values of two <see cref="PropVariant"/> objects. /// </summary> /// <param name="other">The PropVariant to compare with this PropVariant</param> /// <returns>An integer indicating the relationship between the two PropVariants</returns> public int CompareTo(PropVariant other) { return(DefaultComparer.Compare(this, other)); }
static public int Compare(IDataNode left, IDataNode right) { return(DefaultComparer.Compare(left, right)); }
protected virtual bool UpdateVariableValues(MultivariateTestVariableItem variableItem, out List <ID> modifiedVariations) { Assert.ArgumentNotNull(variableItem, "variableItem"); modifiedVariations = new List <ID>(); List <VariableValueItemStub> variableValues = VariableValues; var list2 = new List <MultivariateTestValueItem>(TestingUtil.MultiVariateTesting.GetVariableValues(variableItem)); var comparer = new DefaultComparer(); list2.Sort((lhs, rhs) => comparer.Compare(lhs, rhs)); int num = (list2.Count > 0) ? (list2[0].InnerItem.Appearance.Sortorder - 1) : Settings.DefaultSortOrder; var templateID = new TemplateID(MultivariateTestValueItem.TemplateID); var list3 = new List <KeyValuePair <MultivariateTestValueItem, VariableValueItemStub> >(); var list4 = new List <KeyValuePair <int, VariableValueItemStub> >(); for (int i = variableValues.Count - 1; i >= 0; i--) { VariableValueItemStub stub = variableValues[i]; ID currentId = stub.Id; int index = list2.FindIndex(item => item.ID == currentId); if (index < 0) { var pair = new KeyValuePair <int, VariableValueItemStub>(num--, stub); list4.Add(pair); } else { MultivariateTestValueItem item = list2[index]; if (IsVariableValueChanged(item, stub)) { list3.Add(new KeyValuePair <MultivariateTestValueItem, VariableValueItemStub>(item, stub)); } list2.RemoveAt(index); } } if (list2.Count != 0) { } foreach (Item item2 in list2) { modifiedVariations.Add(item2.ID); item2.Delete(); } foreach (var pair2 in list4) { VariableValueItemStub variableStub = pair2.Value; int key = pair2.Key; string name = variableStub.Name; if (ContainsNonASCIISymbols(name)) { Item item3 = variableItem.Database.GetItem(templateID.ID); name = (item3 != null) ? item3.Name : "Unnamed item"; } if (!ItemUtil.IsItemNameValid(name)) { try { name = ItemUtil.ProposeValidItemName(name); } catch (Exception) { return(false); } } name = ItemUtil.GetUniqueName(variableItem, name); Item item4 = variableItem.InnerItem.Add(name, templateID); Assert.IsNotNull(item4, "newVariableValue"); UpdateVariableValueItem((MultivariateTestValueItem)item4, variableStub, key); } foreach (var pair3 in list3) { MultivariateTestValueItem variableValue = pair3.Key; VariableValueItemStub stub3 = pair3.Value; modifiedVariations.Add(variableValue.ID); UpdateVariableValueItem(variableValue, stub3); } return(true); }