Searches for an element in an unsorted 1D array starting at start index. The search is linear and LabVIEW stops searching as soon as the element is found. The connector pane displays the default data types for this polymorphic function.


icon

Inputs/Outputs

  • c1ddbl.png unsorted 1D array

    unsorted 1D array can be a 1D array of any type.

  • cdbl.png element

    element is the value to search for in the array. element must be the same data type as the elements in 1D array.

  • ci32.png start index (0)

    start index is the index that LabVIEW begins the search from. The default is 0.

  • cEqual_Functorlvclass.png equals function (built-in =)

    equals function is the comparison used to search the array. By default, this is the same comparison the standard Equal? function uses.

    If the array element is a class with an Equals method that includes two inputs of the same type and a boolean output in the connector pane , the default changes to use that comparison.

    To specify a different sort order, wire this terminal to one of the following objects:

    • A class that defines a Equals method with the following connector pane configuration :
      • A functor input in the top-left. A functor is a class that defines an operation on a data type.
      • Two inputs of the same data type as the array elements.
      • A boolean output between two empty outputs.
    • A VI refnum with the following connector pane configuration :
      • Two inputs of the same data type as the array elements.
      • A boolean output.

    The comparison function must be symmetric. If a<b is true, b<a is false. If a and b are the same value, both a<b and b<a are false. If the function is not symmetric, the search results will be unpredictable.

  • ii32.png index of element

    index of element is the index where element is found.

    If the function does not find element, index of element is –1.

  • You cannot use this function to retrieve the index of a value that is not an element of the array. For example, if you have an array of two elements (0.0 and 1.0), this function does not find the index of the value 0.5, as that value is not an element of the array. Use the Threshold 1D Array to find a fractional index or specify an alternate comparison in the equals function input to find the first value within some epsilon.

    This function only finds a string if the element you specify matches an array element exactly. To search a string for any occurrence of a regular expression, use the Match Regular Expression function or specify an alternate comparison in the equals function input.