View source code
							
							
						
								Display the source code in std/algorithm/comparison.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.comparison.among
Find value among values, returning the 1-based index
of the first matching value in values, or 0 if value
is not among values. The predicate pred is used to
compare values, and uses equality by default.
						
				uint among(alias pred, Value, Values...)
				(
				
				  Value value,
				
				  Values values
				
				)
				
				if (Values
				Function among
Template among
Contained Functions
| Name | Description | 
|---|---|
| among | 
Parameters
| Name | Description | 
|---|---|
| pred | The predicate used to compare the values. | 
| value | The value to search for. | 
| values | The values to compare the value to. | 
Returns
0 if value was not found among the values, otherwise the index of the found value plus one is returned.
See Also
Example
assert(3Example
Alternatively, values can be passed at compile-time, allowing for a more
efficient search, but one that only supports matching on equality:
assert(3Authors
License
					Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.