- java.lang.Object
-
- swim.spatial.BitInterval
-
public final class BitInterval extends Object
Significant bit interval encoding. Represents power-of-2 sized integer intervals as a (64 - k) bit prefix with a k bit suffix.Leading one bits replace trailing variable suffix bits. For an integer x with k variable suffix bits, shift k high prefix 1 bits into x.
The rank of a bit interval is the number of trailing variable bits. The base of a bit interval is the lower bound of the interval.
Examples for constant prefix bits x, and variable suffix bits y:
range 2^0:
significant: 0xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
bit interval: 0xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxxrange 2^1:
significand: 0xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxy
bit interval: 10xxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxxrange 2^2:
significand: 0xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxyy
bit interval: 110xxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxxrange 2^3:
significand: 0xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxyyy
bit interval: 1110xxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxxrange 2^4:
significand: 0xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxyyyy
bit interval: 11110xxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxxrange 2^63
significand: 0yyyyyyy yyyyyyyy yyyyyyyy yyyyyyyy yyyyyyyy yyyyyyyy yyyyyyyy yyyyyyyy
bit interval: 11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111110
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
base(long bitInterval)
static int
compare(long a, long b)
static int
compare(long xa, long ya, long xb, long yb)
static boolean
contains(long q, long a)
static boolean
contains(long xq, long yq, long xa, long ya)
static long
from(int rank, long base)
static boolean
intersects(long q, long a)
static boolean
intersects(long xq, long yq, long xa, long ya)
static long
mask(long bitInterval)
static int
rank(long bitInterval)
static <T> void
sort(T[] array, Comparator<? super T> comparator)
static long
span(long x0, long x1)
static long
union(long a, long b)
-
-
-
Method Detail
-
from
public static long from(int rank, long base)
-
span
public static long span(long x0, long x1)
-
union
public static long union(long a, long b)
-
rank
public static int rank(long bitInterval)
-
base
public static long base(long bitInterval)
-
mask
public static long mask(long bitInterval)
-
compare
public static int compare(long a, long b)
-
compare
public static int compare(long xa, long ya, long xb, long yb)
-
contains
public static boolean contains(long q, long a)
-
contains
public static boolean contains(long xq, long yq, long xa, long ya)
-
intersects
public static boolean intersects(long q, long a)
-
intersects
public static boolean intersects(long xq, long yq, long xa, long ya)
-
sort
public static <T> void sort(T[] array, Comparator<? super T> comparator)
-
-