class PagedVirtualMemory {

    public void setLimit(long vsize) {
        eof = vsize;
        int n = (int) (vsize >> pageBits);
        if (n >= bufferMap.length) {
            int nsize = Math.max(n + 1, (3 * bufferMap.length) / 4);
            bufferMap = Arrays.copyOf(bufferMap, nsize);
            hitCounts = Arrays.copyOf(hitCounts, nsize);
            pageMap = Arrays.copyOf(pageMap, nsize);
        }
    }

}

class PagedVirtualMemoryTest {

    @Test
    public void randomAccessRun() {

        
        TestMemory mem = new TestMemory();
        int limit = 16 << 10;
        mem.setLimit(limit);
        Random rnd = new Random();
        
        for(int i = 0; i != 10000; ++i) {
            long n = rnd.nextInt(limit - 64);
            
            verify(mem, n, 64);
        }
        
        System.out.println(mem.getFaultCount());
    }

}