C++-ify analysis nbsearch more.

- Use static_cast instead of C casts throughout.
- Use more C++-style comments.
- Use the same pattern for startPairSearch() as for initSearch() to
  allow multiple concurrent searches.
- Use std::vector instead of explicit memory allocation for the grid
  cell management.  Memory is still managed explicitly for rvec and ivec
  arrays, since they can't be put into std::vector.
- Make most members of the implementation classes private to clarify the
  code (the implementation class is now explicitly responsible for
  managing its internal state).

Part of #866.

Change-Id: I2af5552b696644f954957f96705baabd891284a9