blob: 657c4e346a296d4662f379c6f421c2eec6460ec4 (
plain)
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
|
/*
* Tunnel.cpp
* extract
*
* Created by Hieu Hoang on 19/01/2010.
* Copyright 2010 __MyCompanyName__. All rights reserved.
*
*/
#include "Tunnel.h"
int Tunnel::Compare(const Tunnel &other) const
{
int ret = 0;
if (m_start != other.m_start)
ret = (m_start < other.m_start) ? -1 : +1;
if (ret == 0)
{
if (m_end != other.m_end)
ret = (m_end < other.m_end) ? -1 : +1;
}
return ret;
}
int Tunnel::Compare(const Tunnel &other, size_t direction) const
{
std::pair<size_t, size_t> thisHole(GetStart(direction), GetEnd(direction));
std::pair<size_t, size_t> otherHole(other.GetStart(direction), other.GetEnd(direction));
if (thisHole != otherHole)
return (thisHole < otherHole) ? -1 : +1;
else
return 0;
}
std::ostream& operator<<(std::ostream &out, const Tunnel &hole)
{
out << "[" << hole.m_start[0] << "-" << hole.m_end[0] << "]"
<< "=>" << "[" << hole.m_start[1] << "-" << hole.m_end[1] << "]";
return out;
}
|