Randomly adding and deleting the entries

Hi ,

I have a one scenario where i need to perform ADD and DELETE operation which is completely random.

for eg:: i have to generate the random sequence like add(0)->add(1)->delete(1)->add(2)->add(3)->delete(0)->delete(2)->add(4)->add(5).

I have to make sure that the delete sequence should perform for the added entries.

Quick help is appreciated.

Thanks

In reply to syed taahir ahmed:
This can be constrained the same as this write-followed-by-read problem. Write ADDS an address to a list and Read DELETES it from the list.

In reply to dave_59:

In reply to syed taahir ahmed:
This can be constrained the same as this write-followed-by-read problem. Write ADDS an address to a list and Read DELETES it from the list.

Thanks Dave, there are few requirements to take care.

1)i should be able to perform multiple adds and multiple delete in random order
2) there should not be repeat in add of same entry. And delete should happen for the added entries.

Could you please suggest on that.

Thanks

In reply to syed taahir ahmed:

That is 3 requirements, but whose’s counting. :)

The solution I gave you will do adds and deletes in random order. However, the first operation must be an ADD and the last must be a DELETE. To prevent ADDs to the same entry, you will need two lists. The first list contains the list of entries added previously. This list continues to grow as big as you want. The second list contains the entries you have added but not yet deleted.

In reply to dave_59:

In reply to syed taahir ahmed:
That is 3 requirements, but whose’s counting. :)
The solution I gave you will do adds and deletes in random order. However, the first operation must be an ADD and the last must be a DELETE. To prevent ADDs to the same entry, you will need two lists. The first list contains the list of entries added previously. This list continues to grow as big as you want. The second list contains the entries you have added but not yet deleted.

Hi Dave,

Yeah 3 requirements :), your suggestion gave me sufficient idea to reach my solution

Appreciate for the replies :)

Thanks