Exercise is hands down the best way. In reality, nothing will 'get someone out of your mind' if they hold any significance to you. But if you work out you promote healthy brain activity combined with positive physical results and that combination will make you feel better about yourself. And when you're on that feel good kick its much easier to deal with thoughts of things you've left behind.

I also like to look at it as when you were with this person, you are not in as good of a physical and mental state as you were now. So now instead of just missing them, you can compare it to how much better you are now than you were then. Long story short, sucks trying to forget someone. Just gotta keep that head in a positive space and know that in time the feeling fades. Good luck with it.