ETCollection+HOM documentation

Authors

Generated by builder

Contents -

  1. Software documentation for the NSArray(ETCollectionHOM) category
  2. Software documentation for the NSDictionary(ETCollectionHOM) category
  3. Software documentation for the NSIndexSet(ETCollectionHOM) category
  4. Software documentation for the NSMutableArray(ETCollectionHOM) category
  5. Software documentation for the NSMutableDictionary(ETCollectionHOM) category
  6. Software documentation for the NSMutableIndexSet(ETCollectionHOM) category
  7. Software documentation for the NSMutableSet(ETCollectionHOM) category
  8. Software documentation for the NSObject(ETCollectionHOMIntegrationInformalProtocol) informal protocol
  9. Software documentation for the NSObject(ETEachHOM) category
  10. Software documentation for the NSSet(ETCollectionHOM) category
  11. Software documentation for the ETCollectionHOM protocol
  12. Software documentation for the ETCollectionHOMFilterIntegration protocol
  13. Software documentation for the ETCollectionHOMIntegration protocol
  14. Software documentation for the ETCollectionHOMMapIntegration protocol
  15. Software documentation for the ETCollectionMutationHOM protocol

Software documentation for the NSArray(ETCollectionHOM) category

NSArray(ETCollectionHOM)

Declared in:
ETCollection+HOM.h
Conforms to:
ETCollectionHOM

@group High Order Messaging and Blocks

Software documentation for the NSDictionary(ETCollectionHOM) category

NSDictionary(ETCollectionHOM)

Declared in:
ETCollection+HOM.h
Conforms to:
ETCollectionHOM
ETCollectionHOMIntegration

@group High Order Messaging and Blocks

Method summary

mapInfo 

- (NSArray*) mapInfo;

Helper method for map-HOM integration. Returns the keys in the dictionary.


Software documentation for the NSIndexSet(ETCollectionHOM) category

NSIndexSet(ETCollectionHOM)

Declared in:
ETCollection+HOM.h
Conforms to:
ETCollectionHOM

@group High Order Messaging and Blocks

Software documentation for the NSMutableArray(ETCollectionHOM) category

NSMutableArray(ETCollectionHOM)

Declared in:
ETCollection+HOM.h
Conforms to:
ETCollectionMutationHOM
ETCollectionHOMMapIntegration

@group High Order Messaging and Blocks

Software documentation for the NSMutableDictionary(ETCollectionHOM) category

NSMutableDictionary(ETCollectionHOM)

Declared in:
ETCollection+HOM.h
Conforms to:
ETCollectionMutationHOM

@group High Order Messaging and Blocks

Software documentation for the NSMutableIndexSet(ETCollectionHOM) category

NSMutableIndexSet(ETCollectionHOM)

Declared in:
ETCollection+HOM.h
Conforms to:
ETCollectionMutationHOM
ETCollectionHOMMapIntegration

@group High Order Messaging and Blocks

Software documentation for the NSMutableSet(ETCollectionHOM) category

NSMutableSet(ETCollectionHOM)

Declared in:
ETCollection+HOM.h
Conforms to:
ETCollectionMutationHOM
ETCollectionHOMMapIntegration

@group High Order Messaging and Blocks

Software documentation for the NSObject(ETCollectionHOMIntegrationInformalProtocol) informal protocol

NSObject(ETCollectionHOMIntegrationInformalProtocol)

Declared in:
ETCollection+HOM.h

@group High Order Messaging and Blocks

Method summary

mapInfo 

- (id) mapInfo;

Implement this method if your collection class needs special treatment of its elements for higher-order messaging.


Software documentation for the NSObject(ETEachHOM) category

NSObject(ETEachHOM)

Declared in:
ETCollection+HOM.h

@group High Order Messaging and Blocks

Method summary

each 

- (id) each;

If the receiver conforms to the ETCollection protocol, this method returns a proxy that will let -map and -filter methods iterate over the contents of the collection when it is used as an argument to a message. This way, [[people map] sendMail: [messages each]]; will cause the -sendMail: message to be executed once with every combination of elements from the people and the messages collection.

Note 1: It is only possible to use an proxy object created with -each if it is passed as an argument to a message that is send to a higher-order messaging proxy created by -filter , -map , -filteredCollection or -mappedCollection . Doing [aCollection addObject: [things each]] won't do anything.

