From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10f6aa,76b1fcc14e8dced X-Google-Attributes: gid10f6aa,public X-Google-Thread: 1014db,8b6c45fbebd7d3b7 X-Google-Attributes: gid1014db,public X-Google-Thread: 109fba,76b1fcc14e8dced X-Google-Attributes: gid109fba,public X-Google-Thread: 114917,76b1fcc14e8dced X-Google-Attributes: gid114917,public X-Google-Thread: 103376,c9c309a1859318a1,start X-Google-Attributes: gid103376,public From: z007400b@bc.seflin.org (Ralph Silverman) Subject: Re: HELP ! need to insert value in array !! Date: 1997/06/27 Message-ID: <5p0v7l$9uc@nntp.seflin.org>#1/1 X-Deja-AN: 253065328 References: <33A9C27C.22F7@post4.tele.dk> <5oci49$97g@crl.crl.com> <866920621snz@genesis.demon.co.uk> Organization: SEFLIN Free-Net Newsgroups: comp.lang.c,comp.lang.c++,comp.os.msdos.programmer,comp.lang.asm.x86,comp.lang.ada Date: 1997-06-27T00:00:00+00:00 List-Id: Lawrence Kirby (fred@genesis.demon.co.uk) wrote: : In article <5oci49$97g@crl.crl.com> bobfry@crl.crl.com "Robert Fry" writes: : >Lars writes: : ... : >>This works - but is too slow when we are talking about lets say 5000 : >>positions to move...In the "delete" function i use memcopy/memmove and : >>this appear faster - but offcourse theese functions doesnt work the : >>other direction... : memcpy() isn't defined to work at all for overlapping copies, memmove() : works fine, whether copying backwards or forwards. : >>Do i have to live with this ? or is there any faster way to push this : >>array one pos foreward ?? : If you want to stick with arrays you'll have to live with it, insertion : is simply an inefficient operation on an array. To do better you'll have : to use a different type of datastructure. : >Most people I know would use memmove (or memcpy -- I never remember which : >one is able to check for conflicts and handle this case). However, I'm : >not certain it's portable to all systems. : Yes, it is. : >If there's padding between : >array elements, you have some potential for problems with memmove. : An impelemenattion is not permitted to pad between array elements. : -- : ----------------------------------------- : Lawrence Kirby | fred@genesis.demon.co.uk : Wilts, England | 70734.126@compuserve.com : ----------------------------------------- classic theory of sorting divide algorithms into two related types, a) primary leaf internal b) external secondary etc. sorts here discussed are primary, leaf, internal ... use of block move instruction(s) in primary sort coupled with simple ( array ) data-structure(s) is an effective method ... and provides very fast results ... ( on modern systems ) ... ( e.g. pc s manufactured >1989 generally incorporate very effective dma ... ) classic computation and algorithm theory generally rest on a vonneumann model whereby memory transactions 'shuffle' through cpu ... modern methods allow dispacing such to 'intelligent' memory subsystem ... which acts similarly as a peripheral ... therefore actual system design allows algorithms which might seem very inefficient ( by classic model ) to be renovated into algorithms which are very effective ! -- Ralph Silverman z007400b@bcfreenet.seflin.lib.fl.us