29 #ifndef __FASTJET_CLOSESTPAIR2DBASE__HH__
30 #define __FASTJET_CLOSESTPAIR2DBASE__HH__
33 #include "fastjet/internal/base.hh"
35 FASTJET_BEGIN_NAMESPACE
50 Coord2D(
double a,
double b): x(a), y(b) {};
53 Coord2D operator-(
const Coord2D & other)
const {
54 return Coord2D(x - other.x, y - other.y);};
57 Coord2D operator+(
const Coord2D & other)
const {
58 return Coord2D(x + other.x, y + other.y);};
61 Coord2D
operator*(
double factor)
const {
return Coord2D(factor*x,factor*y);};
62 friend Coord2D
operator*(
double factor,
const Coord2D & coord) {
63 return Coord2D(factor*coord.x,factor*coord.y);
67 Coord2D operator/(
double divisor)
const {
68 return Coord2D(x / divisor, y / divisor);};
71 friend double distance2(
const Coord2D & a,
const Coord2D & b) {
72 double dx = a.x - b.x, dy = a.y-b.y;
76 double distance2(
const Coord2D & b)
const {
77 double dx = x - b.x, dy = y-b.y;
89 class ClosestPair2DBase {
93 virtual void closest_pair(
unsigned int & ID1,
unsigned int & ID2,
94 double & distance2)
const = 0;
97 virtual void remove(
unsigned int ID) = 0;
101 virtual unsigned int insert(
const Coord2D & position) = 0;
106 virtual unsigned int replace(
unsigned int ID1,
unsigned int ID2,
107 const Coord2D & position) {
110 unsigned new_ID = insert(position);
116 virtual void replace_many(
const std::vector<unsigned int> & IDs_to_remove,
117 const std::vector<Coord2D> & new_positions,
118 std::vector<unsigned int> & new_IDs) {
119 for(
unsigned i = 0; i < IDs_to_remove.size(); i++) {
120 remove(IDs_to_remove[i]);}
122 for(
unsigned i = 0; i < new_positions.size(); i++) {
123 new_IDs.push_back(insert(new_positions[i]));}
126 virtual unsigned int size() = 0;
128 virtual ~ClosestPair2DBase() {};
133 FASTJET_END_NAMESPACE
135 #endif // __FASTJET_CLOSESTPAIR2DBASE__HH__
Selector operator*(const Selector &s1, const Selector &s2)
successive application of 2 selectors