/core/externals/update-engine/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. #import <Foundation/Foundation.h>
  19. // Extension to NSArray to allow merging of arrays.
  20. //
  21. @interface NSArray (GTMNSArrayMergingAdditions)
  22. // Merge our array with |newArray| by sorting each array then merging the
  23. // two arrays. If |merger| is provided then call that method on any old
  24. // items that compare as equal to a new item, passing the new item as
  25. // the only argument. If |merger| is not provided, then insert new items
  26. // in front of matching old items. If neither array has any items then
  27. // nil is returned.
  28. //
  29. // The signature of the |merger| is:
  30. // - (id)merge:(id)newItem;
  31. //
  32. // Returns a new, sorted array.
  33. - (NSArray *)gtm_mergeArray:(NSArray *)newArray
  34. mergeSelector:(SEL)merger;
  35. // Same as above, only |comparer| is used to sort/compare the objects, just like
  36. // -[NSArray sortedArrayUsingSelector]. If |comparer| is nil, nil is returned.
  37. - (NSArray *)gtm_mergeArray:(NSArray *)newArray
  38. compareSelector:(SEL)comparer
  39. mergeSelector:(SEL)merger;
  40. @end