The R Project SVN R-packages

Rev

Rev 1878 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1878 Rev 5235
Line 34... Line 34...
34
- (void) addColumn: (NSArray*) colCont withName: (NSString*) name
34
- (void) addColumn: (NSArray*) colCont withName: (NSString*) name
35
{
35
{
36
    [col addObject: colCont];
36
    [col addObject: colCont];
37
    [colNames addObject: name];
37
    [colNames addObject: name];
38
    if ([col count]==1) {
38
    if ([col count]==1) {
39
		int i=0;
39
		NSUInteger i = 0;
40
		rows=[colCont count];
40
		rows = [colCont count];
41
		sortMap=(int*) malloc(sizeof(int)*rows);
41
		sortMap = (int*) malloc(sizeof(int)*rows);
42
		invSortMap=(int*) malloc(sizeof(int)*rows);
42
		invSortMap = (int*) malloc(sizeof(int)*rows);
43
		while (i<rows) { sortMap[i]=invSortMap[i]=i; i++; }
43
		while (i<rows) { sortMap[i]=invSortMap[i]=i; i++; }
44
    } else if ([colCont count]!=rows) {
44
    } else if ([colCont count] != rows) {
45
		NSLog(@"SortableDataSource: column %@ has %d rows, but the data source has %d rows! Bad things may happen...", name, rows);
45
		NSLog(@"SortableDataSource: column %@ has %d rows, but the data source has %d rows! Bad things may happen...", name, rows);
46
    }
46
    }
47
}
47
}
48
 
48
 
49
- (void) addColumnOfLength: (int) clen withCStrings: (char**) cstr name: (NSString*) name
49
- (void) addColumnOfLength: (int) clen withCStrings: (char**) cstr name: (NSString*) name
Line 144... Line 144...
144
- (id) objectAtColumn: (NSString*) name index: (int) row
144
- (id) objectAtColumn: (NSString*) name index: (int) row
145
{
145
{
146
    if (row<0 || row>=rows || !name)
146
    if (row<0 || row>=rows || !name)
147
		return nil;
147
		return nil;
148
    else {
148
    else {
149
		unsigned c = [colNames indexOfObject:name];
149
		NSUInteger c = [colNames indexOfObject:name];
150
		if (c==NSNotFound) return nil;
150
		if (c == NSNotFound) return nil;
151
		else {
151
		else {
152
			NSArray *cc = (NSArray*) [col objectAtIndex: c];
152
			NSArray *cc = (NSArray*) [col objectAtIndex: c];
153
			return (!cc)?nil:[cc objectAtIndex: sortMap[row]];
153
			return (!cc)?nil:[cc objectAtIndex: sortMap[row]];
154
		}
154
		}
155
    }
155
    }