Changeset 10446


Ignore:
Timestamp:
Apr 4, 2010, 1:20:44 PM (12 years ago)
Author:
livings124
Message:

better code for determining the index of a new group

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/GroupsController.m

    r10445 r10446  
    252252{
    253253    //find the lowest index
    254     NSInteger index;
    255     for (index = 0; index < [fGroups count]; index++)
    256     {
    257         BOOL found = NO;
    258         for (NSDictionary * dict in fGroups)
    259             if ([[dict objectForKey: @"Index"] integerValue] == index)
    260             {
    261                 found = YES;
    262                 break;
    263             }
    264        
    265         if (!found)
    266             break;
    267     }
     254    NSMutableIndexSet * indexSet = [NSMutableIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fGroups count]+1)]; //candidates
     255    for (NSDictionary * dict in fGroups)
     256        [indexSet removeIndex: [[dict objectForKey: @"Index"] integerValue]];
     257   
     258    const NSInteger index = [indexSet firstIndex];
    268259   
    269260    [fGroups addObject: [NSMutableDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInteger: index], @"Index",
Note: See TracChangeset for help on using the changeset viewer.