Iterator index querying example clarification

The section 7.12.4 ‘Iterator index querying’ provides an example as shown below:

typedef struct {int index; ...} idx_type;
idx_type q[$];
...
// Find items with index values not matching their position in the queue
q = arr.find(item, iter_index) with (item.index != item.iter_index);

Here shouldn’t array locator ‘find’ method be applied to ‘q’ instead of ‘arr’?

I think that this section of code is missing the declaration of the array:

idx_type arr[];

No, find is being used as a method of the arr associative array. The data type of the associative array elements is irrelevant here. q is a queue of arr’s index type that will store the result of the find method.

Hi @dave_59 , arr is not declared as associative array in the LRM for this example. Is it implicitly declared/understood or am I missing something.

An associative array is the only type that can have a struct as an index type, although this is not declared in this example.