public override int CompareAxisRows(Timeline axis1, int i1, Timeline axis2, int i2) { long eventX = axis1.Event[i1]; long eventY = axis2.Event[i2]; int compareResult = eventX.CompareTo(eventY); if (compareResult == 0) { RCTimeScalar timeX = axis1.Time[i1]; RCTimeScalar timeY = axis2.Time[i2]; compareResult = timeX.CompareTo(timeY); if (compareResult == 0) { RCSymbolScalar symbolX = axis1.SymbolAt(i1); RCSymbolScalar symbolY = axis2.SymbolAt(i2); return(symbolX.CompareTo(symbolY)); } else { return(compareResult); } } else { return(compareResult); } }
public override int CompareAxisRows(Timeline axis1, int i1, Timeline axis2, int i2) { RCSymbolScalar symbolX = axis1.SymbolAt(i1); RCSymbolScalar symbolY = axis2.SymbolAt(i2); return(symbolX.CompareTo(symbolY)); }
public override int CompareAxisRows(Timeline axis1, int i1, Timeline axis2, int i2) { RCAssert.AxisHasT(axis1, "CompareAxisRows: axis1 must contain the T column"); RCAssert.AxisHasT(axis2, "CompareAxisRows: axis2 must contain the T column"); RCTimeScalar timeX = axis1.Time[i1]; RCTimeScalar timeY = axis2.Time[i2]; int compareResult = timeX.CompareTo(timeY); if (compareResult == 0) { RCSymbolScalar symbolX = axis1.SymbolAt(i1); RCSymbolScalar symbolY = axis2.SymbolAt(i2); return(symbolX.CompareTo(symbolY)); } else { return(compareResult); } }
/// <summary> /// DoAxisRank implements the standard ranking for a sorted timeline axis, which is by /// T or E, followed by S. /// </summary> public static Dictionary <long, int> DoAxisRank(Timeline axis) { int[] indices = new int[axis.Count]; for (int i = 0; i < axis.Count; ++i) { indices[i] = i; } Comparison <int> comparison; if (axis.Symbol != null) { if (axis.Event != null) { // E S cube comparison = delegate(int ix, int iy) { long eventX = axis.Event[ix]; long eventY = axis.Event[iy]; int compareResult = eventX.CompareTo(eventY); if (compareResult == 0) { RCSymbolScalar symbolX = axis.SymbolAt(ix); RCSymbolScalar symbolY = axis.SymbolAt(iy); return(symbolX.CompareTo(symbolY)); } else { return(compareResult); } }; } else if (axis.Time != null) { // T S cube comparison = delegate(int ix, int iy) { RCTimeScalar timeX = axis.Time[ix]; RCTimeScalar timeY = axis.Time[iy]; int compareResult = timeX.CompareTo(timeY); if (compareResult == 0) { RCSymbolScalar symbolX = axis.SymbolAt(ix); RCSymbolScalar symbolY = axis.SymbolAt(iy); return(symbolX.CompareTo(symbolY)); } else { return(compareResult); } }; } else { // S cube comparison = delegate(int ix, int iy) { RCSymbolScalar symbolX = axis.SymbolAt(ix); RCSymbolScalar symbolY = axis.SymbolAt(iy); return(symbolX.CompareTo(symbolY)); }; } } else { if (axis.Event != null) { // E cube comparison = delegate(int ix, int iy) { long eventX = axis.Event[ix]; long eventY = axis.Event[iy]; int compareResult = eventX.CompareTo(eventY); return(compareResult); }; } else if (axis.Time != null) { // T cube comparison = delegate(int ix, int iy) { RCTimeScalar timeX = axis.Time[ix]; RCTimeScalar timeY = axis.Time[iy]; return(timeX.CompareTo(timeY)); }; } else { throw new Exception( "Cube sorting can only be applied to cubes with the following axis configurations: S, T, E, E S, T S"); } } Array.Sort(indices, comparison); Dictionary <long, int> result = new Dictionary <long, int> (); for (int i = 0; i < indices.Length; ++i) { result[indices[i]] = i; } return(result); }