Associative array delete more than one element

Hi,

I have an associative array :

Structure_type rdata_array[id][$];

When I do a read out of the array based on the key, such as

rdata_q = rdata_array[id];

Is it then possible to delete a specific number of elements like 64, for this particular ID?

Thanks

In reply to UVM_learner6:

I’m guessing you could use the find() method

rdata_q = rdata_array[id].find() with (item.index <64);

But you need to be a lot more specific about your request. Look at all the questions I came up with

  1. Is the specific number of elements you want to delete a variable or a constant?
  2. If there are more than 64 elements in the Q, which 64 elements get deleted?
  3. If there are less than 64 elements, do you still want the operation performed?
  4. What does this have to do with associative arrays?

In reply to dave_59:

In reply to UVM_learner6:
I’m guessing you could use the find() method

rdata_q = rdata_array[id].find() with (item.index <64);

But you need to be a lot more specific about your request. Look at all the questions I came up with

  1. Is the specific number of elements you want to delete a variable or a constant?
  2. If there are more than 64 elements in the Q, which 64 elements get deleted?
  3. If there are less than 64 elements, do you still want the operation performed?
  4. What does this have to do with associative arrays?

Ok, I understand, will add more specific questions from the next post. Thank you.

I want to delete a specific number of elements which will be based on my read_data_size, which is calculated just before I read out of the array.

The “read_data_size” number of elements that FIRST got pushed into the queue need to be deleted, if there are more than “read_data_size” number of elements.

I have a check to make sure there are “read_data_size” elements before I read out.

The last one is the real question that I am trying to find out if I can use some other structure to implement. I have read data coming from the design OOO, so other than the “id”, the structure that holds the read data does not have much information in it for me to compare against “expected” data.

So I created an Assoc array Structure_type rdata_array[id][$];.

When the queue of structures appear in random order, I want to wait for a specific read_data_size to be filled in the structure before I read them out. Once I read out the elements, I want to remove them because a future transaction can appear with the same id, which is where my checker fails.

In reply to UVM_learner6:
It would help if you created a example of the array populated with simplified data along with a sample of data that the result should look like.