public void removeUpTo(long item1, long item2) {
        lock.writeLock().lock();
        try {
            Map.Entry<Long, RoaringBitmap> firstEntry = map.firstEntry();
            while (firstEntry != null && firstEntry.getKey() <= item1) {
                if (firstEntry.getKey() < item1) {
                    map.remove(firstEntry.getKey(), firstEntry.getValue());
                } else {
                    RoaringBitmap bitSet = firstEntry.getValue();
                    if (bitSet != null) {
                        bitSet.remove(0, item2);
                        if (bitSet.isEmpty()) {
                            map.remove(firstEntry.getKey(), bitSet);
                        }
                    }
                    break;
                }
                firstEntry = map.firstEntry();
            }
        } finally {
            lock.writeLock().unlock();
        }
    }
@Test
    public void testRemoveUpTo() {
        ConcurrentBitmapSortedLongPairSet set = new ConcurrentBitmapSortedLongPairSet();
        set.removeUpTo(0, 1000);
        set.removeUpTo(10, 10000);
        assertTrue(set.isEmpty());

        set.add(1, 0);

        int items = 10;
        for (int i = 0; i < items; i++) {
            set.add(1, i);
        }

        set.removeUpTo(1, 5);
        assertFalse(set.isEmpty());
        assertEquals(set.size(), 5);

        for (int i = 5; i < items; i++) {
            assertTrue(set.contains(1, i));
        }

        set.removeUpTo(2, 0);
        assertTrue(set.isEmpty());
    }