예제 #1
0
        public void AddElement()
        {
            IComparer <int> comparer = new IntComparer();

            // []
            var array = new int[0];

            // [10]
            array = array.BinaryAdd(10, comparer);
            Assert.IsTrue(array.Length == 1);
            Assert.IsTrue(array[0] == 10);

            // [0, 10]
            array = array.BinaryAdd(0, comparer);
            Assert.IsTrue(array.Length == 2);
            Assert.IsTrue(array[0] == 0);
            Assert.IsTrue(array[1] == 10);

            // [0, 8, 10]
            array = array.BinaryAdd(8, comparer);
            Assert.IsTrue(array.Length == 3);
            Assert.IsTrue(array[0] == 0);
            Assert.IsTrue(array[1] == 8);
            Assert.IsTrue(array[2] == 10);

            // [0, 8, 10]
            array = array.BinaryAdd(8, comparer);
            Assert.IsTrue(array.Length == 3);
            Assert.IsTrue(array[0] == 0);
            Assert.IsTrue(array[1] == 8);
            Assert.IsTrue(array[2] == 10);
        }
        public void BinarySearchTree_Int_Comparer_TraverseTest()
        {
            int[] items       = { 9, 8, 7, 6, 11, 12, 13, 2 };
            var   comparer    = new IntComparer();
            var   testTree    = new BinarySearchTree <int>(items, comparer);
            var   inOrderTree = new int[testTree.Count];
            int   i           = 0;

            foreach (var item in testTree.InOrder())
            {
                inOrderTree[i] = item;
                i++;
            }

            int[] preOrderTree = new int[testTree.Count];
            i = 0;
            foreach (var item in testTree.PreOrder())
            {
                preOrderTree[i] = item;
                i++;
            }

            var postOrderTree = new int[testTree.Count];

            i = 0;
            foreach (var item in testTree.PostOrder())
            {
                postOrderTree[i] = item;
                i++;
            }

            CollectionAssert.AreEqual(new int[] { 13, 12, 11, 9, 8, 7, 6, 2 }, inOrderTree);
            CollectionAssert.AreEqual(new int[] { 9, 11, 12, 13, 8, 7, 6, 2 }, preOrderTree);
            CollectionAssert.AreEqual(new int[] { 13, 12, 11, 2, 6, 7, 8, 9 }, postOrderTree);
        }
예제 #3
0
        private static IList <int> _createSortNodeIndexs(IEnumerable <TreeNode> collection)
        {
            var comparer   = new IntComparer();
            var nodeIndexs = new List <int>(collection.Select(t => t.Index).OrderBy(x => x, comparer));

            return(nodeIndexs);
        }
        public static void ArraySorted_OnDisk([Random(0, 1000, 100, Distinct = true)] int n)
        {
            // Arrange
            var sorter      = new ExternalMergeSorter <int>();
            var intComparer = new IntComparer();

            var(correctArray, testArray) = RandomHelper.GetArrays(n);
            var randomizer = Randomizer.CreateRandomizer();
            var main       = new IntFileStorage($"sorted_{randomizer.GetString(100)}", n);
            var temp       = new IntFileStorage($"temp_{randomizer.GetString(100)}", n);

            var writer = main.GetWriter();

            for (var i = 0; i < n; i++)
            {
                writer.Write(correctArray[i]);
            }
            writer.Dispose();

            // Act
            sorter.Sort(main, temp, intComparer);
            Array.Sort(correctArray, intComparer);

            // Assert
            var reader = main.GetReader();

            for (var i = 0; i < n; i++)
            {
                testArray[i] = reader.Read();
            }

            Assert.AreEqual(testArray, correctArray);
        }
