Пример #1
0
        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]);
        }
Пример #2
0
        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);
        }
Пример #3
0
 public bool Contains(string candidate)
 {
     return(words.BinarySearch(candidate) > -1);
 }