当前位置: 首页>>代码示例>>C#>>正文


C# MultiDimensionalArray类代码示例

本文整理汇总了C#中MultiDimensionalArray的典型用法代码示例。如果您正苦于以下问题:C# MultiDimensionalArray类的具体用法?C# MultiDimensionalArray怎么用?C# MultiDimensionalArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MultiDimensionalArray类属于命名空间,在下文中一共展示了MultiDimensionalArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestNotifyCollectionChanged

        public void TestNotifyCollectionChanged()
        {
            var sourceArray = new MultiDimensionalArray<int>(2, 2);
            IMultiDimensionalArray<int> array = 
                new LazyMultiDimensionalArray<int>(()=>
                                                   sourceArray,()=>sourceArray.Count);

            bool called = false;
            EventHandler<MultiDimensionalArrayChangingEventArgs> arrayOnCollectionChanged = delegate { called = true; };
            array.CollectionChanged += arrayOnCollectionChanged;
            array[0, 0] = 0;
            array[0, 1] = 1;
            array[1, 0] = 2;
            array[1, 1] = 3;
            //called when values added
            Assert.IsTrue(called);

            //called when we replace a value
            called = false;
            array[0, 0] = 5;
            Assert.IsTrue(called);            

            //unsubscribe
            called = false;
            array.CollectionChanged -= arrayOnCollectionChanged;
            array[0, 0] = 3;
            Assert.IsFalse(called);            

        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:29,代码来源:LazyMultiDimensionalArrayTest.cs

示例2: ChangeSizeOfLastDimension

        public void ChangeSizeOfLastDimension()
        {
            //we don't use interface because want to check stride
            var array = new MultiDimensionalArray();

            array.Resize(2, 1);

            array[0, 0] = 1; // 0 + 0
            array[1, 0] = 2; // 2 + 0

            // 1   1 <= stride
            Assert.AreEqual(new[] { 1, 1 }, array.Stride);

            log.InfoFormat("Before resize: {0}", array.ToString());

            array.Resize(new[] { 2, 2 });

            log.InfoFormat("After resize: {0}", array.ToString());

            Assert.AreEqual(2, array.Rank);
            Assert.AreEqual(4, array.Count);

            Assert.AreEqual(1, array[0, 0]);
            Assert.AreEqual(2, array[1, 0]);
            Assert.IsNull(array[0, 1]);
            Assert.IsNull(array[1, 1]);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:27,代码来源:MultiDimensionalArrayTest.cs

示例3: ToString

 public void ToString()
 {
     var source = new MultiDimensionalArray<int>(new List<int> { 1, 2, 3, 4, 5, 6 }, new[] { 2, 3 });
     var target = new ConvertedArray<string, int>(source, Convert.ToInt32, Convert.ToString);
     
     Assert.AreEqual("{{1, 2, 3}, {4, 5, 6}}", target.ToString());
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:7,代码来源:ConvertedArrayTest.cs

示例4: Count

 public void Count()
 {
     //array = 1,2,3,4,5
     IMultiDimensionalArray<int> array = new MultiDimensionalArray<int> {1, 2, 3, 4, 5};
     //view  = 2,3
     IMultiDimensionalArrayView<int> view = new MultiDimensionalArrayView<int>(array, 0, 1, 2);
     Assert.AreEqual(2, view.Count);
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:8,代码来源:MultiDimensionalArrayViewTest.cs

示例5: EnumerateEmptyArray

 public void EnumerateEmptyArray()
 {
     IMultiDimensionalArray<int> array = new MultiDimensionalArray<int>();
     foreach (int o in array)
     {
         Assert.Fail("No objects in the array. Should not come here");
     }
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:8,代码来源:MultiDimensionalArrayEnumeratorTest.cs

示例6: Add

 public void Add()
 {
     IMultiDimensionalArray<int> array = new MultiDimensionalArray<int>();
     IMultiDimensionalArrayView view = new MultiDimensionalArrayView(array, 0, int.MinValue, int.MaxValue);
     view.Add(4);
     Assert.AreEqual(1, view.Count);
     Assert.AreEqual(1, array.Count);
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:8,代码来源:MultiDimensionalArrayViewTest.cs

示例7: ClearView

 public void ClearView()
 {
     IMultiDimensionalArray<int> array = new MultiDimensionalArray<int> {1, 2, 3, 4, 5};
     IMultiDimensionalArrayView view = new MultiDimensionalArrayView(array, 0, 1, 2);
     view.Clear();
     Assert.AreEqual(0, view.Count);
     Assert.AreEqual(3, array.Count);
     Assert.IsTrue(new[] {1, 4, 5}.SequenceEqual(array));
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:9,代码来源:MultiDimensionalArrayViewTest.cs

示例8: TestGetInsertionIndex

 public void TestGetInsertionIndex()
 {
     IMultiDimensionalArray<int> ints = new MultiDimensionalArray<int>{1, 2, 40, 50};
     Assert.AreEqual(2, MultiDimensionalArrayHelper.GetInsertionIndex(3, ints));
     Assert.AreEqual(0, MultiDimensionalArrayHelper.GetInsertionIndex(0, ints));
     Assert.AreEqual(4, MultiDimensionalArrayHelper.GetInsertionIndex(60, ints));
     Assert.AreEqual(1, MultiDimensionalArrayHelper.GetInsertionIndex(2, ints));
     Assert.AreEqual(0, MultiDimensionalArrayHelper.GetInsertionIndex(2, new MultiDimensionalArray<int>()));
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:9,代码来源:MultiDimensionalArrayHelperTest.cs

示例9: ConvertToListUsingCopyConstructor

 public void ConvertToListUsingCopyConstructor()
 {
     MultiDimensionalArray array = new MultiDimensionalArray<double>(2);
     IMultiDimensionalArray<double> view = new MultiDimensionalArrayView<double>(array);
     view[0] = 10;
     view[1] = 5;
     var arrayList = new ArrayList(view);
     Assert.AreEqual(10, arrayList[0]);
     Assert.AreEqual(5, arrayList[1]);
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:10,代码来源:MultiDimensionalArrayViewTest.cs

示例10: InBetweenTest

 public void InBetweenTest()
 {
     IMultiDimensionalArray<int> ints = new MultiDimensionalArray<int> { 1, 2, 40, 50 };
     int prev = ints[0];
     int next = ints[ints.Count - 1];
     Assert.IsTrue(Comparer.IsBetween(prev, 3, next));
     Assert.IsFalse(Comparer.IsBetween(prev, 0, next));
     Assert.IsFalse(Comparer.IsBetween(prev, 1, next));
     Assert.IsFalse(Comparer.IsBetween(prev, 50, next));
     Assert.IsTrue(Comparer.IsBetween(prev, 40, next));
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:11,代码来源:MultiDimensionalArrayHelperTest.cs

示例11: GetLastValueSmallerThan

        public void GetLastValueSmallerThan()
        {
            var array = new MultiDimensionalArray { 1.0, 2.0 };
            Assert.IsNull(FunctionHelper.GetLastValueSmallerThan(1.0, array));
            Assert.AreEqual(1.0, FunctionHelper.GetLastValueSmallerThan(1.5, array));
            Assert.AreEqual(2.0, FunctionHelper.GetLastValueSmallerThan(2.5, array));

            array = new MultiDimensionalArray { 1.0 };
            Assert.IsNull(FunctionHelper.GetLastValueSmallerThan(1.0, array));
            Assert.AreEqual(1.0, FunctionHelper.GetLastValueSmallerThan(55.0, array));

        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:12,代码来源:FunctionHelperTest.cs

示例12: ConvertToListUsingCopyConstructorGeneric

        public void ConvertToListUsingCopyConstructorGeneric()
        {
            IList<int> values = new List<int> {1, 2, 3, 4};

            MultiDimensionalArray array = new MultiDimensionalArray<int>(values, new[] {1, 4});

            IMultiDimensionalArray<int> view = new MultiDimensionalArrayView<int>(array);

            IList array1D = new List<int>(view);

            Assert.AreEqual(4, array1D.Count);
            Assert.AreEqual(4, array1D[3]);
            Assert.AreEqual(2, array1D[1]);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:14,代码来源:MultiDimensionalArrayViewTest.cs

示例13: EnumerateRowMajor

 public void EnumerateRowMajor()
 {
     IMultiDimensionalArray<int> array = new MultiDimensionalArray<int>(2, 2);
     array[0, 0] = 0;
     array[0, 1] = 1;
     array[1, 0] = 2;
     array[1, 1] = 3;
     //verify we traverse in row major order
     int i = 0;
     foreach (int j in array)
     {
         Assert.AreEqual(j, i++);
     }
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:14,代码来源:MultiDimensionalArrayEnumeratorTest.cs

示例14: TestConvertedArray

        public void TestConvertedArray()
        {

            IMultiDimensionalArray<int> intArray = new MultiDimensionalArray<int>(new List<int> { 1, 2, 3, 4, 5 }, new[] { 5 });
            IMultiDimensionalArray<string> stringArray = new ConvertedArray<string, int>(intArray, Convert.ToInt32, Convert.ToString);


            Assert.AreEqual(intArray.Shape, stringArray.Shape);


            Assert.AreEqual("1", stringArray[0]);
            //assignment on the converted array are passed to the source
            stringArray.Add("30");
            Assert.AreEqual(30, intArray[5]);
            intArray.Add(31);
            Assert.AreEqual("31", stringArray[6]);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:17,代码来源:ConvertedArrayTest.cs

示例15: Bind2D

        public void Bind2D()
        {
            IMultiDimensionalArray array = new MultiDimensionalArray();
            array.Resize(2, 2);
            array[0, 0] = 5;
            array[1, 1] = 2;

            DataGridView gridView = new DataGridView();

            MultiDimensionalArrayBindingList multiDimensionalArrayBindingList = new MultiDimensionalArrayBindingList(array);
            gridView.DataSource = multiDimensionalArrayBindingList;

            Form form = new Form();
            gridView.Dock = DockStyle.Fill;
            form.Controls.Add(gridView);
            
            WindowsFormsTestHelper.ShowModal(form);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:18,代码来源:MultiDimensionalArrayBindingListTest.cs


注:本文中的MultiDimensionalArray类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。