///<summary> /// "And" and "Near" Ops. Particular behavior is determined by optional /// predicate which may perform additional check of [intermediate] document, /// feasible for inclusion into the result set /// </summary> private static Entry[] Intercross(Entry[] leftIndices, Entry[] rightIndices, EntryProximity reqProximity) { if ((leftIndices == null) || (rightIndices == null)) { return(null); } Array.Sort(leftIndices); Array.Sort(rightIndices); //--------------------------------------------------------------------- ArrayList array_ = new ArrayList(); int i_Left = 0, i_Right = 0; while ((i_Left < leftIndices.Length) && (i_Right < rightIndices.Length)) { if (leftIndices[i_Left].DocIndex == rightIndices[i_Right].DocIndex) { EntryProximity scope = ProximityEstimator.EstimateProximity(leftIndices[i_Left], rightIndices[i_Right]); if (scope <= reqProximity) { leftIndices[i_Left].Proximity = scope; array_.Add(JoinInstancesOfEntries(leftIndices[i_Left], rightIndices[i_Right], reqProximity)); } i_Left++; i_Right++; } else if (leftIndices[i_Left].DocIndex < rightIndices[i_Right].DocIndex) { i_Left++; } else { i_Right++; } } //--------------------------------------------------------------------- Entry[] ai_Result = null; if (array_.Count > 0) { ai_Result = new Entry[array_.Count]; array_.CopyTo(ai_Result); } return(ai_Result); }
private static List <long> Intercross(List <long> leftIndices, List <long> rightIndices, EntryProximity reqProximity) { if ((leftIndices == null) || (rightIndices == null)) { return(null); } leftIndices.Sort(); rightIndices.Sort(); List <long> result = new List <long>(); EntryProximity scope = ProximityEstimator.EstimateProximity(leftIndices, rightIndices); if (scope <= reqProximity) { result.AddRange(JoinInstancesOfEntries(leftIndices, rightIndices, reqProximity)); } return((result.Count == 0) ? null : result); }