|
| 1 | +/* |
| 2 | + * Copyright 2011-2025 Tilmann Zäschke. All Rights Reserved. |
| 3 | + * |
| 4 | + * This software is the proprietary information of Tilmann Zäschke. |
| 5 | + * Use is subject to license terms. |
| 6 | + */ |
| 7 | +package ch.ethz.globis.phtree; |
| 8 | + |
| 9 | +import java.util.Arrays; |
| 10 | + |
| 11 | +/** |
| 12 | + * Entries in a PH-tree with ranged objects. |
| 13 | + * @param <T> value type of the entry |
| 14 | + */ |
| 15 | +public class PhEntrySF<T> { |
| 16 | + |
| 17 | + private final double[] lower; |
| 18 | + private final double[] upper; |
| 19 | + private T value; |
| 20 | + |
| 21 | + /** |
| 22 | + * Range object constructor. |
| 23 | + * @param lower lower left corner |
| 24 | + * @param upper upper right corner |
| 25 | + * @param value The value associated with the point |
| 26 | + */ |
| 27 | + public PhEntrySF(double[] lower, double[] upper, T value) { |
| 28 | + this.lower = lower; |
| 29 | + this.upper = upper; |
| 30 | + this.value = value; |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * @return the value of the entry |
| 35 | + */ |
| 36 | + public T value() { |
| 37 | + return value; |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * @return lower left corner of the entry |
| 42 | + */ |
| 43 | + public double[] lower() { |
| 44 | + return lower; |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * @return upper right corner of the entry |
| 49 | + */ |
| 50 | + public double[] upper() { |
| 51 | + return upper; |
| 52 | + } |
| 53 | + |
| 54 | + void setValue(T value) { |
| 55 | + this.value = value; |
| 56 | + } |
| 57 | + |
| 58 | + @SuppressWarnings("unchecked") |
| 59 | + @Override |
| 60 | + public boolean equals(Object obj) { |
| 61 | + if (!(obj instanceof PhEntrySF)) { |
| 62 | + return false; |
| 63 | + } |
| 64 | + PhEntrySF<T> e = (PhEntrySF<T>) obj; |
| 65 | + return Arrays.equals(lower, e.lower) && Arrays.equals(upper, e.upper); |
| 66 | + } |
| 67 | + |
| 68 | + @Override |
| 69 | + public int hashCode() { |
| 70 | + return Arrays.hashCode(lower) ^ Arrays.hashCode(upper); |
| 71 | + } |
| 72 | + |
| 73 | + @Override |
| 74 | + public String toString() { |
| 75 | + return "{" + Arrays.toString(lower) + "," + Arrays.toString(upper) + "} => " + value; |
| 76 | + } |
| 77 | +} |
0 commit comments