java - What is more effective, a huge condition, or a huge array? -
in app, have 2 fragments of each 1 has tridimensional array stores 2160 variables, of 720 it's float , 1440 it's integer.
i have 2 options: 1 - continue huge tridimensional array. 2 - or huge condition.
my concern application's performance on user's mobile phone. consume less time? memory array use high enough affect fragment loading?
notes
- in app, variables it's constant values.
- the user answer series of questions in end display variables.
there 3 issues:
- has 6 options
- has 15 options
- has 8 options
but have 3 series of questions, in 1 of them display float variables. , in other two, display integer variables.
actually, it's code. results_array[][][]
it's big tridimensional array, made part of code, part dealing 720 float values.
switch (rewardselected) { case 0: int count = 0; while (count < 6) { if(typepack == count) { int count2 = 0; while(count2 < 15) { if(spinnerselected == count2) { int count3 = 0; while(count3 < 8) { float percent = float.parsefloat(edittextpercent.gettext().tostring()); float withpercentapplied = (results_array[count][count3][count2] * percent) / 130; if(checkfivepercent.ischecked()) { float resultfinal = ((withpercentapplied*5) / 100) + withpercentapplied; textviewresults.get(count3).settext(string.valueof(resultfinal)); } else { textviewresults.get(count3).settext(string.valueof(withpercentapplied)); } count3++; } } count2++; } } count++; } break; case 1: break; case 2: break; }
for completeness sake, need.
package so; import java.io.filenotfoundexception; import java.io.filereader; import com.google.gson.*; public class soclass{ jsonelement job; soclass(){ try { job = new jsonparser().parse(new filereader("json file")); } catch (jsonioexception | jsonsyntaxexception | filenotfoundexception e) { // todo auto-generated catch block e.printstacktrace(); } } boolean isvaluepresent(final string v){ return job.getasjsonobject().get(v) != null; } public static void main(string[] args){ soclass = new soclass(); system.out.println("is present? " + so.isvaluepresent("no")); } }
edit
array contents in json file:
{ "key" : null, "key1" : null }
if care constant values/tags. associate real value key
Comments
Post a Comment