public override int CompareTo(object other, System.Collections.IComparer comparer) { if (other == null) { return(0); } if (other is Cons <T> ) { var cons = (Cons <T>)other; int headComparisonResult = comparer.Compare(this.head, cons.head); if (headComparisonResult != 0) { return(headComparisonResult); } else { return(this.tail.CompareTo(cons.tail, comparer)); } } if (other is Nil <T> ) { return(1); } else { return(0); } }
public bool Equals(object other, System.Collections.IComparer comparer) { if (comparer.Compare(other, this) == 0) { return(true); } else { return(false); } }
public static bool ArrayContains(Array array, object value, System.Collections.IComparer comparer) { foreach (object item in array) { if (comparer.Compare(item, value) == 0) { return(true); } } return(false); }
public override int CompareTo(object other, System.Collections.IComparer comparer) { if (other == null) { return(0); } if (other is Some <T> ) { return(-1); } else if (other is None <T> ) { var none = (None <T>)other; return(comparer.Compare(this.GetType().DeclaringType, none.GetType().DeclaringType)); } else { return(comparer.Compare(this, other)); } }
public override int CompareTo(object other, System.Collections.IComparer comparer) { if (other == null) { return(0); } if (other is Some <T> ) { var some = (Some <T>)other; return(comparer.Compare(this.value, some.value)); } else if (other is None <T> ) { return(1); } else { return(0); } }
/// <summary> /// Implementation of System.Collections.IComparer.Compare() /// Can be used to compare symbolic arrays /// Do not invoke with null arguments! /// </summary> /// <param name="_X">Object[]</param> /// <param name="_Y">Object[]</param> /// <returns>-1, 0, or 1</returns> int System.Collections.IComparer.Compare(Object _X, Object _Y) { Object[] X = (Object[])_X; Object[] Y = (Object[])_Y; // skip the Doubles int ix = 0, iy = 0; double sx = 1.0, sy = 1.0; while ((ix < X.Length) && Object.ReferenceEquals(X[ix].GetType(), DT)) { sx *= (double)X[ix]; ix++; } while ((iy < Y.Length) && Object.ReferenceEquals(Y[iy].GetType(), DT)) { sy *= (double)Y[iy]; iy++; } while ((ix < X.Length) && (iy < Y.Length)) // compare all elements of the arrays { int compVal = SSSC.Compare(X[ix], Y[iy]); if (compVal != 0) { return(compVal); // values in arrays X and Y are not equal, so return -1 or +1 } ix++; iy++; } if ((ix == X.Length) && (iy == Y.Length)) { return(0); // ((sx < sy) ? -1 : ((sx > sy) ? 1 : 0)); // arrays are identical (up to Doubles) } else if (ix == X.Length) { return(-1); // X is smaller than Y } else { return(1); // Y is larger than X } }
public int Compare(object x, object y) { return(_comparer.Compare(((SearchHit)x).Record, ((SearchHit)y).Record)); }