data structures - Multi-Dimensional Intersection Algorithm -


all,

i have problem need solve , don't know how efficiently. suppose have collection of objects multiple properties, , each property can take multiple values.

for instance, in pseudo-code object follows:

object.color   object.size   object.sides   object.dimensions   

i want able objects in collection match set of colors, set of sizes, set of sides , set of dimensions.

right now, code if object.color in colorset , object.size in sizeset , ... , object.dimensions in dimensionsset mark object processing (by using dictionary).

is there more efficient way of doing this? can create data structure or algorithm me solve problem efficiently?

cheers!

if want 1 such query, there's not can do. instead, i'll assume want multiple such queries.

create dictionaries mapping properties sets of objects properties. example, colors, might have mappings red {obj1, obj2, obj3} , blue {obj4, obj5}. each property (color, size, sides, dimensions).

you express query on collection whole. object.color in colorset becomes union of corresponding sets colors in colorset. requiring both color , size becomes intersection of sets of objects colors , sizes.

this can more efficient because need check objects have properties, e.g., if you're interested in blue objects, can exclude objects in red set.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -