- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I think this topic might be listed now.
Admin
There are 3 replies in the summary.
Your post is post 8
I got alerted for 1 OP, then later for 6 other posts (including yours).
Let's read the article now.
Admin
Do we have to?
Sigh... ok...
Ok, this actually strikes close to home. I have done something similar recently. It's not a tree, but...
Yeah... that thing is on refactor schedule for next week.
Admin
Sooo... the WTF is that neither of the coders know what
var
does?Admin
No, TRWTF is not making a specialized class for tree that would allow for 100x better code. It's like initiating HTTP download using raw sockets.
Admin
Admin
// It enters the collection and checks the nodeLevel // or else it gets the hose again...
Admin
A dictionary of dictionaries of lists… :mask:
Admin
So TRWTF is the emphasis that is placed upon the filler words in the comments, which makes it sound like a reading from the King James Bible? Why would anybody do that?
Admin
So the text and samples are TRWTF. The structure is not being (used as) a tree, and the code is not determining if something is a leaf...
But is seems the intent was that Specializing a Generic with a Specialized Generic was intended to be the WTF, and here I disagree.
One could use pinning classes, or specialized interfaces (or both), or a number of other techniques, but these really CHANGE the readability/maintainability; in some use cases improving it, in others causing degradation - so a global assertion of one being better (or another being a WTF) is not appropriate.
Admin
Wow, I hope I'm being trolled, but I'll fall for it...
And there's your answer. The article page is just using the wrong syntax highlighter. Though if you know of an editor that allows arbitrary rich text in comments, kindly keep it the hell away from my code.
Admin
well it's better than this one that i ran across the last time i was in C:
yes. that's a pointer to a pointer to a pointer to a pointer to an array of arrays of type unsigned int.
it was every bit as bad as it sounds
Admin
Admin
Ok I'll bite.
What on earth did they use that monstrosity for????
Admin
it was ten years ago and i don't have the surce code, just random snippits from my "ohGoddessNo.txt" file where i make note of some o fthe worst examples of code i've ever seen
According to my notes it was used for keeping track of weighted movesets (the unsigned
int[][] part
) as they were processed through a multilevel selection algorithm to determine which task to execute next.Admin
It's the men's razor of C declarations.
http://www.theonion.com/blogpost/fuck-everything-were-doing-five-blades-11056
Admin
You mistyped suck code
Admin
it was that too.
Admin
I had to do this once:
Because
cudaMallocHosts
takes a pointer to a pointer.Now it's not too unreasonable to think someone could need a 2D-array of such memory areas:
You might one day want to pass this by pointer, so that you can reallocate the structure:
And while you're at it, why limit yourself to just one such entity?
You can even make it into a 2D-array again!
Admin
I don't get why there's a dictionary containing the dictionaries.
The level thing adds complexity that can only break your three's logic.
He's checking if the node exists on the next level to determine if it is a leaf?
How about just checking to see if the node has any children? Get the list from the dictionary against the node. List empty? Then leaf.
But but... but.... how do you find the root?
You add a single member that designates the root.
???
Unless, for some odd reason, an element can exist in two levels in the tree?
I mean, if you're going to take potshots at complex multi-tiered generics, then you need to ask yourself why you think linq is a bad thing.
Admin
In the context of the article, I agree.....however a dictionary of dictionaries is actually quite common.....just think of a compound key....
Admin
That's not legal C. You probably had something more like this:
which is how you get a pointer to a pointer to a pointer to a pointer to an array 10 of array of
unsigned int
. Note that only the outermost array can have an unspecified size, all others must be compile-time constants.Admin
I remember working on client-server software that was trying to pass a large amount of data. But the developers on the client side would complain that their data wasn't getting across.
I looked at what they were passing and it was only a few bytes.
They passed a pointer to data.
Admin
going from memory. i may have messed up the type signature.
either way that's still pretty bad.
Admin
I thought I was going a little insane, then I realized that I don't get the "fancy" code highlighting because my company blocks yandex.st One of these days that CSS file will be hosted instead of hotlinked...
Admin
ThatIsTheJoke.jpg
Admin
you're welcome.
:-P
Admin
What's wrong with a partially-jagged 6-dimensional array?
<!-- :trolleybus: -->Admin
well if you want to look at it that way, it was a jagged 6 dimensional array where the first four dimensions were constrained to only have one element. (it genuinely was a chain of pointers to a two dimensional array)
Admin
Word? :badger:
Admin
Compound keys? That would still be a single-level
Dictionary<TKey,TValue>
, but with a customIEqualityComparer<TKey>
that performs the correct comparison for the compound keys held inTKey
instances...Admin
Yes, globally defining a new kind of equality for a key type makes a lot more sense than just having a dictionary of dictionaries. Because, you know, the key types never have their own kind of equality.
This article only goes to show that what.tdwtf.com is TRWTF.
Admin
The comparer is an explicitly separate class that can be passed in as a parameter to the dictionary instance you are constructing. Outside of the fact that it's stored in a separate class, there's nothing 'global' about it as long as you aren't talking about a type's default comparer.
If you don't like having separate classes hanging around for comparers, you can make them private nested classes of whatever class is holding your dictionary and keep them together and hidden from outside code that way.
Or you can write a generic, re-usable
IEqualityComparer<T>
implementation that takes aFunc<T, T, bool>
to perform the actual comparison and thusly achieve anonymous inline comparers defined using lambda delegates. E.g.Admin
If you TKey was then a compound field, that would also "work", but there are many advantages to using nested Dictionaries from a performance and scalability issue. Part of it is parallization (with TPC or async/await) as wee as differences in the number of detailed compares that must be done...and I will not even get into the difference on GC, pipelines and the cache
Admin
Wrong. Or at least I really hope you're wrong. :) The largest depth of such things that I've seen in the wild has been 3; after that, it gets too brain-bending to be maintainable.
Admin
That seems to be the highest here too - an array of pointers to string, returned by reference. Also the address of a next pointer, passed and returned by reference.
Admin
Without citation and proof of such performance issues existing, I'm going to lean in favor of the so-visible-it-might-as-well-be-smacking-you-in-the-face-with-a-baceball-bat readability and thus maintainance advantages.
I seriously doubt the performance on nested dictionaries will be any better than on a single dictionary. The dictionary type internally switches internal array sizes up by prime number size and uses a hash table representations and lookup optimized to keep itself to the asymptotic complexity required for O(1) lookups. Any level of manual interference with those procedures (e.g. by breaking the actual lookup structure up into something else) is far, far more likely to make things worse than better: consuming more unusued memory on more reserved-but-empty slots in the internal array space; triggering more jumps in the inner reserved array space when keys are added or removed; memory more quickly fragmented; more strain on the GC; etc.
Admin
When I have to do that sort of thing, I use 2 as my prime number. Which sounds like a much worse idea than it is in practice. But then I've only run a set of different hashing algorithms against production code and measured the performance differences. Short summary: keeping it simple is a win in the real world, not because it makes much difference to runtime — it hardly makes any measurable difference at all — but because simpler code is generally a better plan if you want to keep things working well. :smile:
Admin
"Save the fancy algorithms for when it actually matters."
Admin
What do you wish to tell it?
care chastity belt (bdsm)
Admin
Absolutely casual concurrence
circumspection spank girlfriend
Admin
http://alexisldtj33221.tribunablog.com/100-19976708 рамки вебка онлайн бесплатно http://erickxnco55421.thezenweb.com/--41742135 играть бесплатно вебкам той https://gregoryqizq76654.tokka-blog.com/7509828/как-1-2-3 фоторамки онлайн бесплатно вебкой https://edgargwky98765.estate-blog.com/8701896/как-1-2-3 бесплатный сайт по вебке девушка по вебке бесплатно бесплатно видеочат по вебке секс о вебке бесплатно
https://brol3.com
Admin
Hello! I could have sworn I've been to this site before but after checking through some of the post I realized it's new to me. Anyhow, I'm definitely happy I found it and I'll be book-marking and checking back frequently! aid for ukraine
Admin
I could not refrain from commenting. Well written! help refuges