### Question:
MapSTL { public void insert(IteratorSTL<Pair<K,V>> start, IteratorSTL<Pair<K,V>> end ) { while(!start.equals(end)) { add(start.get().first, start.get().second); start.increment(); } } MapSTL(Comparator<K> comparator); @Override String toString(); void put( K key, V value ); boolean add(K key, V value); boolean contains(K key); V remove(K key); IteratorSTL<Pair<K,V>> begin(); IteratorSTL<Pair<K,V>> end(); IteratorSTL<Pair<K,V>> rBegin(); IteratorSTL<Pair<K,V>> rEnd(); V erase(K key); boolean empty(); IteratorSTL<Pair<K,V>> lower_bound( K key ); IteratorSTL<Pair<K,V>> upper_bound( K key ); boolean isEmpty(); void clear(); void erase( IteratorSTL<Pair<K,V>> iter ); void erase( IteratorSTL<Pair<K,V>> start, IteratorSTL<Pair<K,V>> end ); V get( K key ); IteratorSTL<Pair<K,V>> find(K key); int size(); void insert(IteratorSTL<Pair<K,V>> start, IteratorSTL<Pair<K,V>> end ); static final String EOL; }### Answer:
@Test public void testInsert() { MapSTL<Integer, String> map1 = new ComparableMapSTL<>(); map1.put(0, "zero"); map1.put(1, "one"); map1.put(2, "two"); map1.put(4, "four"); MapSTL<Integer, String> map2 = new ComparableMapSTL<>(); map2.put(20, "twenty"); map2.put(21, "twenty one"); map2.put(22, "twenty two"); map2.put(23, "twenty three"); IteratorSTL<Pair<Integer, String>> begin = map2.begin(); IteratorSTL<Pair<Integer, String>> end = map2.end(); map1.insert(begin, end); assertEquals(8, map1.size()); assertEquals("zero", map1.get(0)); assertEquals("one", map1.get(1)); assertEquals("two", map1.get(2)); assertEquals("four", map1.get(4)); assertEquals("twenty", map1.get(20)); assertEquals("twenty one", map1.get(21)); assertEquals("twenty two", map1.get(22)); assertEquals("twenty three", map1.get(23)); map1 = new ComparableMapSTL<>(); map1.put(0, "zero"); map1.put(1, "one"); map1.put(2, "two"); map1.put(4, "four"); begin = map2.begin(); end = map2.end(); begin.increment(); end.decrement(); map1.insert(begin, end); assertEquals(6, map1.size()); assertEquals("zero", map1.get(0)); assertEquals("one", map1.get(1)); assertEquals("two", map1.get(2)); assertEquals("four", map1.get(4)); assertEquals("twenty one", map1.get(21)); assertEquals("twenty two", map1.get(22)); }