Best way to save two depending Strings in Java and compare if new strings already exist -


I need to save two base strings (action and parameters) in a file or a hashtable / map or array speed and The best solution for memory is

My application repeats through a large amount of form on the website and if I already check the combination of (string action, string parameter) Was done and therefore want to stop being saved. After all, if I have more than thousands of different action and parameter TUPS, then an array will be very slow. I do not have enough experience to choose the right method for this. I tried a hashtable but it does not work:

  hashtable & lt; String, string & gt; Ht = new hashtable & lt; String, string & gt; (); If (ht.containsKey (action) & amp; amp; HT.at (action) is included (parameter) {System.out.println ("Tupel already exists"); to continue; } Other ht.put (verb, parameter);  

If any action and parameter is always 1-to-1 mapping (one action only one Parameter), then your basic base should be fine (though I recommend a hashmap on the hashtap because it supports fast and fast keys)

If you have several criteria for a given action , Then you want Maps & lt; String, set & lt; String & gt; & Gt; - Where action is the key and each action is then related to the set of parameters

Announce it like this:

  Maps & lt; String, set & lt; String & gt; & Gt; Map = new hashmap & lt; & Gt; ();  

Use it like this:

 set  & lt; String & gt; Parameterset = map.get (verb); // See ParametersAd ((parameterSet! = Null) & amp; (Parameter System (parameter) {// if it exists and key system in it.out.println ("Tuepel already exists");} And the {// pair does not exist (parameterSet == null) {// Set the parameter if the required parameter sets = new hashset & lt; string & gt; (); map.put (verb, parameter set);} parameter set.ed ( Parameter); / and add your parameter}  

for the rest of your code and other things which are not working :

  • I'm not sure what your continue is in your original code, it is difficult to tell without the remaining method.
  • I am assuming that the construction of your hashtable is different from the use - if you are reproducing it every time, then you certainly have problems.

Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -