in reply to Re: Best method to diff large array
in thread Best method to diff very large array efficiently

Thank you for taking the time to respond.

I agree, the sort is not required and I will remove that.

The information I need is on the differences in @arr_1 that are not in @arr_2.

I am not at work but will make the edits to the code tmw and check the results.

I think @dropped is incorrect verbiage, I will change it to be @diff

Replies are listed 'Best First'.
Re^3: Best method to diff large array
by BrowserUk (Patriarch) on Nov 25, 2013 at 05:29 UTC

    You didn't say whether the values in each of the two arrays are uniq?

    Also. what are the values in the arrays? Ie. strings, numbers, integers, small(ish) integers etc.?


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Hi there,

      I updated the post based on your questions, to answer your question, the values are unique and its an INT data type

      Thanks,

      AJ

        For integers, this will beat using hashes hands-down:

        @a1 = map int( rand 1e6 ), 1 .. 8000; @a2 = map int( rand 1e6 ), 1 .. 6000;; vec( $vec, $_, 1 )=1 for @a2;; @missingFromA2 = grep !vec( $vec, $_, 1 ), @a1;;

        A note of caution, if the integers can be bigger than say 2**30, then this won't work properly on older perls; and would consume large amounts of memory on newer perls. But if your integers are less than that, it is very, very fast.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.