mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 08:41:03 +00:00
fixes to conform to coding style
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35477 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
739c0c8ece
commit
7fd19938a5
1 changed files with 102 additions and 88 deletions
|
@ -864,120 +864,134 @@ static NSUInteger posForIndex(GSIArray array, NSUInteger index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)enumerateIndexesInRange: (NSRange)range
|
- (void) enumerateIndexesInRange: (NSRange)range
|
||||||
options: (NSEnumerationOptions)opts
|
options: (NSEnumerationOptions)opts
|
||||||
usingBlock: (GSIndexSetEnumerationBlock)aBlock
|
usingBlock: (GSIndexSetEnumerationBlock)aBlock
|
||||||
{
|
{
|
||||||
NSUInteger lastInRange = (NSMaxRange(range) - 1);
|
NSUInteger lastInRange;
|
||||||
NSUInteger startArrayIndex = posForIndex(_array, range.location);
|
NSUInteger startArrayIndex;
|
||||||
NSUInteger endArrayIndex = MIN(posForIndex(_array, lastInRange), (GSIArrayCount(_array) - 1));
|
NSUInteger endArrayIndex;
|
||||||
NSUInteger i;
|
NSUInteger i;
|
||||||
NSUInteger c;
|
NSUInteger c;
|
||||||
BOOL isReverse = opts & NSEnumerationReverse;
|
BOOL isReverse = opts & NSEnumerationReverse;
|
||||||
BLOCK_SCOPE BOOL shouldStop = NO;
|
BLOCK_SCOPE BOOL shouldStop = NO;
|
||||||
|
|
||||||
if ((0 == [self count]) || (NSNotFound == range.location))
|
if ((0 == [self count]) || (NSNotFound == range.location))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startArrayIndex = posForIndex(_array, range.location);
|
||||||
if (NSNotFound == startArrayIndex)
|
if (NSNotFound == startArrayIndex)
|
||||||
{
|
{
|
||||||
startArrayIndex = 0;
|
startArrayIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastInRange = (NSMaxRange(range) - 1);
|
||||||
|
endArrayIndex = MIN(posForIndex(_array, lastInRange),
|
||||||
|
(GSIArrayCount(_array) - 1));
|
||||||
if (NSNotFound == endArrayIndex)
|
if (NSNotFound == endArrayIndex)
|
||||||
{
|
{
|
||||||
endArrayIndex = GSIArrayCount(_array) - 1;
|
endArrayIndex = GSIArrayCount(_array) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isReverse)
|
if (isReverse)
|
||||||
{
|
{
|
||||||
i = endArrayIndex;
|
i = endArrayIndex;
|
||||||
c = startArrayIndex;
|
c = startArrayIndex;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
i = startArrayIndex;
|
i = startArrayIndex;
|
||||||
c = endArrayIndex;
|
c = endArrayIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
GS_DISPATCH_CREATE_QUEUE_AND_GROUP_FOR_ENUMERATION(enumQueue, opts)
|
GS_DISPATCH_CREATE_QUEUE_AND_GROUP_FOR_ENUMERATION(enumQueue, opts)
|
||||||
while (isReverse ? i >= c : i <= c)
|
while (isReverse ? i >= c : i <= c)
|
||||||
{
|
|
||||||
NSRange r = GSIArrayItemAtIndex(_array, i).ext;
|
|
||||||
NSUInteger innerI;
|
|
||||||
NSUInteger innerC;
|
|
||||||
if (isReverse)
|
|
||||||
{
|
{
|
||||||
innerI = NSMaxRange(r) - 1;
|
NSRange r = GSIArrayItemAtIndex(_array, i).ext;
|
||||||
innerC = r.location;
|
NSUInteger innerI;
|
||||||
}
|
NSUInteger innerC;
|
||||||
else
|
|
||||||
{
|
|
||||||
innerI = r.location;
|
|
||||||
innerC = NSMaxRange(r) - 1;
|
|
||||||
}
|
|
||||||
while (isReverse ? innerI >= innerC : innerI <= innerC)
|
|
||||||
{
|
|
||||||
if ((innerI <= lastInRange) && (innerI >= range.location))
|
|
||||||
{
|
|
||||||
GS_DISPATCH_SUBMIT_BLOCK(enumQueueGroup, enumQueue, if (shouldStop) {return;}, return;, aBlock, innerI, &shouldStop);
|
|
||||||
}
|
|
||||||
if (shouldStop)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (isReverse)
|
|
||||||
{
|
|
||||||
if (0 == innerI)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
innerI--;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
innerI++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shouldStop)
|
if (isReverse)
|
||||||
{
|
{
|
||||||
break;
|
innerI = NSMaxRange(r) - 1;
|
||||||
|
innerC = r.location;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
innerI = r.location;
|
||||||
|
innerC = NSMaxRange(r) - 1;
|
||||||
|
}
|
||||||
|
while (isReverse ? innerI >= innerC : innerI <= innerC)
|
||||||
|
{
|
||||||
|
if ((innerI <= lastInRange) && (innerI >= range.location))
|
||||||
|
{
|
||||||
|
GS_DISPATCH_SUBMIT_BLOCK(enumQueueGroup, enumQueue,
|
||||||
|
if (shouldStop) {return;}, return;,
|
||||||
|
aBlock, innerI, &shouldStop);
|
||||||
|
}
|
||||||
|
if (shouldStop)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (isReverse)
|
||||||
|
{
|
||||||
|
if (0 == innerI)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
innerI--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
innerI++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldStop)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (isReverse)
|
||||||
|
{
|
||||||
|
if (0 == i)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isReverse)
|
|
||||||
{
|
|
||||||
if (0 == i)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GS_DISPATCH_TEARDOWN_QUEUE_AND_GROUP_FOR_ENUMERATION(enumQueue, opts)
|
GS_DISPATCH_TEARDOWN_QUEUE_AND_GROUP_FOR_ENUMERATION(enumQueue, opts)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)enumerateIndexesWithOptions: (NSEnumerationOptions)opts
|
- (void) enumerateIndexesWithOptions: (NSEnumerationOptions)opts
|
||||||
usingBlock: (GSIndexSetEnumerationBlock)aBlock
|
usingBlock: (GSIndexSetEnumerationBlock)aBlock
|
||||||
{
|
{
|
||||||
NSUInteger firstIndex = [self firstIndex];
|
NSUInteger firstIndex;
|
||||||
NSUInteger lastIndex = [self lastIndex];
|
NSUInteger lastIndex;
|
||||||
|
NSRange range;
|
||||||
|
|
||||||
|
firstIndex = [self firstIndex];
|
||||||
if (NSNotFound == firstIndex)
|
if (NSNotFound == firstIndex)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
[self enumerateIndexesInRange: NSMakeRange(firstIndex, ((lastIndex - firstIndex) + 1))
|
|
||||||
|
lastIndex = [self lastIndex];
|
||||||
|
range = NSMakeRange(firstIndex, ((lastIndex - firstIndex) + 1));
|
||||||
|
|
||||||
|
[self enumerateIndexesInRange: range
|
||||||
options: opts
|
options: opts
|
||||||
usingBlock: aBlock];
|
usingBlock: aBlock];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)enumerateIndexesUsingBlock: (GSIndexSetEnumerationBlock)aBlock
|
- (void) enumerateIndexesUsingBlock: (GSIndexSetEnumerationBlock)aBlock
|
||||||
{
|
{
|
||||||
[self enumerateIndexesWithOptions: 0
|
[self enumerateIndexesWithOptions: 0
|
||||||
usingBlock: aBlock];
|
usingBlock: aBlock];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue