public void getSubRecordsBetween(MultiResultSet results, Long from, Long to) { Set<Long> values = sortedSet.subSet(from, to); for (Long value : values) { ConcurrentMap<Long, Record> records = mapRecords.get(value); if (records != null) { results.addResultSet(value, records.values()); } } // to wasn't included so include now ConcurrentMap<Long, Record> records = mapRecords.get(to); if (records != null) { results.addResultSet(to, records.values()); } }