
<ConsistencyModule:> max_index_g(+Collection,?Index)

   Index is constrained to the index(es) of the variable(s) with the maximum value in Collection, with native gecode indexing

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

Type
   library(gfd)

Description
  This version of max_index/2 uses the native Gecode indexing, which starts 
  from 0, i.e. the first element of Collection has index 0. This is different 
  from normal ECLiPSe's indexing, which starts from 1.

  This predicate maps directly to Gecode's native implementation of the
  constraint, and may therefore be more efficient, but could also be
  incompatible with existing ECLiPSe code. 

   This constraint can be embedded in a constraint expression in its
   functional form (without the last argument).

  See max_index/2 for a more detailed description of this predicate.

Examples
   [eclipse 25]: max_first_index([1,2,3], I).

I = 3

[eclipse 26]: max_first_index([1,2,3,1,10,9,10], I).

I = 5

[eclipse 27]: L = [A,B,C,D,E], L :: 1..10, max_first_index(L, 3), C #> 4.

L = [A{[1 .. 9]}, B{[1 .. 9]}, C{[5 .. 10]}, D{[1 .. 10]}, E{[1 .. 10]}]
A = A{[1 .. 9]}
B = B{[1 .. 9]}
C = C{[5 .. 10]}
D = D{[1 .. 10]}
E = E{[1 .. 10]}
[eclipse 28]: L = [A,B,C,D,E], L :: 1..10, max_first_index(L, 3), C #< 4.

L = [A{[1, 2]}, B{[1, 2]}, C{[2, 3]}, D{[1 .. 3]}, E{[1 .. 3]}]
A = A{[1, 2]}
B = B{[1, 2]}
C = C{[2, 3]}
D = D{[1 .. 3]}
E = E{[1 .. 3]}

[eclipse 29]:  L = [A,B,C,D,E], L :: 1..10, max_first_index(L, 3), B #> 4.

L = [A{[1 .. 9]}, B{[5 .. 9]}, C{[6 .. 10]}, D{[1 .. 10]}, E{[1 .. 10]}]
A = A{[1 .. 9]}
B = B{[5 .. 9]}
C = C{[6 .. 10]}
D = D{[1 .. 10]}
E = E{[1 .. 10]}

[eclipse 30]:  L = [A,B,C,D,E], L :: 1..10, max_first_index(L, 3), B #< 4.

L = [A{[1 .. 9]}, B{[1 .. 3]}, C{[2 .. 10]}, D{[1 .. 10]}, E{[1 .. 10]}]
A = A{[1 .. 9]}
B = B{[1 .. 3]}
C = C{[2 .. 10]}
D = D{[1 .. 10]}
E = E{[1 .. 10]}

[eclipse 31]: [A,B,D] :: 1..10, C :: 20..30, max_first_index([A,B,C,D], I).

A = A{[1 .. 10]}
B = B{[1 .. 10]}
D = D{[1 .. 10]}
C = C{[20 .. 30]}
I = 3



See Also
   max_index / 2
