- Declared in:
- ETCollection+HOM.h
- Conforms to:
- ETCollectionHOM
@group High Order Messaging and Blocks
- Declared in:
- ETCollection+HOM.h
- Conforms to:
- ETCollectionHOM
- ETCollectionHOMIntegration
@group High Order Messaging and Blocks
Helper method for map-HOM integration. Returns the keys in the dictionary.
- Declared in:
- ETCollection+HOM.h
- Conforms to:
- ETCollectionHOM
@group High Order Messaging and Blocks
- Declared in:
- ETCollection+HOM.h
- Conforms to:
- ETCollectionMutationHOM
- ETCollectionHOMMapIntegration
@group High Order Messaging and Blocks
- Declared in:
- ETCollection+HOM.h
- Conforms to:
- ETCollectionMutationHOM
@group High Order Messaging and Blocks
- Declared in:
- ETCollection+HOM.h
- Conforms to:
- ETCollectionMutationHOM
- ETCollectionHOMMapIntegration
@group High Order Messaging and Blocks
- Declared in:
- ETCollection+HOM.h
- Conforms to:
- ETCollectionMutationHOM
- ETCollectionHOMMapIntegration
@group High Order Messaging and Blocks
- Declared in:
- ETCollection+HOM.h
@group High Order Messaging and Blocks
Implement this method if your collection class needs special treatment of its elements for higher-order messaging.
- Declared in:
- ETCollection+HOM.h
@group High Order Messaging and Blocks
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".
- Declared in:
- ETCollection+HOM.h
- Conforms to:
- ETCollectionHOM
@group High Order Messaging and Blocks
- Declared in:
- ETCollection+HOM.h
@group High Order Messaging and Blocks
Returns a collection containing all elements of
the original collection that respond with
YES
to aBlock.
Returns a collection containing all elements of
the original collection that respond with
NO
to aBlock.
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.
Folds the collection by applying aBlock consecutively with the accumulator as the first and each element as the second argument of the block.
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"]
.
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.
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".
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.
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:
will produce a collection containing "foobar" and
"FOOBAR".
nil
];
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}.
- 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.
This method will be called by the filter proxy.
- Declared in:
- ETCollection+HOM.h
- Conforms to:
- ETCollectionHOMMapIntegration
- ETCollectionHOMFilterIntegration
@group High Order Messaging and Blocks
- 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.
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.
- Declared in:
- ETCollection+HOM.h
@group High Order Messaging and Blocks
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;
Filters a collection the same way
-filter
does, but only includes objects that respond with
NO
to the predicate.
Removes all elements from the collection for
which the aBlock does not return
NO
.
Removes all elements from the collection for
which the aBlock does not return
YES
.
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.
Replaces each element in the collection with the result of applying aBlock to it. The blocks takes one argument of type id.
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.
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.