DisjointRectSet.h 608 B

12345678910111213141516171819202122232425262728
  1. #pragma once
  2. #include <AK/Vector.h>
  3. #include <LibDraw/Rect.h>
  4. class DisjointRectSet {
  5. public:
  6. DisjointRectSet() {}
  7. ~DisjointRectSet() {}
  8. DisjointRectSet(DisjointRectSet&& other)
  9. : m_rects(move(other.m_rects))
  10. {
  11. }
  12. void add(const Rect&);
  13. bool is_empty() const { return m_rects.is_empty(); }
  14. int size() const { return m_rects.size(); }
  15. void clear() { m_rects.clear(); }
  16. void clear_with_capacity() { m_rects.clear_with_capacity(); }
  17. const Vector<Rect, 32>& rects() const { return m_rects; }
  18. private:
  19. void shatter();
  20. Vector<Rect, 32> m_rects;
  21. };