Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

9
LINES

< > BotCompany Repo | #1004369 // keysStartingWith - sub-map of TreeMap with all keys that start with x - TODO: rename

JavaX fragment (include)

static <T> Map<S, T> keysStartingWith(String x, TreeMap<S, T> map) {
  if (empty(x)) ret map;
  S lastKey = lexicographicallyNextString(x);
  ret map.subMap(x, true, lastKey, false);
}

static <T> Map<S, T> keysStartingWith(TreeMap<S, T> map, String x) {
  ret keysStartingWith(x, map);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1004369
Snippet name: keysStartingWith - sub-map of TreeMap with all keys that start with x - TODO: rename
Eternal ID of this version: #1004369/3
Text MD5: de69d6d88c329e4ca06eedfa1a66aa87
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-02-26 09:21:08
Source code size: 292 bytes / 9 lines
Pitched / IR pitched: No / No
Views / Downloads: 594 / 602
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1013072 - keysStartingWith2 - returns a set
#1021757 - valuesForKeysStartingWith
#1021831 - subMapStartingWith_dropPrefix - not optimized for TreeMaps