Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I can do it with just one temp and n+m+(m-n) swaps (on paper):

0 1 2 3 4 5 6 7 8 [a b c d e f 1 2 3] temp [d]>>>>>>>>>>>[d] temp = *(p1+p1len+1) // want t +o move [0]->[3] so put [3]->temp (1) [a]>>>[d] *(p1+p1len+1) = *(p1+0) // [0]->[ +3] (2) [e]<<<<<[e] *(p1+0) = *(p1+p1len+2) // want t +o move [1]->[4] so put [4]->[0] (3) [b]>>>[b] *(p1+p1len+2) = *(p1+1) // [1]->[ +4] (4) [f]<<<<<[f] *(p1+1) = *(p1+p1len+3) // want t +o move [2]->[5] so put [5]->[1] (5) [c]>>>[c] *(p1+p1len+3) = *(p1+2) // [2]->[ +5] leaving [2] free so (6) [3]<<<<<<<<<[3] *(p1+2) = *(p2+p2len-1) // [2]<-[ +8] leaving [8] free so (7) [f]>>>>>>>>>>>[f] *(p2+p2len-1) = *(p1+1) // [1]->[ +8] leaving [1] free so (8) [2]<<<<<<<<<[2] *(p1+1) = *(p2+p2len-2) // [1]<-[ +7] leaving [7] free so (9) [e]>>>>>>>>>>>[e] *(p2+p2len-2) = *(p1+0) // [0]->[ +7] leaving [0] free so (10) [1]<<<<<<<<<[1] *(p1+0) = *(p2+p2len-3) // [0]<-[ +6] which leaves [6] free (11) [d]<<<<<[d] *(p2+p2len-3) = temp; // for th +e value in temp (12) [1 2 3 a b c d e f] m=6, n= +3, moves= 6+3+(6-3) = 12

But I'm damned if I can see any pattern to the increments & decrements or steps; to capture that for a generic M+N?

the triple reverse (which really is only two passes through the whole thing).

That's really quite brilliant, I'd never have thought of that :), and it will certainly be what O shall fall back to if I can't get this working.

But as the left buffers are going to be 2GB or 4GB or 8GB or 16GB or 32GB (depending on physical memory in the machine)

and the right buffer could be anything from 16 bytes up to the (leftBufferSize)-16 (ie. whatever is left in the dataset modulus the leftBufferSize)

you can see why I'd rather avoid (M+N)*2 if I can get M+N+(M-N). (And also why a 3 buffer is impractical.)


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". I'm with torvalds on this
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked
m=6, n=3, moves= 6+3+(6-3) = 12

In reply to Re^2: [OT] Swapping buffers in place. by BrowserUk
in thread [OT] Swapping buffers in place. by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-25 13:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found