@Test public void testNoLimitNoOffset() { smartIterator = new SmartIterator(0, 0); Map<String, Object> unfilteredList = createMap(5); Map<String, Object> filteredList = smartIterator.applyLimitAndOffset(unfilteredList); assertEquals(5, filteredList.size()); }
public Map<String, A> applyLimitAndOffset(Map<String, A> map) { iterator = map.entrySet().iterator(); Map<String, A> filteredMap = new LinkedHashMap<String, A>(); int i = 0; while (isRecordRequired(filteredMap.size())) { Entry<String, A> item = (Entry<String, A>) iterator.next(); if (i++ >= offset) { filteredMap.put(item.getKey(), item.getValue()); } } return filteredMap; }
SmartIterator { public Map<String, A> applyLimitAndOffset(Map<String, A> map) { iterator = map.entrySet().iterator(); Map<String, A> filteredMap = new LinkedHashMap<String, A>(); int i = 0; while (isRecordRequired(filteredMap.size())) { Entry<String, A> item = (Entry<String, A>) iterator.next(); if (i++ >= offset) { filteredMap.put(item.getKey(), item.getValue()); } } return filteredMap; } }
SmartIterator { public Map<String, A> applyLimitAndOffset(Map<String, A> map) { iterator = map.entrySet().iterator(); Map<String, A> filteredMap = new LinkedHashMap<String, A>(); int i = 0; while (isRecordRequired(filteredMap.size())) { Entry<String, A> item = (Entry<String, A>) iterator.next(); if (i++ >= offset) { filteredMap.put(item.getKey(), item.getValue()); } } return filteredMap; } SmartIterator(int limit, int offset); }
SmartIterator { public Map<String, A> applyLimitAndOffset(Map<String, A> map) { iterator = map.entrySet().iterator(); Map<String, A> filteredMap = new LinkedHashMap<String, A>(); int i = 0; while (isRecordRequired(filteredMap.size())) { Entry<String, A> item = (Entry<String, A>) iterator.next(); if (i++ >= offset) { filteredMap.put(item.getKey(), item.getValue()); } } return filteredMap; } SmartIterator(int limit, int offset); Map<String, A> applyLimitAndOffset(Map<String, A> map); List<A> applyLimitAndOffset(Collection<A> unfilteredCollection); }
SmartIterator { public Map<String, A> applyLimitAndOffset(Map<String, A> map) { iterator = map.entrySet().iterator(); Map<String, A> filteredMap = new LinkedHashMap<String, A>(); int i = 0; while (isRecordRequired(filteredMap.size())) { Entry<String, A> item = (Entry<String, A>) iterator.next(); if (i++ >= offset) { filteredMap.put(item.getKey(), item.getValue()); } } return filteredMap; } SmartIterator(int limit, int offset); Map<String, A> applyLimitAndOffset(Map<String, A> map); List<A> applyLimitAndOffset(Collection<A> unfilteredCollection);  }