public Tuple <Range, Converter <IEnumerable <double>, IEnumerable <double> > > DataTransformer(int transformedDataIndex) { int foundIndex = dataTransformers.BinarySearch(new Tuple <Range, Converter <IEnumerable <double>, IEnumerable <double> > >(new Range(transformedDataIndex, transformedDataIndex), null), rangeComparer); if (foundIndex < 0) { foundIndex = ~foundIndex - 1; } transformedDataIndex.ShouldBeLessThan(dataTransformers[foundIndex].Item1.End.Value); return(dataTransformers[foundIndex]); }
private int GetCurrentPosition(KeyValuePair <TKey, TObject> item) { int index; if (_optimisations.HasFlag(SortOptimisations.ComparesImmutableValuesOnly)) { index = _list.BinarySearch(item, _comparer); if (index < 0) { throw new SortException("Current position cannot be found. Ensure the comparer includes a unique value, or do not specify ComparesImmutableValuesOnly"); } } else { index = _list.IndexOf(item); if (index < 0) { throw new SortException("Current position cannot be found. The item is not in the collection"); } } return(index); }
public bool Contains(string candidate) { return(words.BinarySearch(candidate) > -1); }