2019-02-19 14:49:23 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <AK/Vector.h>
|
2019-07-18 10:15:00 +02:00
|
|
|
#include <LibDraw/Rect.h>
|
2019-02-19 14:49:23 +01:00
|
|
|
|
|
|
|
|
class DisjointRectSet {
|
|
|
|
|
public:
|
2019-06-07 11:46:55 +02:00
|
|
|
DisjointRectSet() {}
|
|
|
|
|
~DisjointRectSet() {}
|
|
|
|
|
DisjointRectSet(DisjointRectSet&& other)
|
|
|
|
|
: m_rects(move(other.m_rects))
|
|
|
|
|
{
|
|
|
|
|
}
|
2019-02-19 14:49:23 +01:00
|
|
|
|
|
|
|
|
void add(const Rect&);
|
|
|
|
|
|
2019-04-20 17:19:56 +02:00
|
|
|
bool is_empty() const { return m_rects.is_empty(); }
|
2019-05-26 17:35:33 +02:00
|
|
|
int size() const { return m_rects.size(); }
|
2019-04-20 17:19:56 +02:00
|
|
|
|
2019-02-19 14:49:23 +01:00
|
|
|
void clear() { m_rects.clear(); }
|
|
|
|
|
void clear_with_capacity() { m_rects.clear_with_capacity(); }
|
2019-04-20 14:02:19 +02:00
|
|
|
const Vector<Rect, 32>& rects() const { return m_rects; }
|
2019-02-19 14:49:23 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void shatter();
|
|
|
|
|
|
2019-04-20 14:02:19 +02:00
|
|
|
Vector<Rect, 32> m_rects;
|
2019-02-19 14:49:23 +01:00
|
|
|
};
|