Getting data from associative array with .next()

In reply to boryah:

From the LRM:

The syntax for the next() method is as follows:


function int next( ref index );

where index is an index of the appropriate type for the array in question. Associative arrays that specify a wildcard index type shall not be allowed.

The next() method finds the smallest index whose value is greater than the given index argument.

If there is a next entry, the index variable is assigned the index of the next entry, and the function returns 1. Otherwise, the index is unchanged, and the function returns 0.


  string s;
  if ( map.first( s ) )
    do
      $display( "%s : %d\n", s, map[ s ] );
    while ( map.next( s ) );