Note 2: If an each proxy is passed to a message used as a filter predicate, it suffices that the predicate evaluates to YES for one element of the argument-collection. If a collection A contains "foo" and "bar" and collection B contains "BAR" and "bar", after [[A filter] isEqualToString: [B each]]; , A will still contain "bar" (but not "BAR"), since one of the elements of B matched "bar".


Software documentation for the NSSet(ETCollectionHOM) category

NSSet(ETCollectionHOM)

Declared in:
ETCollection+HOM.h
Conforms to:
ETCollectionHOM

@group High Order Messaging and Blocks

Software documentation for the ETCollectionHOM protocol

ETCollectionHOM

Declared in:
ETCollection+HOM.h

@group High Order Messaging and Blocks

Method summary

filteredCollectionWithBlock: 

- (id) filteredCollectionWithBlock: (BOOL(^)(id))aBlock;

Returns a collection containing all elements of the original collection that respond with YES to aBlock.


filteredOutCollectionWithBlock: 

- (id) filteredOutCollectionWithBlock: (BOOL(^)(id))aBlock;

Returns a collection containing all elements of the original collection that respond with NO to aBlock.


leftFold 

- (id) leftFold;

Returns a proxy object that can be used to perform a left fold on the collection. The value of the first argument of any method used as a folding method is taken to be the initial value of the accumulator, with the accumulator being used as the receiver of the folding method.

Example: total = [[salaries leftFold] addAmount: nullSalary]; will compute total of all elements in salaries by using the -addAmount: message.


leftFoldWithInitialValue: intoBlock: 

- (id) leftFoldWithInitialValue: (id)initialValue intoBlock: (id)aBlock;

Folds the collection by applying aBlock consecutively with the accumulator as the first and each element as the second argument of the block.


mappedCollection 

- (id) mappedCollection;

Returns a proxy object on which methods can be called. These methods will cause a collection to be returned containing the elements of the original collection mapped by the method call.

Example: addresses = [[people mappedCollection] address]; will cause addresses to be a collection created by sending -address to every element in people.

Note: Can be used to send the same message to multiple objects even if the message returns void, then the result is not a new collection but nil. For example, [[people mappedCollection] setCity: @"New York"] .


mappedCollectionWithBlock: 

- (id) mappedCollectionWithBlock: (id)aBlock;

Returns a collection with each element of the original collection mapped by applying aBlock where aBlock takes one argument of type id and returns id.


rightFold 

- (id) rightFold;

Returns a proxy object that can be used to perform a right fold on the collection. The value of the first argument of any method used as a folding method is taken to be the initial value of the accumulator, with the accumulator being used as the argument of the folding method.

Example: If characters is an ordered collection containing "x", "y" and "z" (in that order), [[characters rightFold] stringByAppendingString: @": end"]; will produce "xyz: end".


rightFoldWithInitialValue: intoBlock: 

- (id) rightFoldWithInitialValue: (id)initialValue intoBlock: (id)aBlock;

Folds the collection by applying aBlock consecutively with the accumulator as the second and each element (beginning with the last) as the first argument of the block.


zippedCollectionWithCollection: 

- (id) zippedCollectionWithCollection: (id<NSObject,ETCollection>)aCollection;

Returns a proxy object the will use the next message received to coalesce the receiver and aCollection into one collection by sending the message to every element of the receiver with the corresponding element of the second collection as an argument. The first argument (after the implicit receiver and selector arguments) of the message is thus ignored. The operation will stop at the end of the shorter collection.

Example: If collection A contains "foo" and "FOO", and collection B "bar" and "BAR", [[A zippedCollectionWithCollection: B] stringByAppendingString: nil]; will produce a collection containing "foobar" and "FOOBAR".


zippedCollectionWithCollection: andBlock: 

- (id) zippedCollectionWithCollection: (id<NSObject,ETCollection>)aCollection andBlock: (id)aBlock;

Coalesces the receiver and the collection named by aCollection into one collection by applying aBlock (where aBlock takes two arguments of type id) to all element-pairs built from the receiver and aCollection. The operation will stop at the end of the shorter collection.

Example: For A={a,b} and B={c,d,e} C = [A zippedCollectionWithCollection: B andBlock: ^ NSString* (NSString *foo, NSString *bar) {return [foo stringByAppendingString: bar];}]; will result in C={ac,bd}.


