User guide

24-169
SystemVerilog Testbench Constructs
function array_type[$] array_name.first() with (expression);
Example 24-32
value = queue1.first() with (item > 5);
object = queue1.first() with (item.x > 5);
In the first example, the first element which is greater than 5 is
returned. In the second example, the first element with the member
variable greater than 5 is returned.
find_first_index()
The find_first_index() method returns the first index satisfying the
expression using with construct. If the array is empty or no match is
found with the expression then an empty queue is returned. The with
expression is required and is not optional.
Syntax
function int_or_index_type[$] array_name.find_first_index()
with (expression);
Example 24-33
index = queue1.first _index() with (item > 5);
index = queue1.first _index() with (item.y > 5);
The first example returns the index of the first element which is greater
than 5. In the second example, the index of the first element that
contains the member variable y greater than 5 is returned.