Apologies if you saw this on php-general already...

Give about 1 MILLION sets of 1 to ~20 integers such as:

(15, 42, 57, 314, 1024)

I need to be able to compare any two sets and determine if any of their
elements are within, say, 20 of each other.

Example:

(10, 100, 1000) CLOSETO (50, 150, 1050) ==> FALSE
(10, 100, 1000) CLOSETO (15, 150, 1050) ==> TRUE   [abs(15 - 10) < 20]
(10, 100, 1000) CLOSETO (115, 1050) ==> TRUE       [abs(115 - 110) < 20]

The sets are actually ordered sets, monotonicly increasing, if that helps.

Each set has another 36 bytes of associated data, of which 32 (two int4)
can be composed for a unique ID.  Or I could just assign an ID to each
one.

I could, of course, create a table of about 10 MILLION rows and be
searching through that...  But my gut says there should be an easier way.

I've look at the ~/contrib/array and even considered converting each set
to a built-in "path" datatype -- But neither of those seems to provide a
"any_vertex_near" function for comparing two objects.

Any ideas?...




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to