How to handle better data from HashMap in Java? -
in order develop text editor in java, user able open several files object jtabbedpane
. then, stores such files on hashmap<string,tabmanager>
. (the key of hashmap
), should name of file. after, have on memory files opened within of hashmap
. now, need manage tabs. example, if user on tab selected it, evident user change font of text, save file selected, copy it, , on. manage tab selected user, need of class objects tab selected, just. such as, jtextpane
, file
. basically, should do:
for(map.entry<string, tabmanager> entry: hashmap.entry) { string key = entry.getkey(); tabmanager = entry.getvalue(); if(tab.gettabselected().equals(key)) { // resquest objects tab selected user this.container = tabmanager.getjtextpane(); this.file = tabmanager.getfile(); } }
i have on hands objects tab selected user. now, going handle it. issue is:
- how handle big amount of datas ?
- all time, have loop know tab user selected ?
how handle data ?
i can't see name of map... assuming have like:
map<string, tabmanager> map = new hashmap<>();
where string name of tab, unique per tab, , can name tab.gettabselected(), can do:
tabmanager selectedtab = map.get(tab.gettabselected());
to selected tab.
about second question: how handle big data... since don't want read , copy in memory entire file every time, want:
- start , end file pointers know chunk of file displaying
- cache tabs page each of them displays
- open file when tab selected , cache out-of-date or not covering info need, close when tab not selected anymore (and/or after time). other optimizations possible...
Comments
Post a Comment