[ library(gfd) | Reference Manual | Alphabetic Index ]

# max_first_index(+Collection,?Index)

Index is constrained to the index of the first variable with the maximum value in Collection

Collection
  A collection (a la collection_to_list/2) of integers or (domain) variables
Index
  (Domain) variable or integer (array notation accepted)

## Description

Index is constrained to the index of the first (smallest index) variable(s) with the maximum value in Collection. If Index is a variable, it must not occur in Collection..

You may find it more convenient to embed `max_first_index(Vars)` in a constraint expression.

As with all constraints that involve indexes, the index starts from 1, unlike Gecode's native indexes that starts from 0 - a dummy first element is added to Collection in the constraint posted to Gecode if Collection is not empty.

This constraint is a variation of max_index in the global constraint catalog, and is implemented using Gecode's maxarg() constraint with tie-break set to true..

## See Also

max_index / 2, max_first_index / 2, min_index / 2, max / 2, min / 2, eclipse_6 : collection_to_list / 2, lists : collection_to_list / 2