Software documentation for the ETCollectionHOMFilterIntegration protocol

ETCollectionHOMFilterIntegration

Declared in:
ETCollection+HOM.h

@group High Order Messaging and Blocks

The ETCollectionHOMFilterIntegration protocol defines a hook that collections can use to tie into higher-order messaging if they need special treatment of their elements.

Method summary

placeObject: atIndex: inCollection: basedOnFilter: withSnapshot: 

- (void) placeObject: (id)anObject atIndex: (NSUInteger)index inCollection: (id<ETCollectionMutation>*)aTarget basedOnFilter: (BOOL)shallInclude withSnapshot: (id)snapshot;

This method will be called by the filter proxy.


Software documentation for the ETCollectionHOMIntegration protocol

ETCollectionHOMIntegration

Declared in:
ETCollection+HOM.h
Conforms to:
ETCollectionHOMMapIntegration
ETCollectionHOMFilterIntegration

@group High Order Messaging and Blocks

Software documentation for the ETCollectionHOMMapIntegration protocol

ETCollectionHOMMapIntegration

Declared in:
ETCollection+HOM.h

@group High Order Messaging and Blocks

The ETCollectionHOMMapIntegration protocol defines a hook that collections can use to tie into higher-order messaging if they need special treatment of their elements.

Method summary

placeObject: inCollection: insteadOfObject: atIndex: havingAlreadyMapped: mapInfo: 

- (void) placeObject: (id)mappedObject inCollection: (id<ETCollectionMutation>*)aTarget insteadOfObject: (id)originalObject atIndex: (NSUInteger)index havingAlreadyMapped: (NSArray*)alreadyMapped mapInfo: (id)mapInfo;

This method will be called by the map- and zip-functions and allows the receiver to control how the replacement object is placed in the target collection (which might be identical to the receiver). Classes adopting the ETCollectionHOMMapIntegration protocol can also implement the -mapInfo to provide additional information (e.g. about the original state of the collection, which will be passed as mapInfo here.


Software documentation for the ETCollectionMutationHOM protocol

ETCollectionMutationHOM

Declared in:
ETCollection+HOM.h

@group High Order Messaging and Blocks

Method summary

filter 

- (id) filter;

Returns a proxy object on which methods with return type BOOL can be called. Only elements that respond with YES to the method call will remain in the collection. If there are any object returning messages sent to the proxy before the predicate, these messages will be applied to the elements in the collection before the test is performed. It is thus possible to filter a collection based on attributes of an object: [[[persons filter] firstName] isEqual: @"Alice"]

The returned boolean that corresponds to the last message is undetermined. For example, the code below is meaningless: if ([[[persons filter] firstName] isEqual: @"Alice"]) doSomething;


filterOut 

- (id) filterOut;

Filters a collection the same way -filter does, but only includes objects that respond with NO to the predicate.


filterOutWithBlock: 

- (void) filterOutWithBlock: (BOOL(^)(id))aBlock;

Removes all elements from the collection for which the aBlock does not return NO.


filterWithBlock: 

- (void) filterWithBlock: (BOOL(^)(id))aBlock;

Removes all elements from the collection for which the aBlock does not return YES.


map 

- (id) map;

Returns a proxy object on which methods can be called. These methods will cause each element in the collection to be replaced with the return value of the method call.


mapWithBlock: 

- (void) mapWithBlock: (id)aBlock;

Replaces each element in the collection with the result of applying aBlock to it. The blocks takes one argument of type id.


zipWithCollection: 

- (id) zipWithCollection: (id<NSObject,ETCollection>)aCollection;

Returns a proxy object which will coalesce the collection named by aCollection into the first collection by sending all messages sent to the proxy to the elements of the receiver with the corresponding element of aCollection as an argument. The first argument of the message (after the implicit receiver and selector arguments) is thus ignored. The operation will stop at the end of the shorter collection.


zipWithCollection: andBlock: 

- (void) zipWithCollection: (id<NSObject,ETCollection>)aCollection andBlock: (id)aBlock;

Coalesces the second collection into the first by applying aBlock (where aBlock takes two arguments of type id) to all element pairs. Processing will stop at the end of the shorter collection.