### Function

# GLib PtrArray find

since: 2.54

#### Declaration

    gboolean
    g_ptr_array_find (
      GPtrArray* haystack,
      gconstpointer needle,
      guint* index_
    )

#### Description

Checks whether `needle` exists in `haystack`. If the element is found, `TRUE` is returned and the element’s index is returned in `index_` (if non-`NULL`). Otherwise, `FALSE` is returned and `index_` is undefined. If `needle` exists multiple times in `haystack`, the index of the first instance is returned.

This does pointer comparisons only. If you want to use more complex equality checks, such as string comparisons, use g_ptr_array_find_with_equal_func().

Available since: 2.54

This function is not directly available to language bindings.

#### Parameters

`haystack`

  Type: An array of `gpointer`

  Pointer array to be searched.

  The data is owned by the caller of the function.

`needle`

  Type: `gconstpointer`

  Pointer to look for.

  The argument can be `NULL`.
  The data is owned by the caller of the function.

`index_`

  Type: `guint*`

  Return location for the index of the element, if found.

  The argument will be set by the function.
  The argument can be `NULL`.

#### Return value

Type: `gboolean`

`TRUE` if `needle` is one of the elements of `haystack`.