Listing 6
// file: objects.cpp
#include "soapH.h"
Objects::Objects() : object() {}
// compute the number of collisions
int Objects::collisions() const
{ int hits = 0;
for (std::vector<Point*>::const_iterator i = object.begin(); i !=
object.end(); ++i)
for (std::vector<Point*>::const_iterator j = i; j != object.end();
++j)
if (*i != NULL && *j != NULL && *i != *j
&& (*i)->distance(**j) <= (*i)->radius() + (*j)->radius())
hits++;
return hits;
}
// empty collection?
bool empty() const
{ return object.empty(); }