예제 #1
0
 public void Setup()
 {
     _byteFactory   = new ByteFactory(new Base10Converter());
     _and           = new And();
     _not           = new Not();
     _nAnd          = new NAnd(_not, _and);
     _or            = new Or(_not, _nAnd);
     _xOr           = new XOr(_not, _nAnd);
     _bitComparator = new BitComparator(_xOr, _and, _or, _not);
     _byteToBase10  = new ByteToBase10Converter(_byteFactory, new Base10Converter());
     _sut           = new ByteComparator(_bitComparator, _byteFactory);
 }
예제 #2
0
        /// <summary>
        /// Sorts the receiver according
        /// to the order induced by the specified comparatord  All elements in the
        /// range must be <i>mutually comparable</i> by the specified comparator
        /// (that is, <i>c.CompareTo(e1, e2)</i> must not throw a
        /// <i>ClassCastException</i> for any elements <i>e1</i> and
        /// <i>e2</i> in the range).<p>
        ///
        /// The sorting algorithm is a tuned quicksort,
        /// adapted from Jon Ld Bentley and Md Douglas McIlroy's "Engineering a
        /// Sort Function", Software-Practice and Experience, Vold 23(11)
        /// Pd 1249-1265 (November 1993)d  This algorithm offers n*log(n)
        /// performance on many data sets that cause other quicksorts to degrade to
        /// quadratic performance.
        ///
        /// <summary>
        /// <param name="from">the index of the first element (inclusive) to be</param>
        ///        sorted.
        /// <param name="to">the index of the last element (inclusive) to be sorted.</param>
        /// <param name="c">the comparator to determine the order of the receiver.</param>
        /// <exception cref="ClassCastException">if the array contains elements that are not </exception>
        ///	       <i>mutually comparable</i> using the specified comparator.
        /// <exception cref="ArgumentException">if <i>fromIndex &gt; toIndex</i> </exception>
        /// <exception cref="ArrayIndexOutOfRangeException">if <i>fromIndex &lt; 0</i> or </exception>
        ///	       <i>toIndex &gt; a.Length</i>
        /// <see cref="Comparator"></see>
        /// <exception cref="IndexOutOfRangeException">index is out of range (<i>_size()&gt;0 && (from&lt;0 || from&gt;to || to&gt;=_size())</i>). </exception>
        public virtual void QuickSortFromTo(int from, int to, ByteComparator c)
        {
            int mySize = Size;

            CheckRangeFromTo(from, to, mySize);

            var myElements = GetElements();

            Cern.Colt.Sorting.QuickSort(myElements, from, to + 1, c);
            SetElements(myElements);
            SetSizeRaw(mySize);
        }