Connecting Tech Pros Worldwide Forums | Help | Site Map

Searching for subsets within multidimensional arrays

Scott Handojo
Guest
 
Posts: n/a
#1: Nov 16 '05
Lets say I have the following arrays

X1 (1, 2, 7, 8)
X2 (1, 2, 4, 6)
X3 (1, 2, 3, 5)
X4 (1, 3, 5)
X5 (2, 3, 5)
X6 (4, 5, 6, 8)

My 'search array' is comprised of
S1 (1,2,3,5,7,8)

I want all the arrays with either the same values or a
subset there of. So the result should be that I have the
arrays
X1, X3, X4, X5

X2 is discarded because of the '4' and X6 because of
the '4'

I could go through each array, but that seems slow and
time consuming. Is there a faster way of doing this
within C#?

Thanks,
Scott

Shakir Hussain
Guest
 
Posts: n/a
#2: Nov 16 '05

re: Searching for subsets within multidimensional arrays


Scott,

I believe there is no direct function in c# for your purpose.

ArrayList.BinarySearch function is available for searching within the same
array. You have to implement your own logic to search between arrays which
has different dimensions.

If speed is the issue, you can paste the code here or you can email to
shakirhussain@yahoo.com. I will try to optimize it .

--
Shak
(Houston)


"Scott Handojo" <shand@discussions.microsoft.com> wrote in message
news:2dbec01c46b75$08c1f0d0$a601280a@phx.gbl...[color=blue]
> Lets say I have the following arrays
>
> X1 (1, 2, 7, 8)
> X2 (1, 2, 4, 6)
> X3 (1, 2, 3, 5)
> X4 (1, 3, 5)
> X5 (2, 3, 5)
> X6 (4, 5, 6, 8)
>
> My 'search array' is comprised of
> S1 (1,2,3,5,7,8)
>
> I want all the arrays with either the same values or a
> subset there of. So the result should be that I have the
> arrays
> X1, X3, X4, X5
>
> X2 is discarded because of the '4' and X6 because of
> the '4'
>
> I could go through each array, but that seems slow and
> time consuming. Is there a faster way of doing this
> within C#?
>
> Thanks,
> Scott[/color]


Closed Thread