예제 #5
0
    public void RunTestSort()
    {
        dst_text.text = string.Empty;
        if (random_array)
        {//配列初期化.
            int length = items.Length;
            for (int k = 0; k < length; ++k)
            {
                items[k] = Mathf.FloorToInt(Random.Range(min_int, max_int + 1 - float.Epsilon));
            }
        }
        //for (int k = 0; k < items.Length; ++k)
        //{
        //    dst_text.text += (items[k].ToString("D3") + "\t");
        //}
        //dst_text.text += "\n";
#if true //通常のソート
        List <int>  sortlist = new List <int>(items);
        IntComparer com      = new IntComparer();
        sortlist.Sort(com);
        sorteditem = sortlist.ToArray();
#endif

        StartCoroutine(Sort());
    }
예제 #6
0
        public void Serch_Positive_Test(int result, int value, params int[] array)
        {
            IComparer <int> comp = new IntComparer();

            Array.Sort(array);

            Assert.AreEqual(result, BinarySearch <int> .Search(array, value, comp));
        }
예제 #7
0
파일: Comparer.cs 프로젝트: krs43/ngenerics
        public void Set()
        {
            var comparer = new ReverseComparer <int>();

            IComparer <int> newComparer = new IntComparer();

            comparer.Comparer = newComparer;

            Assert.AreEqual(comparer.Comparer, newComparer);
        }
예제 #8
0
        public void Simple()
        {
            var comparer = new ReverseComparer <int>();

            Assert.AreEqual(comparer.Comparer, Comparer <int> .Default);

            IComparer <int> newComparer = new IntComparer();

            comparer = new ReverseComparer <int>(newComparer);

            Assert.AreEqual(comparer.Comparer, newComparer);
        }
