-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathBlackQuad.java
27 lines (22 loc) · 997 Bytes
/
BlackQuad.java
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
public final class BlackQuad implements QuadTree {
// Private constructor prevents objects from being created.
private BlackQuad() { }
// The only instance of this singleton class.
private static final BlackQuad instance = new BlackQuad();
/**
* Returns the only instance of this singleton class.
* @return The instance of BlackQuad.
*/
public static BlackQuad get() { return instance; }
/**
* Determines if this tree represents a square of uniform colour.
*/
public boolean isOneColour() { return true; }
/**
* Computes the black area of the region represented by this tree, under the assumption
* that the entire region is a square with side {@code 1 << scale}.
* @param scale The scale of the region represented by this tree.
* @return The black area of the region represented by this tree.
*/
public long computeArea(int scale) { return ((long)1 << scale) * ((long)1 << scale); }
}