processing - Iterating over array of Objects -> Store Float Value of Property in New Array -
i'm trying iterate on array of new objects, isolate value within object store in new array can sort , calculate median of values. i'm able isolate float value m.breakup
getting breakup
array seems eluding me. ideas on type of array need create take mbreakup
float values?
// global info sourcetype roster[]; // our database of sources int nsources=0; // number of sources float breakup[]; void setup() { size(720,720, p3d); // load data, each record (i.e. text line) string string lines[]= loadstrings("marriagesuccess-table-s12.csv"); nsources=lines.length-2; roster=new sourcetype[nsources]; // create "sourcetype" objects database, line split tabs // ( "\t" == tab , "," == comma , "\n" == carriage return/newline ) (int i=0; i<nsources; i++) { roster[i]=new sourcetype(lines[i+1].split(",")); println(i.mbreakup); } // running problem here (sourcetype :roster){ breakup = append(breakup,i.mbreakup); } }
so figured out.
i initializing breakup array incorrectly. it's working.
// global info sourcetype roster[]; // our database of sources int nsources=0; // number of sources float[] breakup = new float[0];
arrays processing
No comments:
Post a Comment