public List <KeyValuePair <int, int> > FindRangesWithSameValues(List <IColumnElement> array) { List <KeyValuePair <int, int> > result = new List <KeyValuePair <int, int> >(); IColumnElement currentName = array[0]; int key = -1; for (int i = 1; i < array.Count; i++) { if (currentName.IsEqualTo(array[i])) { if (key == -1) { key = i - 1; } } else { currentName = array[i]; if (key != -1) { result.Add(new KeyValuePair <int, int>(key, i - 1)); key = -1; } } } // Logic to include last value if any if (key != -1) { result.Add(new KeyValuePair <int, int>(key, array.Count - 1)); } return(result); }
public bool IsLessThan(IColumnElement other) { Age otherAsName = other as Age; return(this.data < otherAsName.data); }
public bool IsEqualTo(IColumnElement other) { Age otherAsName = other as Age; return(this.data == otherAsName.data); }
public bool IsGreaterThan(IColumnElement other) { Age otherAsName = other as Age; return(this.data > otherAsName.data); }
public bool IsLessThan(IColumnElement other) { Name otherAsName = other as Name; return(this.data.CompareTo(otherAsName.data) < 0); }
public bool IsEqualTo(IColumnElement other) { Name otherAsName = other as Name; return(this.data.CompareTo(otherAsName.data) == 0); }
public bool IsLessThan(IColumnElement other) { Weight otherAsName = other as Weight; return(this.data > otherAsName.data); // Weight sorted in descending order }
public bool IsEqualTo(IColumnElement other) { Weight otherAsName = other as Weight; return(this.data == otherAsName.data); }