AVLGroupTree extends AbstractCollection<Centroid> implements Serializable { @SuppressWarnings("WeakerAccess") public int floor(double centroid) { int floor = IntAVLTree.NIL; for (int node = tree.root(); node != IntAVLTree.NIL; ) { final int cmp = Double.compare(centroid, mean(node)); if (cmp <= 0) { node = tree.left(node); } else { floor = node; node = tree.right(node); } } return floor; } AVLGroupTree();   AVLGroupTree(final boolean record); int size(); int prev(int node); int next(int node); double mean(int node); int count(int node); List<Double> data(int node); void add(double centroid, int count, List<Double> data); @Override boolean add(Centroid centroid); @SuppressWarnings("WeakerAccess") void update(int node, double centroid, int count, List<Double> data, boolean forceInPlace); void remove(int node); @SuppressWarnings("WeakerAccess") int floor(double centroid); @SuppressWarnings("WeakerAccess") int floorSum(long sum); int first(); @SuppressWarnings("WeakerAccess") int last(); @SuppressWarnings("WeakerAccess") long headSum(int node); @Override Iterator<Centroid> iterator(); int sum();  }
@Test public void testFloor() { AVLGroupTree x = new AVLGroupTree(false); for (int i = 0; i < 101; i++) { x.add(new Centroid(i / 2)); } assertEquals(IntAVLTree.NIL, x.floor(-30)); for (Centroid centroid : x) { assertEquals(centroid.mean(), x.mean(x.floor(centroid.mean() + 0.1)), 0); } }