I'm trying to create a submap method between two keys. I can't figure out how to get this done using the methods given. Returns an iterable containing all entries with keys in the range from

  • fromKey inclusive to toKey inclusive.
  • @return iterable with keys in desired range

public Iterable<Entry<K,V>> subMapInclusive(K fromKey, K toKey) throws IllegalArgumentException {
    ArrayList<Entry<K, V>> results = new ArrayList<>();
    Entry<K, V> tempKey = ceilingEntry(fromKey);
    while(tempKey != toKey){
      results.add(tempKey);
      tempKey = lowerEntry(tempKey.getKey());



    }
    return results;
  }

0 Answers