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

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.

Replies are listed 'Best First'.
Re^4: Best method to diff large array
by newbieperlperson (Acolyte) on Nov 25, 2013 at 05:39 UTC

    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.

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