예제 #1
0
        private int GetInsertPositionBinary(T item)
        {
            int index       = _innerList.BinarySearch(item, _comparer);
            int insertIndex = ~index;

            //sort is not returning uniqueness
            if (insertIndex < 0)
            {
                throw new SortException("Binary search has been specified, yet the sort does not yeild uniqueness");
            }
            return(insertIndex);
        }
예제 #2
0
        private int GetCurrentPosition(ChangeAwareList <T> target, T item)
        {
            int index = _sortOptions == SortOptions.UseBinarySearch
                ? target.BinarySearch(item, _comparer)
                : target.IndexOf(item);

            if (index < 0)
            {
                throw new SortException("Current item cannot be found");
            }

            return(index);
        }