forked from codysauermann/GeometricDataStructures2D
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoint2D.cpp
More file actions
72 lines (57 loc) · 1.87 KB
/
Point2D.cpp
File metadata and controls
72 lines (57 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "Point2D.h"
#include <algorithm>
#include <iostream>
using namespace std;
struct Point2D::Impl
{
Impl(){};
Impl(vector<SimplePoint2D> _pointCollection): pointCollection(move(_pointCollection)){};
vector<SimplePoint2D> pointCollection;
bool ordered;
};
Point2D::Point2D() {}
Point2D::Point2D(vector<SimplePoint2D> _pointCollection):pimpl(new Impl())
{
_pointCollection.erase(unique(_pointCollection.begin(), _pointCollection.end()), _pointCollection.end());
sort(_pointCollection.begin(), _pointCollection.end());
this->pimpl->pointCollection = _pointCollection;
this->pimpl->ordered = true;
}
Point2D::Point2D(vector<SimplePoint2D> _pointCollection, bool _ordered):pimpl(new Impl())
{
this->pimpl->ordered = _ordered;
if(_ordered){
_pointCollection.erase(unique(_pointCollection.begin(), _pointCollection.end()), _pointCollection.end());
sort(_pointCollection.begin(), _pointCollection.end());
}
this->pimpl->pointCollection = _pointCollection;
}
Point2D::Point2D(Point2D const &sourcePoint2D): pimpl(new Impl(*sourcePoint2D.pimpl))
{
}
Point2D::Point2D(Point2D &&sourcePoint2D)
{
this->pimpl = move(sourcePoint2D.pimpl);
sourcePoint2D.pimpl = nullptr;
}
Point2D::~Point2D(){}
int Point2D::count()
{
return this->pimpl->pointCollection.size();
}
Point2D::Iterator Point2D::begin()
{
return Iterator(&(this->pimpl->pointCollection)[0]);
}
Point2D::Iterator Point2D::end()
{
return Iterator(&(this->pimpl->pointCollection)[this->pimpl->pointCollection.size()]);
}
/*Point2D randomPoint2D(long count, int minX, int maxX, int minY, int maxY)
{
generateSeed();
std::vector<SimplePoint2D> points;
for (long i = 0; i < count; i++)
points.push_back(randomSimplePoint2D(minX, maxX, minY, maxY));
return Point2D(points);
}*/