mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 06:18:59 +00:00
The algorithm I came up with is O(n^2) but given the small numbers of rects we're typically working with, it doesn't really matter. May need to revisit this in the future if we find ourselves with a huge number of rects.
23 lines
488 B
C++
23 lines
488 B
C++
#pragma once
|
|
|
|
#include <AK/Vector.h>
|
|
#include <SharedGraphics/Rect.h>
|
|
|
|
class DisjointRectSet {
|
|
public:
|
|
DisjointRectSet() { }
|
|
~DisjointRectSet() { }
|
|
DisjointRectSet(DisjointRectSet&& other) : m_rects(move(other.m_rects)) { }
|
|
|
|
void add(const Rect&);
|
|
|
|
void clear() { m_rects.clear(); }
|
|
void clear_with_capacity() { m_rects.clear_with_capacity(); }
|
|
const Vector<Rect>& rects() const { return m_rects; }
|
|
|
|
private:
|
|
void shatter();
|
|
|
|
Vector<Rect> m_rects;
|
|
};
|
|
|