There is a saying that we can't chose who we love. We could have feelings for guys who are taken or who are bad news.
If you have feelings for someone's boyfriend or someone who is bad for you, don't fight them. The more you try not to think about someone the more you think about that person. Even if you are busy all day, trying to get your mind off of them at night when you have nothing to think about you will think of that person.
The first thing you must do is acknowledge your feelings. Accept how you feel about the other person. After you do that look at the facts. If they are with someone it hurts but sneaking around or going after them is wrong. If they have issues, mistreat you or are just not your type then know that. Know that you deserve better and these feelings just happened.
Go and surround yourself around other guys. Don't sleep around or give yourself a bad reputation. The way you have feeling for this guy the way you could have feelings for another. This guy is not the only guy in the world. There are guys in the world that are single and know how to treat a girl.
Give it time for the feelings to go away. Don't fight them or talk yourself out of liking that person. Once again you cannot control your feelings. Just go live your life and pretty soon that person will just be someone from the past whom you liked.
So if you are in this situation don't worry. The worst thing you could do is fight your feelings All it will cause you is stress. Don't let yourself get in a messy situation. Just know that the way you like this guy the way you could like someone else.