4

I am porting a small function from C# to Objective-C (for the iPhone), and I am running into a snag with a C# method.

I'm not sure what the following C# lines would equate to in Objective C. Particularly the Set Method.

BitArray bits = new BitArray(DESC_LEN);

bits.Set(j,
(ii_data[cix_1 - KERNEL_SZ/2*ii_step - KERNEL_SZ/2] +
 ii_data[cix_1 + KERNEL_SZ/2*ii_step + KERNEL_SZ/2] -
 ii_data[cix_1 - KERNEL_SZ/2*ii_step + KERNEL_SZ/2] -
 ii_data[cix_1 + KERNEL_SZ/2*ii_step - KERNEL_SZ/2])
 >
(ii_data[cix_2 - KERNEL_SZ/2*ii_step - KERNEL_SZ/2] +
 ii_data[cix_2 + KERNEL_SZ/2*ii_step + KERNEL_SZ/2] -
 ii_data[cix_2 - KERNEL_SZ/2*ii_step + KERNEL_SZ/2] -
 ii_data[cix_2 + KERNEL_SZ/2*ii_step - KERNEL_SZ/2] )
);

Does anyone have any idea what Set in C# might equate to in Objective-C. Of course I've done some Googling, but nothing pops out.

Cheers, Brett

Brett
  • 11,637
  • 34
  • 127
  • 213

2 Answers2

4

It seems you're looking for a way to implement bit arrays in Objective-C. There is an answer to that question here: How do I implement a bit array in C / Objective C.

As for what the Set method does, the documentation for that is here: http://msdn.microsoft.com/en-us/library/system.collections.bitarray.set.aspx. All it does is set the bit at the given index (in this case j) with a boolean value (in this case, the result of the inequality comparison).

Community
  • 1
  • 1
Steven Oxley
  • 6,563
  • 6
  • 43
  • 55
0

Based on a very brief search, it looks like BitArray isn't a natural part of Objective C. So, you should first tell us what you're trying to use in place of C#'s BitArray.

This question may help: How do I implement a bit array in C / Objective C

Community
  • 1
  • 1
John Fisher
  • 22,355
  • 2
  • 39
  • 64