Mango provides a number of generic algorithms

- count
- countIf
- countIfNot
- find
- findIf
- findIfNot
- findPosition
- findPositionIf
- forEach
- intersection
- partition
- remove
- removeIf
- symmetricDifference
- transform
- unique

### count

`count`

computes the number of elements in the sequence that
are equal to `value`

(`value`

may be `null`

).
The objects in the sequence and `value`

must be comparable using
`Object.equals`

(unless `value`

is `null`

).

### countIf

`countIf`

is similar to `count`

, but more general.
It computes the number of elements in the sequence which satisfy some condition.
The condition is a described in the user-supplied `test`

object, and
`countIf`

computes the number of objects for which `test.test(o)`

is `true`

.

### countIfNot

`CountIfNot`

is the complement of `CountIf`

. It counts the number of elements in the sequence which fail some condition. The condition is a described in the user-supplied test object, and `CountIfNot`

computes the number of objects such that `test.test(o)`

is `false`

.

### find

Searchs the sequence for the given value.
Returns the `Object`

, or `null`

if the value
is not found. Any iterator will have been advanced to the next object
in the sequence. The objects in the sequence and `value`

must be comparable using
`Object.equals`

(unless `value`

is `null`

).

### findIf

Searchs the sequence and returns the first
object encountered for which the Predicate returns `true`

.
Returns the `Object`

, or `null`

if the value
is not found. Any iterator will have been advanced to the next object
in the sequence.

### findIfNot

Searchs the sequence traversed by the `Iterator`

and returns the first object encountered for which the Predicate returns `false`

. The iterator will have been advanced to the next object in the sequence.

### findPosition

Searchs the sequence traversed by the `Iterator`

for the given value. Returns the index of the value in the collection, or -1 if the value is not found. The iterator will have been advanced to the next object in the sequence. The objects in the sequence and value must be comparable using `Object.equals`

(unless value is `null`

).

### findPositionIf

Searchs the sequence traversed by the `Iterator`

until the given `Predicate`

is true. Returns the index of the value in the collection, or -1 if the value is not found. The iterator will have been advanced to the next object in the sequence.

### forEach

The algorithm ForEach applies the function `fn`

to
each element in the sequence.
E.g. to print all the elements in a list

Mango.forEach(list, Bind.Method(System.out, "println"));is equivalent to

for(int i = 0; i < list.size(); ++i) System.out.println(list.get(i));

### intersection

The intersection algorithm finds the common elements in both collections.

### partition

Partition splits a collection into two, based on the provided predicate.

### remove

The `remove`

algorithm traverses the sequence, and removes any objects which equal `value`

. The supplied iterator must support the `remove`

method.

### removeIf

The `removeIf`

algorithm traverses the sequence, and removes any objects for which `test`

is true. The supplied iterator must support the `remove`

method.

### symmetricDifference

The symmetric difference of two collections are those elements which are in one collection, but not the other. Alternatively, it can be considered in terms of stripping the common elements from two collections.

### transform

The algorithm `transform`

applies the function fn to each element in the iterator sequence. The return value of fn is appended to the `results`

collection. If the return value of fn is itself collection, then each member of that collection is added to `results`

.

### unique

This algorithm operates like the Unix uniq utility. Removes duplicate elements. Whenever a consecutive groups of duplicate objects occur in the sequence, unique removes all but the first objects in each group. The supplied iterator must support the `remove`

method.