Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: class-dump/src/NSArray-Extensions.m

Issue 7793008: Add the 3.3.3 sources for class-dump. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « class-dump/src/NSArray-Extensions.h ('k') | class-dump/src/NSData-CDExtensions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // -*- mode: ObjC -*-
2
3 // This file is part of class-dump, a utility for examining the Objective-C seg ment of Mach-O files.
4 // Copyright (C) 1997-1998, 2000-2001, 2004-2010 Steve Nygard.
5
6 #import "NSArray-Extensions.h"
7
8 #import "CDTopoSortNode.h"
9
10 @implementation NSArray (CDExtensions)
11
12 - (NSArray *)reversedArray;
13 {
14 return [[self reverseObjectEnumerator] allObjects];
15 }
16
17 - (NSArray *)arrayByMappingSelector:(SEL)aSelector;
18 {
19 NSMutableArray *newArray;
20
21 newArray = [NSMutableArray array];
22 for (id object in self) {
23 id value = [object performSelector:aSelector];
24 if (value != nil)
25 [newArray addObject:value];
26 // TODO (2004-01-28): Or we could add NSNull.
27 }
28
29 return newArray;
30 }
31
32 @end
33
34 @implementation NSArray (CDTopoSort)
35
36 - (NSArray *)topologicallySortedArray;
37 {
38 NSMutableDictionary *nodesByName;
39 NSMutableArray *sortedArray;
40 NSArray *allNodes;
41
42 nodesByName = [[NSMutableDictionary alloc] init];
43
44 for (id <CDTopologicalSort> anObject in self) {
45 NSString *identifier;
46 CDTopoSortNode *aNode;
47
48 aNode = [[CDTopoSortNode alloc] initWithObject:anObject];
49 [aNode addDependanciesFromArray:[anObject dependancies]];
50
51 identifier = [aNode identifier];
52 if ([nodesByName objectForKey:identifier] != nil)
53 NSLog(@"Warning: Duplicate identifier (%@) in %s", identifier, _cmd) ;
54 [nodesByName setObject:aNode forKey:identifier];
55 [aNode release];
56 }
57
58 sortedArray = [NSMutableArray array];
59
60 allNodes = [[nodesByName allValues] sortedArrayUsingSelector:@selector(ascen dingCompareByIdentifier:)];
61 for (CDTopoSortNode *aNode in allNodes) {
62 if ([aNode color] == CDWhiteNodeColor)
63 [aNode topologicallySortNodes:nodesByName intoArray:sortedArray];
64 }
65
66 [nodesByName release];
67
68 return sortedArray;
69 }
70
71 @end
72
73
74 @implementation NSMutableArray (CDTopoSort)
75
76 - (void)sortTopologically;
77 {
78 NSArray *sortedArray;
79
80 sortedArray = [self topologicallySortedArray];
81 assert([self count] == [sortedArray count]);
82
83 [self removeAllObjects];
84 [self addObjectsFromArray:sortedArray];
85 }
86
87 @end
OLDNEW
« no previous file with comments | « class-dump/src/NSArray-Extensions.h ('k') | class-dump/src/NSData-CDExtensions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698