DasGenie: !Scrap
« Dezember 2004 | Main | Februar 2005 »

Samstag, 8. Januar 2005

Iterating over an NSIndexSet

Since I needed this quite a lot and the original Apple documentation isn't very helpful here, I decided to post my 2 favorite ways of iterating over an NSIndexSet:
// easy and still reasonable fast - can be reversed by using lastIndex and indexLessThanIndex:
unsigned index = [indexSet firstIndex];
while (index!=NSNotFound) {
    // do Stuff
    index=[indexSet indexGreaterThanIndex:index]) {
}
This seems a little bit inefficient, but I was made belief (by mmalc) that indexGreaterThanIndex: behaves efficient when called this way.

Nevertheless if you want full speed at possibly large sets, then go for this one:
// more complex but as efficient as you choose your buffersize
unsigned int indexBuffer[40];
unsigned int bufferIndex;
unsigned int indexCount=1;
NSRange range=NSMakeRange([indexSet firstIndex],
                          [indexSet lastIndex]-[indexSet firstIndex]+1);
while ((indexCount=[indexSet getIndexes:indexBuffer maxCount:40 inIndexRange:&range])) {
    for (bufferIndex=0;bufferIndex<indexCount;bufferIndex++) {
        unsigned int index=indexBuffer[bufferIndex];
        // do stuff
    }
}
If you know a way to reverse the direction of this one please add a comment.
Samstag, 8. Januar 2005, 20:26 | Permalink | Comments (0)

Apple Store Refund

For those who didn't know, the US Apple Store has the following policy (here under "Prices") on price drops:
"Should Apple reduce its price on any shipped product within 10 calendar days of shipment, you may contact Apple Sales Support at 1-800-676-2775 to request a refund or credit of the difference between the price you were charged and the current selling price.  To receive the refund or credit you must contact Apple within 14 business days of shipment."

Sadly I couldn't find a regulation like this in the german policy.
Samstag, 8. Januar 2005, 12:07 | Permalink | Comments (4)

Sonntag, 2. Januar 2005

... nachtrag

Martin zurecht über Verhältnismäßigkeit: hier

Und der im ersten Kommentar erwähnte Artikel: Die Zeit: Wir haben versagt!. Lesen.
Sonntag, 2. Januar 2005, 11:33 | Permalink | Comments (1)