What do you do? Do you address them with a "I'm not taking your shit" type of deal, or do you just ignore?

This bitch is a long-goner ex, but I keep wondering what I should've done in this situation (I posted this story somewhere else awhile ago):

We were at a small party, everybody's talking, having fun etc... Im standing with her and suddenly she walks up to one of her guy friends and gives him a hug, not just like a normal hug, one that's like I feel comfortable in your hands type of hug, and mind you, this was looonnngg after everybody greeted everybody else. She doesn't do it once, but THREE times, all the while IN FRONT OF ME.

&

Me and my buddy were in front of the weight room at our school. She had volleyball practice and they were doing crunches. So before she goes in, she says hi (no hug, like always) and we talk, after a while the conversation gets to a halt, and then she walks up to my friend (who's her friend too, btw) and gives him the same type of hug.

What should I have done in these situations? Address them, or ignore them? And just in general, what do YOU do in shit test situations?

Thank you in advance.

Edit: To clarify, we were together at the time.