ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ClosestPair.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*--------------------------- File ClosestPair.h ---------------------------*/
3/*--------------------------------------------------------------------------*/
84/*--------------------------------------------------------------------------*/
85/*----------------------------- DEFINITIONS --------------------------------*/
86/*--------------------------------------------------------------------------*/
87
88#ifndef __ADS_ClosestPair
89 #define __ADS_ClosestPair
90/* self-identification: #endif constant */
91
92/*--------------------------------------------------------------------------*/
93/*------------------------------ INCLUDES ----------------------------------*/
94/*--------------------------------------------------------------------------*/
95
96#include "ADS/Contract.h"
99#include "ADS/sort/Sort.h"
100
101#include <algorithm>
102#include <cmath>
103#include <cstddef>
104#include <cstdint>
105#include <cstdlib>
106#include <limits>
107#include <numeric>
108#include <optional>
109#include <tuple>
110#include <utility>
111#include <vector>
112
113/*--------------------------------------------------------------------------*/
114/*--------------------------- NAMESPACE ------------------------------------*/
115/*--------------------------------------------------------------------------*/
116
117namespace ADS
118{
119
122inline std::int64_t squaredDistance( const Point & p , const Point & q );
123
162inline std::pair< std::pair< std::size_t , std::size_t > , std::int64_t >
163closestPair( const std::vector< Point > & P );
164
218inline std::pair< std::pair< std::size_t , std::size_t > , std::int64_t >
219closestPairSweep( const std::vector< Point > & P );
220
239inline std::pair< std::pair< std::size_t , std::size_t > , std::int64_t >
240closestPairBrute( const std::vector< Point > & P );
241
242/*--------------------------------------------------------------------------*/
243
244} // end( namespace ADS )
245
246/*--------------------------------------------------------------------------*/
247/*-------------------------- IMPLEMENTATION --------------------------------*/
248/*--------------------------------------------------------------------------*/
249
250#include "ADS/geometry/impl/ClosestPair.tpp"
251
252/*--------------------------------------------------------------------------*/
253
254#endif /* ClosestPair.h included */
255
256/*--------------------------------------------------------------------------*/
257/*------------------------- End File ClosestPair.h -------------------------*/
258/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The convex hull of a set of points of the plane (section 16.1), the smallest convex polygon that co...
The engineered random numbers, beyond the book: generators of 64 bits that cost a few instructions an...
The sort that chooses its algorithm, beyond the book: sort() and stableSort() look at what they sort ...
std::pair< std::pair< std::size_t, std::size_t >, std::int64_t > closestPair(const std::vector< Point > &P)
the places of the two closest points of and the square of their distance, by divide et impera;
std::int64_t squaredDistance(const Point &p, const Point &q)
the square of the distance of and
std::pair< std::pair< std::size_t, std::size_t >, std::int64_t > closestPairBrute(const std::vector< Point > &P)
a closest pair, the first of the least distance in the order of the loops (not always the one of clos...
std::pair< std::pair< std::size_t, std::size_t >, std::int64_t > closestPairSweep(const std::vector< Point > &P)
the pair of closestPair() by the sweep on the points sorted by , and by the randomized grid when the ...
Definition ADT.h:96
a point of the plane, of integer coordinates
Definition ConvexHull.h:101