code: protected boolean checkCollision() {
  
          // sort the positions by their left x coordinate, so we can easily exclude
          // pairs of positions which don't overlap horizontally
          sortByLeft();
          int i;
          for (i = 0; i < m_positions.size(); i++) {
              for (int j = i + 1; (j < m_positions.size())
                  && intersectsHorizontally(m_positions.get(i), m_positions.get(j)); j++) {
                  if (intersectsVertically(m_positions.get(i), m_positions.get(j))) {
                      handleCollision(m_positions.get(i), m_positions.get(j));
                      return true;
                  }
              }
          }
          return false;
      }
docs: Checks whether a collision occurs and handle it if necessary.<p>
  
  @return true if a collision occured