### Question:
Hits implements Closeable { public int getCountBetween (int firstindex, int lastindex, int start, int stop, Float minweight, Boolean isPlus) throws IOException { assert(firstindex >= 0); assert(lastindex >= firstindex); assert(lastindex <= positions.ib.limit()); int[] p = getIndices(firstindex, lastindex, start,stop); if (minweight == null && isPlus == null) { return p[1] - p[0]; } int count = 0; for (int i = p[0]; i < p[1]; i++) { count += ((minweight == null || (weights.get(i) >= minweight)) && (isPlus == null || (getStrandOne(lenAndStrand.get(i)) == isPlus))) ? 1 : 0; } return count; } Hits(int chrom, String positionsFname, String weightsFname, String lasFname); static IntBP openIntBP(String fname); static FloatBP openFloatBP(String fname); static short getLengthOne(int las); static short getLengthTwo(int las); static boolean getStrandOne(int las); static boolean getStrandTwo(int las); static int makeLAS(short lengthOne, boolean strandOne); static int makeLAS(short lengthOne, boolean strandOne, short lengthTwo, boolean strandTwo); IntBP getPositionsBuffer(); FloatBP getWeightsBuffer(); IntBP getLASBuffer(); int[] getIndicesLinear(int firstindex, int lastindex, int startpos, int lastpos); int[] getIndices(int firstindex, int lastindex, int startpos, int lastpos); int getCountBetween(int firstindex,
                                int lastindex,
                                int start,
                                int stop,
                                Float minweight,
                                Boolean isPlus); double getWeightBetween(int firstindex,
                                    int lastindex,
                                    int start,
                                    int stop,
                                    Float minweight,
                                    Boolean isPlus); IntBP getIntsBetween(IntBP buffer,
                                int firstindex,
                                int lastindex,
                                int start,
                                int stop,
                                Float minweight,
                                Boolean isPlus); IntBP getHitsBetween(int firstindex,
                                int lastindex,
                                int start,
                                int stop,
                                Float minweight,
                                Boolean isPlus); IntBP getLASBetween(int firstindex,
                               int lastindex,
                               int start,
                               int stop,
                               Float minweight,
                               Boolean isPlus); FloatBP getWeightsBetween(int firstindex,
                                     int lastindex,
                                     int start,
                                     int stop,
                                     Float minweight,
                                     Boolean isPlus); int[] histogram(int firstindex,
                           int lastindex,
                           int start,
                           int stop,
                           int stepsize,
                           int dedup,
                           Float minweight,
                           Boolean isPlus,
                           boolean extension); float[] weightHistogram(int firstindex,
                                   int lastindex,
                                   int start,
                                   int stop,
                                   int stepsize,
                                   int dedup,
                                   Float minweight,
                                   Boolean isPlus,
                                   boolean extension); void close(); static IntBP emptyIntBP; static FloatBP emptyFloatBP; }### Answer:
@Test public void testCountRange() throws IOException { for (int q = 0; q < 300; q++) { int start = (int)Math.round(Math.random() * MAXVALUE); int end = start + (int)(Math.round(Math.random() * MAXVALUE) % (MAXVALUE - start)); if (end < start) { throw new RuntimeException("end < start"); } int count = 0; for (int i = 0; i < hits.size(); i++) { if (hits.get(i) >= start && hits.get(i) <= end) { count++; } } int reported = hitsfile.getCountBetween(header.getFirstIndex(start), header.getLastIndex(end), start,end, null, null); assertTrue(count == reported); } }