What was, isn’t. What will be isn’t yet. All we have is now and that is where your mind should be.
To avoid unpleasant memories, concentrate on another memory, or concentrate on the present, where you are, and the things going on around you.
A delete function is unavailable, and so, unpleasant memories must be suppressed.
Memories of people, places, and events can be covered by pleasant recall. Keep your mind busy with better thoughts and keep fighting to suppress the unwanted thoughts.
Sometimes, it’s all you have. You must forget, or go mad.