Method #2: Indexing
I implemented an index operator on the class which simply calls the index operator on the array.
public double this[int position]
{
get
{
return array_[position];
}
}
Method #3: Indirect Array
I created a property to access the array.
public double[] Array
{
get
{
return array_;
}
}
When iterating, I called the Array property and then its index operator.
d = data.Array[j];
Method #3: Direct Array
I created a reference to the array.
double[] array = data.Array;
Then, I iterate through that reference.
d = array[j];
Method #4: Pointer Math
Finally, I tried improving performance by iterating through the array in Managed C++ using pointer manipulation.
static void iterate( Data& data )
{
double d;
double __pin* ptr = &( data.Array[0] );
for ( int i = 0; i < data.Array.Length; i++ )
{
d = *ptr;
++ptr;
}
}
I called it this way:
Pointer.iterate( data );
Comments