• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# MultiDimensionalArray类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Bind3DArrayUsing2DView

        public void Bind3DArrayUsing2DView()
        {
            IMultiDimensionalArray array = new MultiDimensionalArray(3, 3, 3);
            array[0, 0, 0] = 1;
            array[1, 1, 1] = 2;

            IMultiDimensionalArrayView view = array.Select(0, 0, 0);
            view.Reduce[0] = true; // reduce 1st dimension

            DataGridView gridView = new DataGridView();

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

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


示例17: ChangeSizeOfFirstDimension

        public void ChangeSizeOfFirstDimension()
        {
            IMultiDimensionalArray array = new MultiDimensionalArray();

            array.Resize(1, 2);

            array[0, 0] = 1; // 0 + 0
            array[0, 1] = 2; // 0 + 1
            // 2   1 <= 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[0, 1]);
            Assert.IsNull(array[1, 0]);
            Assert.IsNull(array[1, 1]);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:24,代码来源:MultiDimensionalArrayTest.cs


示例18: Clone

        public void Clone()
        {
            IMultiDimensionalArray<double> array = new MultiDimensionalArray<double>(3);
            array[0] = 1;
            array[1] = 2;
            array[2] = 3;

            var view = array.Select(0, 1, 1);

            var clonedView = (IMultiDimensionalArrayView)view.Clone();

            Assert.IsTrue(view.OffsetStart.SequenceEqual(clonedView.OffsetStart));
            Assert.IsTrue(view.OffsetEnd.SequenceEqual(clonedView.OffsetEnd));
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:14,代码来源:MultiDimensionalArrayViewTest.cs


示例19: RemoveRow

        public void RemoveRow()
        {
            int[] lengths = new[] { 2, 3 };
            IMultiDimensionalArray array = new MultiDimensionalArray(lengths);

            array[0, 0] = 1;
            array[0, 1] = 2;
            array[0, 2] = 3;

            array[1, 0] = 4;
            array[1, 1] = 5;
            array[1, 2] = 6;

            IMultiDimensionalArrayBindingList bindingList = new MultiDimensionalArrayBindingList(array);
            bindingList.RemoveAt(1);

            int expectedRowsCount = 2;
            Assert.AreEqual(expectedRowsCount, array.Shape[bindingList.RowDimension]);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:19,代码来源:MultiDimensionalArrayBindingListTest.cs


示例20: SelectOnMultipleIndexes

        public void SelectOnMultipleIndexes()
        {
            // more complex example (isn't it another test?)
            var array = new MultiDimensionalArray(3, 3);
            // 1 9 2     1   2
            // 9 9 9 ==> 
            // 3 9 4     3   4   
            array[0, 0] = 1;
            array[0, 1] = 9;
            array[0, 2] = 2;
            array[1, 0] = 9;
            array[1, 1] = 9;
            array[1, 2] = 9;
            array[2, 0] = 3;
            array[2, 1] = 9;
            array[2, 2] = 4;

            IMultiDimensionalArrayView view = array.Select(0, new[] {0, 2}).Select(1, new[] {0, 2});
            Assert.IsTrue(new[] {2, 2}.SequenceEqual(view.Shape));
            Assert.AreEqual(4, view.Count);
            Assert.AreEqual(1, view[0, 0]);
            Assert.AreEqual(2, view[0, 1]);
            Assert.AreEqual(3, view[1, 0]);
            Assert.AreEqual(4, view[1, 1]);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:25,代码来源:MultiDimensionalArrayViewTest.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MultiEdgeId类代码示例发布时间:2022-05-24
下一篇:
C# MultiDictionary类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap