Changeset 5215
- Timestamp:
- 02/04/08 07:13:22 (6 months ago)
- Files:
-
- Tuna/trunk/TNNode.h (modified) (1 diff)
- Tuna/trunk/TNNode.m (modified) (2 diffs)
- Tuna/trunk/TNSessionController.m (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Tuna/trunk/TNNode.h
r5208 r5215 57 57 - (NSUInteger)children; 58 58 - (TNNode *)childAtIndex:(NSUInteger)index; 59 - (TNNode *)firstChild;60 59 - (id)childWithFunction:(TNFunction *)function; 61 60 - (id)childWithFunctionIdenticalTo:(TNFunction *)function; 61 - (TNNode *)childWithHighestCumulativePercent; 62 62 - (TNNode *)parent; 63 63 - (BOOL)isLeaf; Tuna/trunk/TNNode.m
r5208 r5215 180 180 181 181 182 - (TNNode *)firstChild {183 return ([_children count] == 0) ? NULL : [_children objectAtIndex:0];184 }185 186 187 188 182 - (id)childWithFunction:(TNFunction *)function { 189 183 TNNode *node; … … 222 216 223 217 return NULL; 218 } 219 220 221 222 - (TNNode *)childWithHighestCumulativePercent { 223 TNNode *node, *child = NULL; 224 NSUInteger i, count; 225 double percent = 0.0; 226 227 if(_children) { 228 count = CFArrayGetCount((CFMutableArrayRef) _children); 229 230 for(i = 0; i < count; i++) { 231 node = (id) CFArrayGetValueAtIndex((CFMutableArrayRef) _children, i); 232 233 if(!child || node->_cumulativePercent > percent) { 234 child = node; 235 percent = child->_cumulativePercent; 236 } 237 } 238 } 239 240 return child; 224 241 } 225 242 Tuna/trunk/TNSessionController.m
r5208 r5215 184 184 while([node children] > 0) { 185 185 before = [node cumulativePercent]; 186 node = [node firstChild];186 node = [node childWithHighestCumulativePercent]; 187 187 after = [node cumulativePercent]; 188 188 delta = (before - after) / before;
