Re: BOOL array

2008-09-15 Thread Ken Thomases
On Sep 15, 2008, at 5:16 PM, Alex Reynolds wrote: I also wanted to learn a bit about Objective-C++. What are the issues that involve exceptions? I find that NSExceptions I have in my larger application still work when I poke those. In the 32-bit runtime, Objective-C exceptions and C++ exc

Re: BOOL array

2008-09-15 Thread Alex Reynolds
BOOL vs. bool aside (as well as a couple methods that return NSString* and throw NSException) I wanted to take a stab at making this particular class more portable. If I wrote it closer to the C++ STL spec, I could more easily use it in other contexts while writing my larger application in Coc

Re: BOOL array

2008-09-15 Thread Kyle Sluder
On Mon, Sep 15, 2008 at 5:43 PM, Alex Reynolds <[EMAIL PROTECTED]> wrote: > Are there any downsides to creating Cocoa-based applications in Objective > C++? If you're switching to Objective-C++ just to get std::vector, I would strongly suggest you reconsider. There are plenty of issues regarding

Re: BOOL array

2008-09-15 Thread Ken Thomases
On Sep 15, 2008, at 4:43 PM, Alex Reynolds wrote: Is there a difference in the underlying storage between vector and vector? Yes! std::vector is a class template. There's a generic implementation provided that works with any type (within certain constraints), but there's a specializati

Re: BOOL array

2008-09-15 Thread Clark Cox
On Mon, Sep 15, 2008 at 2:43 PM, Alex Reynolds <[EMAIL PROTECTED]> wrote: >> >> Of course there's always std::vector< bool > ;-) usually at 1 bit per >> bit... >> >> -- >> Scott Ribe >> [EMAIL PROTECTED] >> http://www.killerbytes.com/ >> (303) 722-0567 voice > > > Thanks for the tip. So I ended up

Re: BOOL array

2008-09-15 Thread Alex Reynolds
> > Of course there's always std::vector< bool > ;-) usually at 1 bit per > bit... > > -- > Scott Ribe > [EMAIL PROTECTED] > http://www.killerbytes.com/ > (303) 722-0567 voice Thanks for the tip. So I ended up going the route of making my .m files into .mm files, and using std::vector< vector > t

Re: BOOL array

2008-09-11 Thread Clark Cox
On Thu, Sep 11, 2008 at 6:22 AM, dreamcat7 <[EMAIL PROTECTED]> wrote: > > On 11 Sep 2008, at 13:08, Jean-Daniel Dupas wrote: >> >> That's fine if you love to reinvent the wheel, but that exactly the >> interface provided by CFMutableBitVector. >> >> CFBitVectorCreateMutable() >> CFBitVectorSetBitAt

Re: BOOL array

2008-09-11 Thread Michael Ash
On Wed, Sep 10, 2008 at 12:28 PM, Shawn Erickson <[EMAIL PROTECTED]> wrote: > On Wed, Sep 10, 2008 at 9:18 AM, Joel Norvell <[EMAIL PROTECTED]> wrote: >> OK. I think I've got it. One could use an increasing sequence of integers, >> letting evenness and oddness determine the boolean state at any

Re: BOOL array

2008-09-11 Thread Peter N Lewis
At 14:22 +0100 11/9/08, dreamcat7 wrote: On 11 Sep 2008, at 13:08, Jean-Daniel Dupas wrote: And it probably does it better as it will not waste 7 bits for each option. No, in a CFBitVector there is 4-bytes for each bit. CFBit A binary value of either 0 or 1. typedef UInt32 CFBit; The CFBi

Re: BOOL array

2008-09-11 Thread Chris Holloway
No, CFBit is just declared to be used in the interface of CFBitVector. Look at http://http://src.gnu-darwin.org/DarwinSourceArchive/expanded/CF/CF-299/Collections.subproj/CFBitVector.c, in particular the function __CFBitVectorBit. Each value has 1 bit of overhead. Anything more is a needless waste

Re: BOOL array

2008-09-11 Thread dreamcat7
On 11 Sep 2008, at 13:08, Jean-Daniel Dupas wrote: That's fine if you love to reinvent the wheel, but that exactly the interface provided by CFMutableBitVector. CFBitVectorCreateMutable() CFBitVectorSetBitAtIndex() CFBitVectorGetBitAtIndex() And it probably does it better as it will not w

Re: BOOL array

2008-09-11 Thread Jean-Daniel Dupas
Le 11 sept. 08 à 13:32, dreamcat7 a écrit : Yes the NSMutableData needs this category method then it work. @interface NSMutableData (charArray) - (char*)char; @end @implementation NSMutableData (charArray) - (char*)char { char * foo = self.mutableBytes; return foo; } @end

Re: BOOL array

2008-09-11 Thread dreamcat7
Yes the NSMutableData needs this category method then it work. @interface NSMutableData (charArray) - (char*)char; @end @implementation NSMutableData (charArray) - (char*)char { char * foo = self.mutableBytes; return foo; } @end + (NSMutableData*)defaultOptions { NSMu

Re: BOOL array

2008-09-11 Thread dreamcat7
" use NSMutableData objects with 1 byte for each 0 or 1 value. You can then get the BOOL values as 'data.bytes [index]', set them with 'data.mutableBytes [index] = someBool' and resize the array with 'data.length = someLength'. In terms of source code, that's about as minimalistic as it gets

Re: BOOL array

2008-09-10 Thread Quincey Morris
... [earlier discussion] ... NSIndexSet can use less than 1-bit per bit :) (It compresses contiguous ranges) In some cases, especially where 1s are relatively sparse, as with selections. It can also take a whole lot more than 1 bit per bit, since a range is a pair of 32-bit ints. ... [future

Re: BOOL array

2008-09-10 Thread Scott Ribe
> NSIndexSet can use less than 1-bit per bit :) > (It compresses contiguous ranges) In some cases, especially where 1s are relatively sparse, as with selections. It can also take a whole lot more than 1 bit per bit, since a range is a pair of 32-bit ints. -- Scott Ribe [EMAIL PROTECTED] http://w

