24 #ifndef _ORDEREDPAIR_HPP_ 25 #define _ORDEREDPAIR_HPP_ 51 os <<
"(" << p.
x <<
"," << p.
y <<
")";
58 char open=
'\0', comma=
'\0', close=
'\0';
59 is >> open >> p.
x >> comma >> p.
y >> close;
61 if (open!=
'(' || comma!=
',' || close!=
')')
62 throw std::runtime_error(
"[OrderedPair::operator>>] Unexpected input.");
69 return a.
x==b.
x && a.
y==b.
y;
89 : begin_(reinterpret_cast<const
OrderedPair*>(begin)),
97 : begin_(reinterpret_cast<const
OrderedPair*>(&v[0])),
98 end_(reinterpret_cast<const
OrderedPair*>(&v[0]+v.size()))
103 const_iterator
begin()
const {
return begin_;}
104 const_iterator
end()
const {
return end_;}
105 size_t size()
const {
return end_-begin_;}
119 #endif // _ORDEREDPAIR_HPP_ std::istream & operator>>(std::istream &is, OrderedPair &p)
const OrderedPair & operator[](size_t index) const
bool operator==(const OrderedPair &a, const OrderedPair &b)
bool operator!=(const OrderedPair &a, const OrderedPair &b)
std::ostream & operator<<(std::ostream &os, const OrderedPair &p)
const_iterator end() const
OrderedPairContainerRef(const void *begin, const void *end)
constructor for wrapping array of contiguous data
OrderedPairContainerRef(const std::vector< T > &v)
template constructor for automatic conversion from vector; e.g.
const OrderedPair * begin_
OrderedPair(double _x=0, double _y=0)
const OrderedPair * const_iterator
wrapper class for accessing contiguous data as a container of OrderedPairs; note that it does not own...
const_iterator begin() const