Click here to Skip to main content
16,016,157 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralA Prayer for Archimedes Pin
Bassam Abdul-Baki10-Oct-07 6:44
professionalBassam Abdul-Baki10-Oct-07 6:44 
GeneralRe: A Prayer for Archimedes Pin
IdUnknown10-Oct-07 7:16
IdUnknown10-Oct-07 7:16 
GeneralRe: A Prayer for Archimedes Pin
Bassam Abdul-Baki10-Oct-07 7:26
professionalBassam Abdul-Baki10-Oct-07 7:26 
Questionfill memory with a pattern Pin
DQNOK10-Oct-07 5:21
professionalDQNOK10-Oct-07 5:21 
AnswerRe: fill memory with a pattern Pin
DQNOK11-Oct-07 7:35
professionalDQNOK11-Oct-07 7:35 
AnswerRe: fill memory with a pattern Pin
Alan Balkany24-Oct-07 4:13
Alan Balkany24-Oct-07 4:13 
GeneralRe: fill memory with a pattern Pin
DQNOK24-Oct-07 10:33
professionalDQNOK24-Oct-07 10:33 
GeneralRe: fill memory with a pattern Pin
DQNOK25-Oct-07 3:41
professionalDQNOK25-Oct-07 3:41 
After thinking a bit more about it, I realized the stuff about the GPF is probably not correct. It would just copy garbage.

As I think thru things, I try to document them so I (or someone else) won't come back later on and try to improve on the code without throughly thinking things thru. Based on your suggestion, I've added the following comments to my memoryFill() function.

void memoryFill( void* target, char* pattern, size_t ptrnlen, size_t numRepeats )
{  
   char* trgt = (char*)target;  //for ease in pointer manipulation.   
   ...
   //
   // If we KNEW that memcpy copied from the base of the src array to the base
   // of the target array, we could write an EXTREMELY fast algorithm:
   //    memcpy( trgt, pattern, ptrnlen );                     //put one copy at the base.
   //    memcpy( trgt+ptrnlen, trgt, ptrnlen*(numRepeats-1) ); //destructive copy the rest
   // Conversely, if we KNEW that memcpy copied from the end of the src array 
   // to the end of the target array, we could write:
   //    memcpy( trgt+ptrnlen*(numRepeats-1) , pattern, ptrnlen ); //put one copy at the end.
   //    memcpy( trgt, trgt+ptrnlen, ptrnlen*(numRepeats-1) );     //destructive copy the rest
   // However, the C standard distinctly says that memcpy can do it's copying
   // in whatever order it wants.  We CANNOT rely on any specific order.
   //
   ...
}

David
QuestionAlgorithm to check how different are two files? Pin
bosfan9-Oct-07 22:01
bosfan9-Oct-07 22:01 
AnswerRe: Algorithm to check how different are two files? Pin
cp98769-Oct-07 22:56
cp98769-Oct-07 22:56 
GeneralRe: Algorithm to check how different are two files? Pin
bosfan9-Oct-07 23:18
bosfan9-Oct-07 23:18 
AnswerRe: Algorithm to check how different are two files? Pin
ScottM111-Oct-07 2:07
ScottM111-Oct-07 2:07 
GeneralRe: Algorithm to check how different are two files? Pin
ChandraRam11-Oct-07 2:25
ChandraRam11-Oct-07 2:25 
GeneralRe: Algorithm to check how different are two files? Pin
ScottM124-Oct-07 3:59
ScottM124-Oct-07 3:59 
AnswerRe: Algorithm to check how different are two files? Pin
chandu00413-Oct-07 0:30
chandu00413-Oct-07 0:30 
AnswerRe: Algorithm to check how different are two files? Pin
Gesown16-Oct-07 6:20
professionalGesown16-Oct-07 6:20 
Questiongenetic algorithms for image generation? Pin
Juraj Borza9-Oct-07 9:56
Juraj Borza9-Oct-07 9:56 
AnswerRe: genetic algorithms for image generation? Pin
Stan F. Form13-Oct-07 3:16
Stan F. Form13-Oct-07 3:16 
AnswerRe: genetic algorithms for image generation? Pin
Marshall15-Oct-07 9:26
Marshall15-Oct-07 9:26 
AnswerRe: genetic algorithms for image generation? Pin
Alan Balkany24-Oct-07 4:24
Alan Balkany24-Oct-07 4:24 
QuestionA simple question Pin
Ennis Ray Lynch, Jr.9-Oct-07 3:53
Ennis Ray Lynch, Jr.9-Oct-07 3:53 
AnswerRe: A simple question Pin
El Corazon9-Oct-07 4:47
El Corazon9-Oct-07 4:47 
GeneralRe: A simple question Pin
Ennis Ray Lynch, Jr.9-Oct-07 5:23
Ennis Ray Lynch, Jr.9-Oct-07 5:23 
GeneralRe: A simple question Pin
El Corazon9-Oct-07 5:25
El Corazon9-Oct-07 5:25 
GeneralThus my question Pin
Ennis Ray Lynch, Jr.9-Oct-07 7:11
Ennis Ray Lynch, Jr.9-Oct-07 7:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.