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


C# MultiDimensionalArray.Select方法代码示例

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


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

示例1: 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

示例2: 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

示例3: MoveDimensionAtGivenIndexAndLength

        public void MoveDimensionAtGivenIndexAndLength()
        {
            var values = new List<int> { 1, 2, 3, 4 };
            IMultiDimensionalArray<int> array = new MultiDimensionalArray<int>(values, new[] { 1, 4 });

            var view = array.Select(1, 2, 3); // select { 1, 2, [3, 4] }

            // move 2nd dimension index
            var dimension = 1;
            var startIndex = 1;
            var length = 2;
            var newIndex = 0;
            array.Move(dimension, startIndex, length, newIndex); // 1, 2, 3, 4  => 2, 3, 1, 4

            //  2, 3, [1, 4]
            Assert.IsTrue(view.SequenceEqual(new[] { 1, 4 }));
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:17,代码来源:MultiDimensionalArrayViewTest.cs

示例4: UseEnumeratorOnMultiDimensionalArrayView

        public void UseEnumeratorOnMultiDimensionalArrayView()
        {
            // Setup an array
            // 1 2 -
            // 3 4 - 
            // - - - 
            IMultiDimensionalArray<double> array = new MultiDimensionalArray<double>(3, 3);
            array[0, 0] = 1;
            array[0, 1] = 2;
            array[1, 0] = 3;
            array[1, 1] = 4;

            // make a selection of the top right corner
            IMultiDimensionalArray<double> view = array.Select(0, 0, 1).Select(1, 0, 1);
            Assert.IsTrue(new[] {2, 2}.SequenceEqual(view.Shape));

            // since array supports enumerator - we can enumerate throuth all values as 1D array
            Assert.IsTrue(new double[] {1, 2, 3, 4}.SequenceEqual(view));
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:19,代码来源:MultiDimensionalArrayViewTest.cs

示例5: SelectUsingIndexes

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

            IMultiDimensionalArrayView view = array.Select(0, new[] {0, 2});

            // Select first and last element
            Assert.AreEqual(2, view.Count);
            Assert.AreEqual(1, view[0]);
            Assert.AreEqual(3, view[1]);

            Assert.AreEqual(3,view.MaxValue);
            Assert.AreEqual(1,view.MinValue);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:17,代码来源:MultiDimensionalArrayViewTest.cs

示例6: 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

示例7: SelectARow

        public void SelectARow()
        {
            var array = new MultiDimensionalArray(2, 3);
            // 1 2 3     1 2 3
            // 4 5 6 ==> 
            
            array[0, 0] = 1;
            array[0, 1] = 2;
            array[0, 2] = 3;
            array[1, 0] = 4;
            array[1, 1] = 5;
            array[1, 2] = 6;
            // select the first index of the first dimension (e.g. the row)
            var row =  array.Select(0,new[]{0});
            row.Reduce[0] = true;
            Assert.AreEqual(new[]{1,2,3},row);

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

示例8: InsertAt

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

            var view = array.Select(0, new[] {0, 2, 4});
            view.InsertAt(0, 3); //insert at end
            Assert.AreEqual(7, array.Count);
            Assert.AreEqual(new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 6.0}, array); //Ambiguous!
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:15,代码来源:MultiDimensionalArrayViewTest.cs

示例9: ResizeParentAndUpdateShapeOfSubArray

        public void ResizeParentAndUpdateShapeOfSubArray()
        {
            //create a 2D grid of 3x3
            IMultiDimensionalArray array = new MultiDimensionalArray(3, 3);

            //select rows [1, 2). So skip the first row
            IMultiDimensionalArray subArray = array.Select(0, 1, int.MaxValue);
            Assert.IsTrue(subArray.Shape.SequenceEqual(new[] {2, 3}));

            //resize the parent. Add one row and one column. Check the shape of the subArray changes
            array.Resize(new[] {4, 4});
            Assert.IsTrue(subArray.Shape.SequenceEqual(new[] {3, 4}));
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:13,代码来源:MultiDimensionalArrayViewTest.cs

示例10: ReduceOnWrongDimensionThrowsAnException

 public void ReduceOnWrongDimensionThrowsAnException()
 {
     var array = new MultiDimensionalArray(3, 3);
     var subArray = array.Select(0, 0, 1);
     subArray.Reduce[0] = true; //try to reduce the first dimension
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:6,代码来源:MultiDimensionalArrayViewTest.cs

示例11: ReduceArray

 public void ReduceArray()
 {
     // create a 2D grid and slice rows and columns
     // 1 2 3
     // 4 5 6
     // 7 8 9
     IMultiDimensionalArray array = new MultiDimensionalArray(3, 3);
     array[0, 0] = 1;
     array[0, 1] = 2;
     array[0, 2] = 3;
     array[1, 0] = 4;
     array[1, 1] = 5;
     array[1, 2] = 6;
     array[2, 0] = 7;
     array[2, 1] = 8;
     array[2, 2] = 9;
     //create a reduced array containing the first row
     var view = array.Select(0, 0, 0);
     view.Reduce[0] = true; //reduce the x dimension
     Assert.AreEqual(1, view.Rank);
     Assert.AreEqual(new[] {3}, view.Shape);
     Assert.AreEqual(2, view[1]);
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:23,代码来源:MultiDimensionalArrayViewTest.cs

示例12: OutOfRangeForChildArray

        public void OutOfRangeForChildArray()
        {
            ///create a 2D grid and slice rows and columns
            /// 1 2
            /// 3 4
            IMultiDimensionalArray array = new MultiDimensionalArray(2, 2);
            array[0, 0] = 1;
            array[0, 1] = 2;
            array[1, 0] = 4;
            array[1, 1] = 5;

            //create a subarray of the top left corner
            // 1 |2|
            // 4 |5|
            //
            IMultiDimensionalArray subArray = array.Select(1, 1, 1);

            subArray[1, 1] = 5; // <= exception
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:19,代码来源:MultiDimensionalArrayViewTest.cs

示例13: IndexOf

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

            var view = array.Select(0, new[] { 1 });
            Assert.AreEqual(0, view.IndexOf(2));
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:10,代码来源:MultiDimensionalArrayViewTest.cs

示例14: GenericFiltered

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

            var view = array.Select(0, new[] {1});
            Assert.AreEqual(2, view[0]);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:10,代码来源:MultiDimensionalArrayViewTest.cs

示例15: ReducedIndexing

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

            var view = array.Select(0, int.MinValue, int.MaxValue);
            view.SelectedIndexes[0] = new int[] { 0 };
            view.SelectedIndexes[1] = new int[] { 1 };
            view.Reduce[0] = true; //reduce the x dimension
            //one element
            Assert.AreEqual(1, view.Count);
            //rank and shape are one
            Assert.AreEqual(1, view.Rank);
            Assert.AreEqual(new[] { 1 }, view.Shape);

            //get the value
            Assert.AreEqual(2, view[0]);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:20,代码来源:MultiDimensionalArrayViewTest.cs


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