public int index_of(match m) { if (m.line_idx < 0) { // it's the empty match return(-1); } lock (this) { // 1.6.16 in event log, matches are still sorted correctly int idx = matches_.binary_search_closest(x => x.line_idx, m.line_idx).Item2; // 1.6.10 - this seems to generate a lot of asserts for event viewer, even though logically the code is correct // I will take a look at a later time //if ( idx >= 0 && !reverse_order) // Debug.Assert(matches_[idx] == m); return(idx); } }
// 1.0.84 note: if this is proves too slow, i'll do a binary search by m.line_idx !!! public int index_of(match m) { if (m.line_idx < 0) { // it's the empty match return(-1); } lock (this) { //return matches_.IndexOf(m); int idx = matches_.binary_search_closest(x => x.line_idx, m.line_idx).Item2; if (idx >= 0) { Debug.Assert(matches_[idx] == m); } return(idx); } }