Exemplo n.º 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]);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
 public bool Contains(string candidate)
 {
     return(words.BinarySearch(candidate) > -1);
 }