Make 3D builtin array take Vector3 as index

Is there any way to make a 3D builtin array take Vector3’s as its index?

Example:

var array3D : int[16, 16, 16]; // = something
var vector3D : Vector3; // = something

Debug.Log(array3D[vector3D.x, vector3D.y, vector3d.z]);
// The above works, but it's really ugly

Debug.Log(array3D[vector3D]);
// This would be really awesome

Basically I want to do this so I can have

some_array[a - b + c]

instead of

some_array[a.x - b.x + c.x, a.y - b.y + c.y, a.z - b.z + c.z]

(I’m using Javascript.)

Yeah, I know I could just calculate the final Vector3 beforehand, but that just seems like it would make it messier.

Thanks in advance for any tips!

You can build a custom indexer. Untested C# code. But the principle should work the same in JavaScript.

public struct MyArray {
    private [,,] myArray = new int[16,16,16];

    public int this[Vector3 i]{
        get {
            return myArray [i.x,i.y,i.z];
        }
        set {
            myArray [i.x,i.y,i.z] = value;
        }
    }
}