02.05.2014 Views

CoreandServices.book - Ocean - Schlumberger

CoreandServices.book - Ocean - Schlumberger

CoreandServices.book - Ocean - Schlumberger

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Basics<br />

Cast int array to this type.<br />

int[ ] arr = new int[ ] { 3, 5, 7 };<br />

Index3 idx3_from_arr = (Index3)arr;<br />

// idx3_from_arr value is (3, 5, 7);<br />

Cast this type to int array.<br />

Index3 idx3 = new Index3(3, 5, 7);<br />

int[ ] arr = (int) idx3;<br />

// arr value is [3, 5, 7];<br />

Index types support the following methods:<br />

Clone – This method makes an exact copy, equivalent to using the copy constructor.<br />

Index3 idx = new Index3(3, 5, 7);<br />

Index3 idx2 = idx.clone();<br />

// idx2 value is (3, 5, 7). Equivalent to copy ctor<br />

Dot – This method multiplies Index properties (I * I, J * J, ...) and sums the results.<br />

Index3 idx_1 = new Index3(3, 5, 7);<br />

Index3 idx_2 = new Index3(9, 13, 17);<br />

int dot = Index3.Dot(idx_1, idx_2)<br />

// dot = 3*9 + 5*13 + 7*17 = 211<br />

Equals – This method completes an equality check.<br />

Index3 idx_1 = new Index3(3, 5, 7);<br />

Index3 idx_2 = new Index3(9, 13, 17);<br />

if (idx_1.Equals(idx_2))<br />

// result is false<br />

GetHashCode – This method returns a hash code for the Index instance.<br />

Index3 idx3 = new Index3(3, 5, 7);<br />

int hc = idx3.GetHashCode();<br />

4-88 <strong>Ocean</strong> Application Development Framework 2008.1<br />

<strong>Schlumberger</strong> Private

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!