1
0

break,continue実装,var,dim実装中

This commit is contained in:
otya128
2015-06-10 19:09:15 +09:00
parent 2e9e966f0b
commit 7c383dff1a
6 changed files with 180 additions and 14 deletions

View File

@@ -18,7 +18,7 @@ struct Value
int integerValue;
double doubleValue;
wstring stringValue;
int[] intArray;
Array!int intArray;
}
this(int value)
{
@@ -70,3 +70,47 @@ struct Value
}
}
}
class Array(T)
{
T[] array;
//最大要素数2^^31
//4次元配列
int[4] dim;
int dimCount;
this(int len)
{
dim[0] = len;
dim[1] = 0;
dim[2] = 0;
dim[3] = 0;
array = new T[len];
dimCount = 1;
}
this(int[] dim)
{
int len = 1;
foreach(int i; dim)
{
len *= i;
}
array = new T[len];
dimCount = dim.length;
}
T opIndex(int i1)
{
return array[i1];
}
T opIndex(int i1, int i2)
{
return array[i1 * dim[0] + i2];
}
T opIndex(int i1, int i2, int i3)
{
return array[i1 * dim[0] * dim[1] + i2 * dim[1] + i3];
}
T opIndex(int i1, int i2, int i3, int i4)
{
return array[i1];//array[i1 * dim[0] * dim[1] * dim[2] + i2 * dim[1] + i3];
}
}