Elvis: E.g. one iteration over the array.
Eifler: Well there are multiple rows as well
Caskey: I won’t know how many
Vafiadis: Basically you have one object, or two. One of them is a table of x coords, the other is a table of y coords
Gransberry: How do I know the y coordinates?
Favorito: I have to find those first
Vafiadis: You loop through the array once, and categorize each item into said table. You handle collisions with an array
Elvis: Gillice: http://pastie.org/10424398
Elvis: You don’t already know the y coordinate?
Elvis: I figured it was a property on text
Hoffstot: I know it as soon as I have found the first element of a row
Vafiadis: It’s of the form {x:x, y:y}, {x:x1, y:y1}, {x2, y:y2}, right?
Sulit: Which I can only find by its x-coordinate at the moment
Kever: Disregarding your mishaps
Elvis: Gillice: would what i suggested work?
Vafiadis: If the array is in that form, you can form a complete lookup table
Amparo: I’m not sure if that provides a performance improvement over using the original array
Thornley: Hence I’m not sure if I’m following completely
Elvis: Gillice: it’s substantially better, since you only iterate over it once.
Burnette: I need to call getusermedia synchronously, in other word i need to way to wait for the user selection before doing other stuff with the mic, do you have any idea how to wait for the callback to complete before proceeding?
Croney: Tcsc: yeah, but then I iterate over the lookup table instead?
Stickland: I guess I can design that to be more efficient though
Vafiadis: That’s still only iterating over it twice. instead of array.length2 times
Elvis: You’d do that outside of the loop though
Vafiadis: Since the lookup table will be shorter, unless every row is unique
Aberle: I’m not sure how it’d be shorter
Elvis: You’re only iterating over rows
Elvis: Andnot over the elements of the rows
Kallio: But I’d have to iterate over the original at least twice, no?
Mcnuh: First to compose the look-up table of rows
Lagraize: And then to find the y-coordinates of the rows
Kneisler: By searching for their x
Elvis: Didn’t you say you were doing this in a nested loop though
Vafiadis: The way you’re describing it, though, you aren’t iterating twice
Vafiadis: You’re iterating the entire array once per element of the original array
Elvis: Arr.forEachfunction { arr.forEachfunction {} } will iterate over the array many more than 2 times
Vafiadis: IE, you’re doing array.length * array.length iterations
Elvis: The only time it will run over it twice is for arrays of length 1.
Montelle: Tcsc: it wouldn’t iterate for each text string though
Winterberg: Only for the ones that match the x-coordinate of a row
Elvis: How do you find those?
Elvis: You have to iterate over the otehrs to get to them
Leta: The 2nd forEach wouldn’t run for each text in the array
Benny: And it’d be a filter more likely
Elvis: That’s still worst case On2
Harajly: But yeah, still not the most efficient
Elvis: I mean it might not matter for the size of what your’e dealing with.
Elvis: But if you are concerned about performance there you’ll want to go for the On solution, definitely
Blackshear: Yeah, I’ll compose a lookup table of all possible rows
Pompey: Tcsc: thanks for the idea
Vafiadis: If you were concerned about memory usage in such a situation rare these days you could also keep the original array sorted by y coordinate or use a binary search tree, but I digress