Re: BOOL array

2008-09-10 Thread Clark Cox
NSIndexSet can use less than 1-bit per bit :) (It compresses contiguous ranges) On Wed, Sep 10, 2008 at 5:21 PM, Scott Ribe <[EMAIL PROTECTED]> wrote: > Of course there's always std::vector< bool > ;-) usually at 1 bit per bit... -- Clark S. Cox III [EMAIL PROTECTED] __

Re: BOOL array

2008-09-10 Thread Scott Ribe
Of course there's always std::vector< bool > ;-) usually at 1 bit per bit... -- Scott Ribe [EMAIL PROTECTED] http://www.killerbytes.com/ (303) 722-0567 voice ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or

Re: BOOL array

2008-09-10 Thread Joel Norvell
Yes, only storing "ones" would work well with NSMutableIndexSet's containsIndex method. If you didn't get a "hit" you'd know that that position was a "zero." I was incorrectly thinking of NSMutableIndexSet as an array. --- On Wed, 9/10/08, Shawn Erickson <[EMAIL PROTECTED]> wrote: > On Wed, S

Re: BOOL array

2008-09-10 Thread Shawn Erickson
On Wed, Sep 10, 2008 at 9:18 AM, Joel Norvell <[EMAIL PROTECTED]> wrote: > OK. I think I've got it. One could use an increasing sequence of integers, > letting evenness and oddness determine the boolean state at any index. That > would save a huge amount of "overhead" in this case! You only n

Re: BOOL array

2008-09-10 Thread Igor Mozolevsky
2008/9/10 Joel Norvell <[EMAIL PROTECTED]>: > OK. I think I've got it. One could use an increasing sequence of integers, > letting evenness and oddness determine the boolean state at any index. That > would save a huge amount of "overhead" in this case! Is the size of the boolean set always f

Re: BOOL array

2008-09-10 Thread Joel Norvell
OK. I think I've got it. One could use an increasing sequence of integers, letting evenness and oddness determine the boolean state at any index. That would save a huge amount of "overhead" in this case! --- On Wed, 9/10/08, Todd Blanchard wrote: > Well, if I read it right, he's using the NS

Re: BOOL array

2008-09-10 Thread Todd Blanchard
cter long NSString * instances into an NSMutableArray. The characters are 0 or 1. I guess I could use an int array, but I'm looking to speed up my app and reduce storage. Is it possible to create a BOOL array that can be put into an NSMutableArray? On Sep 10, 2008, at 02:32, Todd Blanchard w

Re: BOOL array

2008-09-09 Thread Joel Norvell
e characters are 0 or 1. > > > > I guess I could use an int array, but I'm looking to speed up my app > > and reduce storage. Is it possible to create a BOOL array that can > > be put into an NSMutableArray? > On Sep 10, 2008, at 02:32, Todd Blanchard wrote: &g

Re: BOOL array

2008-09-09 Thread Joel Norvell
an int array, but I'm looking to speed up my app > > and reduce storage. Is it possible to create a BOOL array that can > > be put into an NSMutableArray? > Or use NSMutableData objects with 1 byte for each 0 or 1 value. You > can then get the BOOL values as 'dat

Re: BOOL array

2008-09-09 Thread Todd Blanchard
I'm looking to speed up my app and reduce storage. Is it possible to create a BOOL array that can be put into an NSMutableArray? Thanks, Alex ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or mode

Re: BOOL array

2008-09-09 Thread Andy Lee
app and reduce storage. Is it possible to create a BOOL array that can be put into an NSMutableArray? Or use NSMutableData objects with 1 byte for each 0 or 1 value. You can then get the BOOL values as 'data.bytes [index]', set them with 'data.mutableBytes [index] = someBool&#

Re: BOOL array

2008-09-09 Thread Andrew Merenbach
On Sep 9, 2008, at 3:24 AM, Alex Reynolds wrote: I am currently putting 320 to 480 character long NSString * instances into an NSMutableArray. The characters are 0 or 1. I guess I could use an int array, but I'm looking to speed up my app and reduce storage. Is it possible to create a

Re: BOOL array

2008-09-09 Thread Quincey Morris
On Sep 9, 2008, at 03:24, Alex Reynolds wrote: I am currently putting 320 to 480 character long NSString * instances into an NSMutableArray. The characters are 0 or 1. I guess I could use an int array, but I'm looking to speed up my app and reduce storage. Is it possible to create a

Re: BOOL array

2008-09-09 Thread Jean-Daniel Dupas
Le 9 sept. 08 à 12:24, Alex Reynolds a écrit : I am currently putting 320 to 480 character long NSString * instances into an NSMutableArray. The characters are 0 or 1. I guess I could use an int array, but I'm looking to speed up my app and reduce storage. Is it possible to create a

Re: BOOL array

2008-09-09 Thread Jason Coco
BOOL array that can be put into an NSMutableArray? You can use a BOOL array or an int array... or an array of uint8_t. BOOL is just a signed char anyway. Just wrap the array in an NSValue object when you put it into the NSMutableArray: BOOL boolArrayOne[320]; /* ... */ NS

BOOL array

2008-09-09 Thread Alex Reynolds
I am currently putting 320 to 480 character long NSString * instances into an NSMutableArray. The characters are 0 or 1. I guess I could use an int array, but I'm looking to speed up my app and reduce storage. Is it possible to create a BOOL array that can be put into an NSMutable