-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathFixedArray.cs
More file actions
53 lines (41 loc) · 841 Bytes
/
FixedArray.cs
File metadata and controls
53 lines (41 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/*
public class Vector2x4 : FixedArray<Vector2,of4>
{
};
*/
public interface SizePolicy
{
int Size{ get;}
}
public class of4 : SizePolicy
{
public int Size{ get { return 4;}}
}
// gr: cannot serialise a template!
[System.Serializable]
public class FixedArray<Type,SizePolicyType> where SizePolicyType : SizePolicy, new()
{
public Type this [int Index] {
get {
return Elements [Index];
}
set {
Elements [Index] = value;
}
}
public int Length { get { return Size.Size; } }
public int Count { get { return Size.Size; } }
SizePolicyType Size = new SizePolicyType();
//[System.Serializable]
Type[] _Elements;
Type[] Elements {
get {
if (_Elements == null)
_Elements = new Type[Length];
return _Elements;
}
}
};