#ifndef SYCL_NEIGHBOR_COVERAGE_SERIAL_HPP
#define SYCL_NEIGHBOR_COVERAGE_SERIAL_HPP

#include "grid.hpp"

template <typename F = double>
class SerialImplementation
{
private:

public:
	/**
	 * Constructor gets the number of points to allocate any supporting data structures of appropriate size.
	 */
	SerialImplementation(std::size_t count)
	{

		// any additional allocation of supporting data structures can be done here

	}


	/**
	 * Computes the coverage of the points by their neighbors closer than given radius.
	 * The results are stored in the coverage vector, which is already sized to the number of points
	 * (and set to zeros).
	 */
	void operator()(const Grid<F, 2> &points, F radius, std::vector<std::size_t> &coverage)
	{
		std::size_t N = points.template size<1>();
		coverage.resize(N); // not necessary, but just to be sure

		for (std::size_t i = 0; i < N; ++i) {
			std::size_t count = 0;
			for (std::size_t j = 0; j < N; ++j) {
				if (i == j) {
					continue;
				}
				F dx = points(0, i) - points(0, j);
				F dy = points(1, i) - points(1, j);
				F distSq = dx * dx + dy * dy;
				if (distSq < radius * radius) { // comparing values ^2 to avoid costly sqrt
					++count;
				}
			}
			coverage[i] = count;
		}
	}
};


#endif