| 140 | }; |
| 141 | |
| 142 | public Triple<Node, Node, Double> bracket(double x) { |
| 143 | clean(); |
| 144 | int index = Collections.binarySearch((List) n, (Double) x, finder); |
| 145 | if (index >= 0) |
| 146 | return new Triple<>(n.get(index), null, 0.0); |
| 147 | if (-index - 1 >= n.size()) |
| 148 | return new Triple<>(null, n.get(n.size() - 1), 0.0); |
| 149 | |
| 150 | return new Triple<>(n.get(safeIndex(-index - 2)), n.get(safeIndex(-index - 1)), alpha(x, n.get(safeIndex(-index - 2)), n.get(safeIndex(-index - 1)))); |
| 151 | } |
| 152 | |
| 153 | private int safeIndex(int i) { |
| 154 | if (i<0) i = 0; |