예제 #9
0
 static public int constructor(IntPtr l)
 {
     try {
         IntComparer o;
         o = new IntComparer();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #10
0
        public static void SortsArray([Random(0, 1000, 100, Distinct = true)]int n)
        {
            // Arrange
            var sorter = new CocktailSorter<int>();
            var intComparer = new IntComparer();
            var (correctArray, testArray) = RandomHelper.GetArrays(n);

            // Act
            sorter.Sort(testArray, intComparer);
            Array.Sort(correctArray);

            // Assert
            Assert.AreEqual(correctArray, testArray);
        }
예제 #11
0
파일: Program.cs 프로젝트: HellSir/NikTest
        static void Main(string[] args)
        {
            int[]       arr        = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray(); //вводим элементы массива через пробел
            IntComparer myComparer = new IntComparer();                                                 //Класс, реализующий сравнение
            Heap <int>  heap       = new Heap <int>(arr, myComparer);

            heap.HeapSort();

            for (int i = 0; i < heap._array.Length; i++)
            {
                Console.Write(heap._array[i] + " ");
            }

            Console.ReadKey();
        }
예제 #12
0
        public static void ArraySorted([Random(0, 1000, 100, Distinct = true)] int n)
        {
            // Arrange
            var sorter      = new MiddlePointQuickSorter <int>();
            var intComparer = new IntComparer();

            var(correctArray, testArray) = RandomHelper.GetArrays(n);

            // Act
            sorter.Sort(testArray, intComparer);
            Array.Sort(correctArray, intComparer);

            // Assert
            Assert.AreEqual(testArray, correctArray);
        }
예제 #13
0
        public static void ArraySorted_WithCustomShrinkFactor([Random(0, 1000, 100, Distinct = true)] int n)
        {
            // Arrange
            var sorter      = new CombSorter <int>(1.5);
            var intComparer = new IntComparer();

            var(correctArray, testArray) = RandomHelper.GetArrays(n);

            // Act
            sorter.Sort(testArray, intComparer);
            Array.Sort(correctArray, intComparer);

            // Assert
            Assert.AreEqual(testArray, correctArray);
        }
예제 #14
0
        public void ArraySorted([Random(0, 1000, 100, Distinct = true)] int n)
        {
            // Arrange
            var sorter      = new BucketSort();
            var intComparer = new IntComparer();

            var(correctArray, testArray) = RandomHelper.GetArrays(n);

            // Act
            sorter.Sort(testArray, intComparer);
            Array.Sort(correctArray);

            // Assert
            Assert.AreEqual(correctArray, testArray);
        }
예제 #15
0
        public void TestMethod1()
        {
            int[] mass     = { 12, 55, 45, 78 };
            int[] massCurr = { 12, 45, 55, 78 };

            IntComparer myComparer = new IntComparer();
            Heap <int>  heap       = new Heap <int>(mass, myComparer);

            heap.HeapSort();

            int[] massEnd = heap._array;

            bool equal_Curr = massCurr.SequenceEqual(massEnd);

            Assert.AreEqual(true, equal_Curr);
        }
예제 #16
0
        public override bool Evaluate()
        {
            if (m_comparer == null)
            {
                if (_comparerType != null && _comparerType.IsValid)
                {
                    m_comparer = (IntComparer)System.Activator.CreateInstance(_comparerType.Type);
                }
                else
                {
                    throw new System.NullReferenceException("Null comparer");
                }
            }

            return(m_comparer.Compare(_providerA.GetValue(), _providerB.GetValue()));
        }
        public static void ArraySorted([Random(0, 1000, 100, Distinct = true)] int n)
        {
            // Arrange
            var sorter      = new ExternalMergeSorter <int>();
            var intComparer = new IntComparer();

            var(correctArray, testArray) = RandomHelper.GetArrays(n);
            var main = new IntInMemoryStorage(testArray);
            var temp = new IntInMemoryStorage(new int[testArray.Length]);

            // Act
            sorter.Sort(main, temp, intComparer);
            Array.Sort(correctArray, intComparer);

            // Assert
            Assert.AreEqual(testArray, correctArray);
        }
예제 #18
0
        public void TestIntComparer()
        {
            string propName = "IntProp";

            _boCol[0].SetPropertyValue(propName, 3);
            _boCol[1].SetPropertyValue(propName, 5);
            _boCol[2].SetPropertyValue(propName, 2);

            IntComparer <MultiPropBO> comparer = new IntComparer <MultiPropBO>(propName);

            _boCol.Sort(comparer);

            Assert.IsNull(_boCol[0].GetPropertyValue(propName));
            Assert.AreEqual(2, _boCol[1].GetPropertyValue(propName));
            Assert.AreEqual(3, _boCol[2].GetPropertyValue(propName));
            Assert.AreEqual(5, _boCol[3].GetPropertyValue(propName));
        }
예제 #19
0
        public void TestCTors()
        {
            var       cmp   = new IntComparer();
            const int limit = 5;

            Assert.AreEqual(LurchTableOrder.None, new LurchTable <int, int>(1).Ordering);
            Assert.AreEqual(LurchTableOrder.Insertion, new LurchTable <int, int>(1, LurchTableOrder.Insertion).Ordering);
            Assert.IsTrue(ReferenceEquals(cmp, new LurchTable <int, int>(1, LurchTableOrder.Insertion, cmp).Comparer));
            Assert.AreEqual(LurchTableOrder.Modified, new LurchTable <int, int>(LurchTableOrder.Modified, limit).Ordering);
            Assert.AreEqual(limit, new LurchTable <int, int>(LurchTableOrder.Modified, limit).Limit);
            Assert.AreEqual(LurchTableOrder.Access, new LurchTable <int, int>(LurchTableOrder.Access, limit, cmp).Ordering);
            Assert.AreEqual(limit, new LurchTable <int, int>(LurchTableOrder.Access, limit, cmp).Limit);
            Assert.IsTrue(ReferenceEquals(cmp, new LurchTable <int, int>(LurchTableOrder.Access, limit, cmp).Comparer));
            Assert.AreEqual(LurchTableOrder.Access, new LurchTable <int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Ordering);
            Assert.AreEqual(limit, new LurchTable <int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Limit);
            Assert.IsTrue(ReferenceEquals(cmp, new LurchTable <int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Comparer));
        }
예제 #20
0
    public string LargestNumber(int[] nums)
    {
        /*This is a sorting problem
         * where we compare the individual items and then sort them
         * instead here we sort based on composite of "item1" + "item2" > "item2" + "item1"
         *
         * In object oriented supported languages we can use Comparator to do this.
         */

        var comparer = new IntComparer();

        Array.Sort(nums, comparer);
        if (nums[0] == 0)
        {
            return("0");
        }
        return(string.Join("", nums));
    }
예제 #21
0
        public void ArraySorted([Random(0, 1000, 1000)] int n)
        {
            var testArray    = new int[n];
            var correctArray = new int[n];

            for (var i = 0; i < n; i++)
            {
                var t = random.Next(0, 1000);
                testArray[i]    = t;
                correctArray[i] = t;
            }

            var intComparer = new IntComparer();

            sorter.Sort(testArray, intComparer);
            Array.Sort(correctArray, intComparer);

            Assert.AreEqual(testArray, correctArray);
        }
예제 #22
0
    static void Main()
    {
        //Console.SetIn(new StreamReader(File.OpenRead("307_Div2_ProbA.txt")));
        int n = int.Parse(Console.ReadLine());

        int [] arr   = new int[n + 1];
        int [] pos   = new int[n + 1];
        int [] rank  = new int[n + 1];
        var    input = Console.ReadLine().Split(new char[] { ' ' });
        int    i;

        for (i = 1; i <= n; i++)
        {
            arr[i] = int.Parse(input[i - 1]);
            pos[i] = i;
        }
        var comparer = new IntComparer();

        Array.Sort(arr, pos, 1, n, comparer);
        // for (i = 1; i <= n; i++) {
        //  Console.WriteLine(arr[i] + " " + pos[i]);
        // }

        for (i = 1; i <= n; i++)
        {
            if (arr[i] != arr[i - 1])
            {
                rank[pos[i]] = i;
            }
            else
            {
                rank[pos[i]] = rank[pos[i - 1]];
            }
        }

        for (i = 1; i <= n; i++)
        {
            Console.Write(rank[i] + " ");
        }
    }
예제 #23
0
        public void ArraySorted([Random(0, 1000, 1000)] int n)
        {
            // Arrange
            var sorter       = new BinaryInsertionSorter <int>();
            var intComparer  = new IntComparer();
            var random       = new Random();
            var testArray    = new int[n];
            var correctArray = new int[n];

            for (var i = 0; i < n; i++)
            {
                var t = random.Next(0, 1000);
                testArray[i]    = t;
                correctArray[i] = t;
            }

            // Act
            sorter.Sort(testArray, intComparer);
            Array.Sort(correctArray, intComparer);

            // Assert
            Assert.AreEqual(testArray, correctArray);
        }
 static ChartCommon()
 {
     DefaultIntComparer           = new IntComparer();
     DefaultDoubleComparer        = new DoubleComparer();
     DefaultDoubleVector3Comparer = new DoubleVector3Comparer();
 }
예제 #25
0
    public void M()
    {
        // Operators
        var i = 42;

        if (i == 32)
        {
            ;
        }
        if (i != 32)
        {
            ;
        }
        if (i > 32)
        {
            ;
        }
        if (i < 32)
        {
            ;
        }
        if (i >= 32)
        {
            ;
        }
        if (i <= 32)
        {
            ;
        }

        // Qualified method calls
        var o = (object)i;
        var s = "abc";

        this.Equals(32); // Equals
        if (o.Equals(32))
        {
            ;               // Equals
        }
        if (s.Equals("32"))
        {
            ;                 // IEquatable<T>.Equals
        }
        // Unqualified method calls
        Equals(32);
        Equals(o, 32);
        object.Equals(0, 32);
        ReferenceEquals(0, 32);
        object.ReferenceEquals(0, 32);

        // User-defined operators
        C c1 = null, c2 = null;

        if (c1 == c2)
        {
            ;
        }
        if (c1 != c2)
        {
            ;
        }
        if (c1 > c2)
        {
            ;
        }
        if (c1 < c2)
        {
            ;
        }
        if (c1 >= c2)
        {
            ;
        }
        if (c1 <= c2)
        {
            ;
        }

        // IComparer.Compare
        var comparer = new Comparer();

        comparer.Compare(i, "32");

        // IComparer<T>.Compare
        var intComparer = new IntComparer();

        intComparer.Compare(i, 32);

        // IComparable.Compare
        c1.CompareTo("c2");

        // IComparable<T>.Compare
        c1.CompareTo(c2);
    }
예제 #26
0
        /// <summary>
        /// Asserts that the Sub-set schema is contained within the Super-set schema
        /// </summary>
        public static void AssertContained(ILogger logger, string superSetConnectionString, string subSetConnectionString, bool compareIndexes, params string[] ignoreTables)
        {
            var mismatchLogger = new MismatchLogger(logger);

            var superSet            = GetDatabase(superSetConnectionString);
            var subSet              = GetDatabase(subSetConnectionString);
            var boolComparer        = new BoolComparer();
            var intComparer         = new IntComparer();
            var stringComparer      = StringComparer.InvariantCulture;
            var sqlDataTypeComparer = new SqlDataTypeComparer();

            foreach (var subSetTable in subSet.Tables.Cast <Table>())
            {
                if (ignoreTables.Contains(subSetTable.Name))
                {
                    mismatchLogger.LogInfo("Ignoring table '{0}'", subSetTable.Name);

                    continue;
                }

                if (!superSet.Tables.Contains(subSetTable.Name))
                {
                    mismatchLogger.LogWarning("Table '{0}' does not exist in '{1}'", subSetTable.Name, superSet.Name);

                    continue;
                }

                mismatchLogger.LogInfo("Comparing table '{0}'", subSetTable.Name);

                var superSetTable   = superSet.Tables[subSetTable.Name];
                var superSetColumns = superSetTable.Columns.Cast <Column>().Where(c => !c.Name.EndsWith("NullBuster")).ToDictionary(c => c.Name);
                var subSetColumns   = subSetTable.Columns.Cast <Column>().ToDictionary(c => c.Name);

                if (subSetColumns.Count != superSetColumns.Count)
                {
                    mismatchLogger.LogWarning(
                        "Table '{0}' in '{1}' has '{2}' columns compared to '{3}' in '{4}'",
                        subSetTable.Name,
                        subSet.Name,
                        subSetTable.Columns.Count,
                        superSetColumns.Count,
                        superSet.Name);
                }

                foreach (var superSetColumn in superSetColumns)
                {
                    if (!subSetColumns.ContainsKey(superSetColumn.Key))
                    {
                        mismatchLogger.LogWarning("Column '{0}' does not exist in '{1}' in '{2}'", superSetColumn.Key, subSetTable.Name, subSet.Name);
                    }
                }

                foreach (var subSetColumn in subSetColumns)
                {
                    if (!superSetColumns.ContainsKey(subSetColumn.Key))
                    {
                        mismatchLogger.LogWarning("Column '{0}' does not exist in '{1}' in '{2}'", subSetColumn.Key, superSetTable.Name, superSet.Name);

                        continue;
                    }

                    var superSetColumn = superSetColumns[subSetColumn.Key];

                    Compare(mismatchLogger, subSetTable, subSetColumn.Value, superSetColumn, c => c.DataType.SqlDataType, sqlDataTypeComparer);
                    Compare(mismatchLogger, subSetTable, subSetColumn.Value, superSetColumn, c => c.DataType.MaximumLength, intComparer);
                    Compare(mismatchLogger, subSetTable, subSetColumn.Value, superSetColumn, c => c.DataType.NumericPrecision, intComparer);
                    Compare(mismatchLogger, subSetTable, subSetColumn.Value, superSetColumn, c => c.DataType.NumericScale, intComparer);
                    Compare(mismatchLogger, subSetTable, subSetColumn.Value, superSetColumn, c => c.Nullable, boolComparer);
                    Compare(mismatchLogger, subSetTable, subSetColumn.Value, superSetColumn, c => c.Default, stringComparer);
                    Compare(mismatchLogger, subSetTable, subSetColumn.Value, superSetColumn, c => c.Identity, boolComparer);
                    Compare(mismatchLogger, subSetTable, subSetColumn.Value, superSetColumn, c => c.InPrimaryKey, boolComparer);
                }

                if (compareIndexes)
                {
                    var superSetUniqueIndexes = superSetTable.Indexes.Cast <Index>().Where(c => c.IsUnique).ToList();
                    var subSetUniqueIndexes   = subSetTable.Indexes.Cast <Index>().Where(c => c.IsUnique).ToList();

                    if (subSetUniqueIndexes.Count != superSetUniqueIndexes.Count)
                    {
                        mismatchLogger.LogWarning(
                            "Table '{0}' in '{1}' has '{2}' unique indexes compared to '{3}' in '{4}'",
                            subSetTable.Name,
                            subSet.Name,
                            subSetUniqueIndexes.Count,
                            superSetUniqueIndexes.Count,
                            superSet.Name);
                    }

                    // Primary Keys and Unique Keys can have different names, so can't check for equality

                    foreach (var subSetUniqueIndex in subSetUniqueIndexes)
                    {
                        var subSetIndexColumns = new HashSet <string>(subSetUniqueIndex.IndexedColumns.Cast <IndexedColumn>().Select(c => c.Name));
                        var found = false;

                        foreach (var superSetUniqueIndex in superSetUniqueIndexes)
                        {
                            var superSetIndexColumns = new HashSet <string>(superSetUniqueIndex.IndexedColumns.Cast <IndexedColumn>().Select(c => c.Name));

                            if (superSetIndexColumns.SetEquals(subSetIndexColumns))
                            {
                                found = true;
                                break;
                            }
                        }

                        if (!found)
                        {
                            mismatchLogger.LogWarning("Table '{0}' in '{1}' has unexpected unique index over columns '{2}'", subSetTable.Name, subSet.Name, string.Join(",", subSetIndexColumns));
                        }
                    }
                }

                // TODO: Check FK (keys can have different names)
            }

            if (mismatchLogger.Errors || mismatchLogger.Warnings)
            {
                Assert.Fail("Schema comparison failed - see ILog output for details");
            }
        }
예제 #27
0
    IEnumerator Sort()
    {
        SortClass <int>     sortclass  = new SortClass <int>();
        IntComparer         com        = new IntComparer();
        int                 n          = 0;
        SortParameter <int> sort_param = null;

        switch (sort_type)
        {
        case SortType.Buble:
        {
            sort_param = new BubleSortParameter <int>(
                com,
                () => { },
                (state, sorting_items, item_states) =>
                {
                    ++n;
                    if (dstint_text)
                    {
                        DistSortArray(state, sorting_items, item_states);
                    }
                }
                );
        }
        break;

        case SortType.Quick:
        case SortType.RandomQuick:
        {
            sort_param = new QuickSortParameter <int>(
                com,
                () => { },
                (state, sorting_items, item_states) =>
                {
                    ++n;
                    if (dstint_text)
                    {
                        DistSortArray(state, sorting_items, item_states);
                    }
                }
                );
        }
        break;

        case SortType.Bitonic_NotUseGPGPUDemo:
        {
            sort_param = new BytonicSortParameter <int>(
                com,
                () => { },
                (state, sorting_items, item_states) =>
                {
                    ++n;
                    if (dstint_text)
                    {
                        DistSortArray(state, sorting_items, item_states);
                    }
                }
                );
        }
        break;
        }
        yield return(sortclass.SortUseIEnumerator(
                         items,
                         sort_param,
                         new WaitForSeconds(wait),
                         sort_type
                         ));

        Debug.Log("操作回数:" + n + "回");
    }
예제 #28
0
        private void FormatTextToPrint()
        {
            TextBox             txt  = null;
            CheckBox            chk  = null;
            ComboBox            cbo  = null;
            List <ControlValue> ctls = new List <ControlValue>();
            int maxlenDescription    = 0;

            foreach (Control ctl in this.Controls)
            {
                if (ctl is TextBox)
                {
                    txt = (TextBox)ctl;
                    ControlValue val = new ControlValue();
                    val.TabIndex    = txt.TabIndex;
                    val.Value       = txt.Text;
                    val.Description = "Field" + val.TabIndex.ToString();
                    Label lbl = this.Controls.Find("lbl" + txt.Name.Replace("txt", ""), true).FirstOrDefault() as Label;
                    if (lbl != null)
                    {
                        val.Description = lbl.Text;
                    }
                    else
                    {
                        val.Description = txt.Tag != null?txt.Tag.ToString() : val.Description;
                    }
                    ctls.Add(val);
                }
                if (ctl is ComboBox)
                {
                    cbo = (ComboBox)ctl;
                    ControlValue val = new ControlValue();
                    val.TabIndex    = cbo.TabIndex;
                    val.Value       = cbo.Text;
                    val.Description = "Field" + val.TabIndex.ToString();
                    Label lbl = this.Controls.Find("lbl" + cbo.Name.Replace("cbo", ""), true).FirstOrDefault() as Label;
                    if (lbl != null)
                    {
                        val.Description = lbl.Text;
                    }
                    else
                    {
                        val.Description = cbo.Tag != null?txt.Tag.ToString() : val.Description;
                    }
                    ctls.Add(val);
                }
                if (ctl is CheckBox)
                {
                    chk = (CheckBox)ctl;
                    ControlValue val = new ControlValue();
                    val.Value       = chk.Checked.ToString();
                    val.Description = chk.Text;
                    val.TabIndex    = chk.TabIndex;
                    ctls.Add(val);
                }
            }//end foreach

            foreach (ControlValue cv in ctls)
            {
                if (cv.Description.Length > maxlenDescription)
                {
                    maxlenDescription = cv.Description.Length;
                }
            }

            IntComparer ic = new IntComparer();

            ctls.Sort(ic);

            _textToPrint.Length = 0;
            foreach (ControlValue cv in ctls)
            {
                string desc = cv.Description + new String(' ', maxlenDescription);
                desc = desc.Substring(0, maxlenDescription) + " ";
                _textToPrint.Append(desc);
                _textToPrint.Append(cv.Value);
                _textToPrint.Append(Environment.NewLine);
            }
        }//end method
예제 #29
0
 public TestLurchTable()
 {
     Comparer = new IntComparer();
 }
예제 #30
0
 static ChartCommon()
 {
     DefaultIntComparer = new IntComparer();
 }
예제 #31
0
        public void TestIntComparer()
        {
            string propName = "IntProp";
            _boCol[0].SetPropertyValue(propName, 3);
            _boCol[1].SetPropertyValue(propName, 5);
            _boCol[2].SetPropertyValue(propName, 2);

            IntComparer<MultiPropBO> comparer = new IntComparer<MultiPropBO>(propName);
            _boCol.Sort(comparer);

            Assert.IsNull(_boCol[0].GetPropertyValue(propName));
            Assert.AreEqual(2, _boCol[1].GetPropertyValue(propName));
            Assert.AreEqual(3, _boCol[2].GetPropertyValue(propName));
            Assert.AreEqual(5, _boCol[3].GetPropertyValue(propName));
        }