PageRenderTime 21ms CodeModel.GetById 12ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/google-toolbox-for-mac/Foundation/GTMNSArray+Merge.h

http://macfuse.googlecode.com/
C++ Header | 47 lines | 8 code | 7 blank | 32 comment | 0 complexity | 6862f1a5d91f997115d3ba4bf1e1bcfa MD5 | raw file
 1//
 2//  GTMNSArray+Merge.h
 3//
 4//  Copyright 2008 Google Inc.
 5//
 6//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
 7//  use this file except in compliance with the License.  You may obtain a copy
 8//  of the License at
 9// 
10//  http://www.apache.org/licenses/LICENSE-2.0
11// 
12//  Unless required by applicable law or agreed to in writing, software
13//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
15//  License for the specific language governing permissions and limitations under
16//  the License.
17//
18
19#import <Foundation/Foundation.h>
20
21// Extension to NSArray to allow merging of arrays.
22//
23@interface NSArray (GTMNSArrayMergingAdditions)
24
25// Merge our array with |newArray| by sorting each array then merging the
26// two arrays.  If |merger| is provided then call that method on any old
27// items that compare as equal to a new item, passing the new item as
28// the only argument.  If |merger| is not provided, then insert new items
29// in front of matching old items.  If neither array has any items then
30// nil is returned.
31//
32// The signature of the |merger| is:
33//    - (id)merge:(id)newItem;
34//
35// Returns a new, sorted array.
36- (NSArray *)gtm_mergeArray:(NSArray *)newArray
37              mergeSelector:(SEL)merger;
38
39// Same as above, only |comparer| is used to sort/compare the objects, just like
40// -[NSArray sortedArrayUsingSelector].  If |comparer| is nil, nil is returned.
41- (NSArray *)gtm_mergeArray:(NSArray *)newArray
42            compareSelector:(SEL)comparer
43              mergeSelector:(SEL)merger;
44
45@end
46
47