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

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

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

    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.

      Waooo, this is really excellent, thank you for sharing.