View source code
							
							
						
								Display the source code in std/algorithm/searching.d from which this
								page was generated on github.
							
						
							Report a bug
							
						
								If you spot a problem with this page, click here to create a
								Bugzilla issue.
							
						
							
								Improve this page
							
							
					
								Quickly fork, edit online, and submit a pull request for this page.
								Requires a signed-in GitHub account. This works well for small changes.
								If you'd like to make larger changes you may want to consider using
								local clone.
							
						Function std.algorithm.searching.maxIndex
Computes the index of the first occurrence of range's maximum element.
						
				ptrdiff_t maxIndex(alias pred, Range)
				(
				
				  Range range
				
				)
				
				if (isInputRange!Range && !isInfinite!Range && is(typeof(binaryFun!pred(range
				Complexity
Ο(range)
    Exactly range comparisons are needed.
Parameters
| Name | Description | 
|---|---|
| pred | The ordering predicate to use to determine the maximum element. | 
| range | The input range to search. | 
Returns
The index of the first encounter of the maximum in range. If the
    range is empty, -1 is returned.
See Also
Example
// Maximum is 4 and first occurs in position 2
int[] a = [2, 3, 4, 1, 2, 4, 1, 1, 2];
writeln(aAuthors
License
					Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.