java - Data Structure for storing several thousand objects with unique index -
i reading huge xml file java sax parser: http://api.steampowered.com/ieconitems_440/getschema/v0001/?format=xml (2.82 mb)
this file contains several thousand 'items', each properties 'name', 'level', etc. 1 of properties unique integer identifier called 'defindex'. creating pojos each of these items of properties mentioned above fields (defindex 1 of them).
- i need read these item objects lot searching defindex
- i won't change data fields of objects though
my question is: how should store these item objects?
my first thought storing them in array , use defindex actual array-index, array huge , not defindexes used, e.g. jumps 2k 30k @ 1 point.
use map
.
map
objects store relationships between unique "keys" , values.
implementations of map
hashmap
, treemap
, among others. generic, type parameter key , value.
you use following. pseudocode; adapt going manipulating these objects. did not take sax api account; demonstrates how use map
.
map<integer, item> items = new hashmap<integer, item>(); (item itemtoread : file) { // or iterate items.put(item.getdefindex(), item); } // data retrieval item itemtoretrieve = items.get(defindextoget);
Comments
Post a Comment