| 231 | }; |
| 232 | |
| 233 | class Rect : HashNode { |
| 234 | public: |
| 235 | int top; |
| 236 | int bottom; |
| 237 | int left; |
| 238 | int right; |
| 239 | |
| 240 | public: |
| 241 | Rect(); |
| 242 | |
| 243 | Rect(const Rect &rect); |
| 244 | |
| 245 | Rect(int left, int top, int right, int bottom); |
| 246 | |
| 247 | virtual ~Rect() = default; |
| 248 | |
| 249 | bool isEmpty() const; |
| 250 | |
| 251 | bool contains(const Point &point) const; |
| 252 | |
| 253 | Point center() const; |
| 254 | |
| 255 | uintptr_t hash() const override; |
| 256 | |
| 257 | std::string toString() const; |
| 258 | |
| 259 | bool operator==(const Rect &node) const; |
| 260 | |
| 261 | Rect &operator=(const Rect &node); |
| 262 | // Rect & operator=(const Rect&& rect); |
| 263 | |
| 264 | // a reference, means do not change it's value |
| 265 | static std::shared_ptr<Rect> getRect(const std::shared_ptr<Rect> &rect); |
| 266 | |
| 267 | static const std::shared_ptr<Rect> RectZero; |
| 268 | private: |
| 269 | static std::vector<std::shared_ptr<Rect>> _rectPool; |
| 270 | }; |
| 271 | |
| 272 | typedef std::shared_ptr<Rect> RectPtr; |
| 273 | |