31 #ifndef __FASTJET_CLOSESTPAIR2DBASE__HH__
32 #define __FASTJET_CLOSESTPAIR2DBASE__HH__
35 #include "fastjet/internal/base.hh"
37 FASTJET_BEGIN_NAMESPACE
52 Coord2D(
double a,
double b): x(a), y(b) {};
55 Coord2D operator-(
const Coord2D & other)
const {
56 return Coord2D(x - other.x, y - other.y);};
59 Coord2D operator+(
const Coord2D & other)
const {
60 return Coord2D(x + other.x, y + other.y);};
63 Coord2D
operator*(
double factor)
const {
return Coord2D(factor*x,factor*y);};
64 friend Coord2D
operator*(
double factor,
const Coord2D & coord) {
65 return Coord2D(factor*coord.x,factor*coord.y);
69 Coord2D operator/(
double divisor)
const {
70 return Coord2D(x / divisor, y / divisor);};
73 friend double distance2(
const Coord2D & a,
const Coord2D & b) {
74 double dx = a.x - b.x, dy = a.y-b.y;
78 double distance2(
const Coord2D & b)
const {
79 double dx = x - b.x, dy = y-b.y;
91 class ClosestPair2DBase {
95 virtual void closest_pair(
unsigned int & ID1,
unsigned int & ID2,
96 double & distance2)
const = 0;
99 virtual void remove(
unsigned int ID) = 0;
103 virtual unsigned int insert(
const Coord2D & position) = 0;
108 virtual unsigned int replace(
unsigned int ID1,
unsigned int ID2,
109 const Coord2D & position) {
112 unsigned new_ID = insert(position);
118 virtual void replace_many(
const std::vector<unsigned int> & IDs_to_remove,
119 const std::vector<Coord2D> & new_positions,
120 std::vector<unsigned int> & new_IDs) {
121 for(
unsigned i = 0; i < IDs_to_remove.size(); i++) {
122 remove(IDs_to_remove[i]);}
124 for(
unsigned i = 0; i < new_positions.size(); i++) {
125 new_IDs.push_back(insert(new_positions[i]));}
128 virtual unsigned int size() = 0;
130 virtual ~ClosestPair2DBase() {};
135 FASTJET_END_NAMESPACE
137 #endif // __FASTJET_CLOSESTPAIR2DBASE__HH__
Selector operator*(const Selector &s1, const Selector &s2)
successive application of 2 selectors