summaryrefslogtreecommitdiff
path: root/Libraries/LibDraw/DisjointRectSet.h
blob: 44aabcfb2c56bdc98af6f308c5bf8f51302ca3fa (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
#pragma once

#include <AK/Vector.h>
#include <LibDraw/Rect.h>

class DisjointRectSet {
public:
    DisjointRectSet() {}
    ~DisjointRectSet() {}
    DisjointRectSet(DisjointRectSet&& other)
        : m_rects(move(other.m_rects))
    {
    }

    void add(const Rect&);

    bool is_empty() const { return m_rects.is_empty(); }
    int size() const { return m_rects.size(); }

    void clear() { m_rects.clear(); }
    void clear_with_capacity() { m_rects.clear_with_capacity(); }
    const Vector<Rect, 32>& rects() const { return m_rects; }

private:
    void shatter();

    Vector<Rect, 32> m_rects;
};