Click here to Skip to main content
15,892,965 members
Home / Discussions / C#
   

C#

 
GeneralRe: Threads Pin
Matty2221-Jan-10 11:35
Matty2221-Jan-10 11:35 
AnswerRe: Threads Pin
Harvey Saayman20-Jan-10 19:40
Harvey Saayman20-Jan-10 19:40 
QuestionHow can I copy a multidimensional List Pin
leekangjae20-Jan-10 15:23
leekangjae20-Jan-10 15:23 
AnswerRe: How can I copy a multidimensional List Pin
Not Active20-Jan-10 15:39
mentorNot Active20-Jan-10 15:39 
GeneralRe: How can I copy a multidimensional List Pin
leekangjae20-Jan-10 17:41
leekangjae20-Jan-10 17:41 
AnswerRe: How can I copy a multidimensional List Pin
AspDotNetDev20-Jan-10 16:25
protectorAspDotNetDev20-Jan-10 16:25 
GeneralRe: How can I copy a multidimensional List Pin
Luc Pattyn20-Jan-10 16:51
sitebuilderLuc Pattyn20-Jan-10 16:51 
GeneralRe: How can I copy a multidimensional List Pin
AspDotNetDev20-Jan-10 17:08
protectorAspDotNetDev20-Jan-10 17:08 
Haha, very observant. I discuss that at the bottom of my article, SlimList. The instruction you are talking about is BSR (bit scan reverse). It checks for the number of consecutive zeros in the most significant bits, or something like that. Point is, it gets you a fast way to calculate the base-2 integer log. I didn't want SlimList to be platform-dependent, so I didn't go with BSR. Also, I didn't want the code to be confusing, so I didn't go with a binary search of the bits... rather, I went with Math.Log, because it was the most obvious.

Luc Pattyn wrote:
Why on earth would you create several arrays when you only need one?


To avoid having to reallocate an array twice the size of the original array and copy values over when the number of elements has exceeded the capacity of the original array (the common technique for creating a List structure). Doing so has the potential to slow things down due to excessive memory allocations and also has the down-side of having 3x the required memory (1x by the old array and 2x by the new array). With SlimList, the old arrays take up 1x memory and the new array takes up 1x memory, for a total of 2x memory during list expansion. And thanks to my use of Log to directly calculate the proper index, the indexing performance is still O(1) (though it could be argued that Log is not truly an O(1) operation, it could be implemented as such with an array to perform the lookup rather than perform the calculation, or in hardware, as the BSR instruction demonstrates, though both are moot points when you consider that you would have to use an n-bit number to perform the lookup anyway with either List or SlimList). Keep in mind that my article is mostly academic in nature. I created it to present a new data structure, not to provide a class that should be used out of the box (as it is implemented, it has some performance issues, which are discussed at the bottom of the article). If your code will only be used on x86 computers, perhaps you go with BSR. Or maybe you go with a different instruction on a different platform. But most of the time, the best choice is to just use .Net's List. Smile | :)


GeneralRe: How can I copy a multidimensional List Pin
AspDotNetDev20-Jan-10 17:10
protectorAspDotNetDev20-Jan-10 17:10 
GeneralRe: How can I copy a multidimensional List Pin
AspDotNetDev20-Jan-10 17:15
protectorAspDotNetDev20-Jan-10 17:15 
GeneralRe: How can I copy a multidimensional List Pin
Luc Pattyn20-Jan-10 17:47
sitebuilderLuc Pattyn20-Jan-10 17:47 
QuestionSimulate keypress Pin
Matt Cavanagh20-Jan-10 14:12
Matt Cavanagh20-Jan-10 14:12 
AnswerRe: Simulate keypress Pin
Bekjong20-Jan-10 16:07
Bekjong20-Jan-10 16:07 
QuestionProblem with AutoResetEvent Array and WaitHandle.WaitAll() Pin
FJJCENTU20-Jan-10 13:27
FJJCENTU20-Jan-10 13:27 
AnswerRe: Problem with AutoResetEvent Array and WaitHandle.WaitAll() Pin
Bekjong20-Jan-10 15:50
Bekjong20-Jan-10 15:50 
AnswerRe: Problem with AutoResetEvent Array and WaitHandle.WaitAll() Pin
Giorgi Dalakishvili20-Jan-10 19:17
mentorGiorgi Dalakishvili20-Jan-10 19:17 
QuestionManaged and Unmanaged code Pin
3bood.ghzawi20-Jan-10 13:03
3bood.ghzawi20-Jan-10 13:03 
AnswerRe: Managed and Unmanaged code Pin
Bekjong20-Jan-10 15:53
Bekjong20-Jan-10 15:53 
AnswerRe: Managed and Unmanaged code Pin
Abhinav S20-Jan-10 17:33
Abhinav S20-Jan-10 17:33 
QuestionDisplay highlighted data from Listbox in Textboxes Pin
CarlMartin1020-Jan-10 13:02
CarlMartin1020-Jan-10 13:02 
AnswerRe: Display highlighted data from Listbox in Textboxes Pin
Luc Pattyn20-Jan-10 13:27
sitebuilderLuc Pattyn20-Jan-10 13:27 
GeneralRe: Display highlighted data from Listbox in Textboxes Pin
CarlMartin1020-Jan-10 13:31
CarlMartin1020-Jan-10 13:31 
GeneralRe: Display highlighted data from Listbox in Textboxes Pin
Luc Pattyn20-Jan-10 13:37
sitebuilderLuc Pattyn20-Jan-10 13:37 
AnswerRe: Display highlighted data from Listbox in Textboxes Pin
Anthony Mushrow20-Jan-10 13:34
professionalAnthony Mushrow20-Jan-10 13:34 
GeneralRe: Display highlighted data from Listbox in Textboxes Pin
CarlMartin1020-Jan-10 13:37
CarlMartin1020-Jan-10 13:37 

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.