public final class SmallHilbertCurve extends Object
BigInteger) and N-dimensional points.
Note: This algorithm is derived from work done by John Skilling and published in "Programming the Hilbert curve". (c) 2004 American Institute of Physics. With thanks also to Paul Chernoch who published a C# algorithm for Skilling's work on StackOverflow and GitHub).
| Modifier and Type | Class and Description |
|---|---|
static class |
SmallHilbertCurve.Builder |
| Modifier and Type | Method and Description |
|---|---|
int |
bits() |
int |
dimensions() |
long |
index(long... point)
Converts a point to its Hilbert curve index.
|
long |
maxIndex() |
long |
maxOrdinate() |
long[] |
point(long index)
Converts a
long index (distance along the Hilbert Curve from 0) to a
point of dimensions defined in the constructor of this. |
void |
point(long index,
long[] x) |
Ranges |
query(long[] a,
long[] b)
Returns index ranges exactly covering the region bounded by
a and
b. |
Ranges |
query(long[] a,
long[] b,
int maxRanges)
Returns index ranges covering the region bounded by
a and b. |
Ranges |
query(long[] a,
long[] b,
int maxRanges,
int bufferSize)
Returns index ranges covering the region bounded by
a and b. |
public int bits()
public int dimensions()
public long index(long... point)
point - an array of long. Each coordinate can be between 0 and
2bits-1.long in the range 0 to 2bits * dimensions -
1IllegalArgumentException - if length of point array is not equal to the
number of dimensions.public long[] point(long index)
long index (distance along the Hilbert Curve from 0) to a
point of dimensions defined in the constructor of this.index - index along the Hilbert Curve from 0. Maximum value 2 bits
* dimensions-1.IllegalArgumentException - if index is negativepublic void point(long index,
long[] x)
public long maxOrdinate()
public long maxIndex()
public Ranges query(long[] a, long[] b)
a and
b. The list will be in increasing order of the range bounds (there
should be no overlaps).a - one vertex of the regionb - the opposing vertex to apublic Ranges query(long[] a, long[] b, int maxRanges)
a and b.
The list will be in increasing order of the range bounds (there should be no
overlaps). The index ranges may cover a larger region than the search box
because the set of exact covering ranges will have been reduced by joining
ranges with minimal gaps. The buffer size used by this method is 1024.a - one vertex of the regionb - the opposing vertex to amaxRanges - the maximum number of ranges to be returned. If 0 then all
ranges are returned.public Ranges query(long[] a, long[] b, int maxRanges, int bufferSize)
a and b.
The list will be in increasing order of the range bounds (there should be no
overlaps). The index ranges may cover a larger region than the search box
because the set of exact covering ranges will have been reduced by joining
ranges with minimal gaps. A buffer of ranges is used and has a size that is
generally speaking a fair bit larger than maxRanges to increase the
probability that minimal extra coverage be returned.a - one vertex of the regionb - the opposing vertex to amaxRanges - the maximum number of ranges to be returned. If 0 then all
ranges are returned.bufferSize - the buffer size of ranges to use. A larger buffer size will
increase the probability that ranges have been joined
optimally (we want to join ranges that have minimal gaps to
minimize the resultant extra coverage). If 0 is passed to
bufferSize then all ranges will be buffered before
shrinking to maxRanges.Copyright © 2013–2020. All rights reserved.