infinitenothing Posted September 17, 2021 Report Share Posted September 17, 2021 Can you rank these three options? Specifically, I'm looking at what are the best options for avoiding mem copies of the string. Is the "swap value" primitive buying me anything? Quote Link to comment
hooovahh Posted September 20, 2021 Report Share Posted September 20, 2021 Is it ever conceivable that there will be more than two Queues to monitor? If so then the last one would scale up better. That being said it isn't the one I'd find myself using, just because the other two are much more readable. I'd probably go with the first one. Swap values is pretty handy when you actually need to swap two values. Here you aren't really using one of the values. From a memory or speed perspective I bet you can't measure the small amount of difference (if any) that is taking place. 1 Quote Link to comment
Neil Pate Posted September 21, 2021 Report Share Posted September 21, 2021 I would definitely not use a Swap Values here as it just makes the code confusing. Of the three I think the top is the most natural (but there is something about the inner dequeue which does not sit well with me). 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.