Click here to Skip to main content
15,887,214 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: What use are foreign keys anyway? Pin
Richard Deeming20-Feb-18 2:42
mveRichard Deeming20-Feb-18 2:42 
GeneralRe: What use are foreign keys anyway? Pin
kmoorevs23-Feb-18 5:43
kmoorevs23-Feb-18 5:43 
GeneralRe: What use are foreign keys anyway? Pin
Rob Grainger27-Feb-18 23:20
Rob Grainger27-Feb-18 23:20 
GeneralRe: What use are foreign keys anyway? Pin
TheGreatAndPowerfulOz5-Mar-18 8:47
TheGreatAndPowerfulOz5-Mar-18 8:47 
GeneralRe: What use are foreign keys anyway? Pin
HarvestMoon000010-Mar-18 7:02
HarvestMoon000010-Mar-18 7:02 
GeneralConcurrentQueue & FirstOrDefault() and search speed. Pin
raddevus5-Feb-18 10:28
mvaraddevus5-Feb-18 10:28 
GeneralRe: ConcurrentQueue & FirstOrDefault() and search speed. Pin
Eddy Vluggen6-Feb-18 1:02
professionalEddy Vluggen6-Feb-18 1:02 
GeneralRe: ConcurrentQueue & FirstOrDefault() and search speed. Pin
Richard Deeming6-Feb-18 2:46
mveRichard Deeming6-Feb-18 2:46 
Not particularly surprising, given the amount of work it's doing. Smile | :)
Reference Source: ConcurrentQueue.cs[^]

It looks like it's implemented as a singly linked list of small arrays (32 items each). Searching a linked list for the last item, or for an item that doesn't exist, is always going to take longer than finding an item close to the start.

It also seems that the order of searches has some effect. Try searching for 1st followed by 31st; then try 31st followed by 1st.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: ConcurrentQueue & FirstOrDefault() and search speed. Pin
raddevus6-Feb-18 5:41
mvaraddevus6-Feb-18 5:41 
GeneralRe: ConcurrentQueue & FirstOrDefault() and search speed. Pin
Kornfeld Eliyahu Peter6-Feb-18 3:37
professionalKornfeld Eliyahu Peter6-Feb-18 3:37 
GeneralRe: ConcurrentQueue & FirstOrDefault() and search speed. Pin
raddevus6-Feb-18 5:37
mvaraddevus6-Feb-18 5:37 
GeneralRe: ConcurrentQueue & FirstOrDefault() and search speed. Pin
Richard Deeming6-Feb-18 10:11
mveRichard Deeming6-Feb-18 10:11 
GeneralRe: ConcurrentQueue & FirstOrDefault() and search speed. Pin
raddevus6-Feb-18 10:19
mvaraddevus6-Feb-18 10:19 
GeneralRe: ConcurrentQueue & FirstOrDefault() and search speed. Pin
Jörgen Andersson9-Feb-18 2:02
professionalJörgen Andersson9-Feb-18 2:02 
GeneralRe: ConcurrentQueue & FirstOrDefault() and search speed. Pin
raddevus9-Feb-18 4:16
mvaraddevus9-Feb-18 4:16 
GeneralRe: ConcurrentQueue & FirstOrDefault() and search speed. Pin
Richard Deeming9-Feb-18 4:47
mveRichard Deeming9-Feb-18 4:47 
GeneralRe: ConcurrentQueue & FirstOrDefault() and search speed. Pin
raddevus9-Feb-18 8:31
mvaraddevus9-Feb-18 8:31 
GeneralRe: ConcurrentQueue & FirstOrDefault() and search speed. Pin
Richard Deeming12-Feb-18 8:19
mveRichard Deeming12-Feb-18 8:19 
GeneralRe: ConcurrentQueue & FirstOrDefault() and search speed. Pin
Jörgen Andersson9-Feb-18 6:09
professionalJörgen Andersson9-Feb-18 6:09 
GeneralRe: ConcurrentQueue & FirstOrDefault() and search speed. Pin
patbob19-Feb-18 5:42
patbob19-Feb-18 5:42 
Generalsql maths Pin
kmoorevs27-Jan-18 7:17
kmoorevs27-Jan-18 7:17 
GeneralRe: sql maths Pin
RedDk28-Jan-18 11:12
RedDk28-Jan-18 11:12 
GeneralRe: sql maths Pin
kmoorevs29-Jan-18 2:53
kmoorevs29-Jan-18 2:53 
GeneralRe: sql maths Pin
Tomz_KV29-Jan-18 5:43
Tomz_KV29-Jan-18 5:43 
GeneralRe: sql maths Pin
kmoorevs29-Jan-18 5:52
kmoorevs29-Jan-18 5:52 

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.