📄 multidimensionalarray.cs
字号:
namespace Opus6
{
using System;
using System.Reflection;
[Copyright("Copyright (c) 2001 by Bruno R. Preiss, P.Eng."), Version("$Id: MultiDimensionalArray.cs,v 1.4 2001/10/28 19:50:09 brpreiss Exp $")]
public class MultiDimensionalArray
{
public MultiDimensionalArray(params int[] args)
{
this.dimensions = new int[args.Length];
this.factors = new int[args.Length];
int num1 = 1;
for (int num2 = args.Length - 1; num2 >= 0; num2--)
{
this.dimensions[num2] = args[num2];
this.factors[num2] = num1;
num1 *= this.dimensions[num2];
}
this.data = new object[num1];
}
private int GetOffset(int[] indices)
{
if (indices.Length != this.dimensions.Length)
{
throw new IndexOutOfRangeException();
}
int num1 = 0;
for (int num2 = 0; num2 < this.dimensions.Length; num2++)
{
if ((indices[num2] < 0) || (indices[num2] >= this.dimensions[num2]))
{
throw new IndexOutOfRangeException();
}
num1 += this.factors[num2] * indices[num2];
}
return num1;
}
public object this[int[] indices]
{
get
{
return this.data[this.GetOffset(indices)];
}
// [param: ParamArray]
set
{
this.data[this.GetOffset(indices)] = value;
}
}
private object[] data;
private int[] dimensions;
private int[] factors;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -