• (disco)

    I think this topic might be listed now.

  • (disco) in reply to Onyx

    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.

  • (disco) in reply to PleegWat
    PleegWat:
    Let's read the article now.

    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...

    QHash<QString, QHash<QString, QMultiHash<QString, QTcpSocket*> > > requestSockets;
    

    Yeah... that thing is on refactor schedule for next week.

  • (disco)

    Sooo... the WTF is that neither of the coders know what var does?

  • (disco) in reply to Maciejasjmj

    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.

  • (disco) in reply to Gaska
    Gaska:
    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.
    ((wide-eyed-innocent-naif))Well, the HTTP download library must be doing that deep inside, so why not cut out the middleman?((/wide-eyed-innocent-naif))
  • (disco)

    // It enters the collection and checks the nodeLevel // or else it gets the hose again...

  • (disco)

    A dictionary of dictionaries of lists… :mask:

  • (disco)

    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?

  • (disco)

    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.

  • (disco) in reply to Matt_Westwood
    Matt_Westwood:
    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?

    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.

  • (disco) in reply to RaceProUK
    RaceProUK:
    A dictionary of dictionaries of lists…

    well it's better than this one that i ran across the last time i was in C:

    unsigned int[][]**** 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

  • (disco) in reply to accalia
    accalia:
    pointer to a pointer to a pointer to a pointer to an array of arrays
    :mask:
  • (disco) in reply to accalia

    Ok I'll bite.

    What on earth did they use that monstrosity for????

  • (disco) in reply to Yazeran
    Yazeran:
    What on earth did they use that monstrosity for????

    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.

  • (disco) in reply to accalia

    It's the men's razor of C declarations.

    http://www.theonion.com/blogpost/fuck-everything-were-doing-five-blades-11056

  • (disco) in reply to accalia
    accalia:
    surce code

    You mistyped suck code

  • (disco) in reply to Luhmann
    Luhmann:
    You mistyped suck code

    it was that too.

  • (disco) in reply to accalia
    accalia:
    yes. that's a pointer to a pointer to a pointer to a pointer to an array of arrays of type unsigned int.

    I had to do this once:

    void initHostMatrices (float*** f, int matrixSize) // an array of references to pointers
    

    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:

    void initHostMatrices (float**** f, int matrixSize) // a 2D-array of references to pointers
    

    You might one day want to pass this by pointer, so that you can reallocate the structure:

    void initHostMatrices (float***** f, int matrixSize) // a reference to a 2D-array of references to pointers
    

    And while you're at it, why limit yourself to just one such entity?

    void initHostMatrices (float****** f, int matrixSize) // an array of references to 2D-arrays of references to pointers
    

    You can even make it into a 2D-array again!

    void initHostMatrices (float******* f, int matrixSize) // an 2D-array of references to 2D-arrays of references to pointers
    
  • (disco)

    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.

  • (disco) in reply to xaade
    xaade:
    I don't get why there's a dictionary containing the dictionaries.

    In the context of the article, I agree.....however a dictionary of dictionaries is actually quite common.....just think of a compound key....

  • (disco) in reply to accalia
    accalia:
    `unsigned int[][]**** c;`

    That's not legal C. You probably had something more like this:

    unsigned int (****c)[10][]
    

    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.

  • (disco) in reply to Protoman

    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.

  • (disco) in reply to Protoman
    Protoman:
    That's not legal C.

    going from memory. i may have messed up the type signature.

    either way that's still pretty bad.

  • (disco) in reply to Matt_Westwood
    Matt_Westwood:
    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?
    Greywolf02:
    // It enters **the** collection **and** checks **the** nodeLevel // or else it gets **the** hose again...

    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...

  • (disco) in reply to accalia

    ThatIsTheJoke.jpg

  • (disco) in reply to Luhmann
    Luhmann:
    ThatIsTheJoke.jpg

    you're welcome.

    :-P

  • (disco) in reply to accalia
    accalia:
    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

    What's wrong with a partially-jagged 6-dimensional array?

    <!-- :trolleybus: -->
  • (disco) in reply to FrostCat

    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)

  • (disco) in reply to narbat
    narbat:
    Though if you know of an editor that allows arbitrary rich text in comments

    Word? :badger:

  • (disco) in reply to narbat
    narbat:
    Though if you know of an editor that allows arbitrary rich text in comments
    C# explicitly requires you to support full unicode, which includes every control and formatting character offered by unicode. Also it allows characters from the 'Other, Format' category in its **identifiers**. Said category has nice stuff in it like RTL/LTR overrides or all manner of zero-width characters...
    TheCPUWizard:
    a dictionary of dictionaries is actually quite common.....just think of a compound key....

    Compound keys? That would still be a single-level Dictionary<TKey,TValue>, but with a custom IEqualityComparer<TKey> that performs the correct comparison for the compound keys held in TKey instances...

  • (disco) in reply to Ragnax

    Compound keys? That would still be a single-level Dictionary<TKey,TValue>, but with a custom IEqualityComparer<TKey> that performs the correct comparison for the compound keys held in TKey instances...

    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.

  • (disco) in reply to Captain
    Captain:
    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.

    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 a Func<T, T, bool> to perform the actual comparison and thusly achieve anonymous inline comparers defined using lambda delegates. E.g.

    var dictionary = new Dictionary<CompoundKey, object>(
      new DelegateEqualityComparer<CompoundKey>((a,b) => a.First.Equals(b.First) && a.Second.Equals(b.Second))
    );
    
  • (disco) in reply to Ragnax
    Ragnax:
    Compound keys? That would still be a single-level Dictionary<TKey,TValue>,

    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

  • (disco) in reply to Maciejasjmj
    Maciejasjmj:
    Now it's not too unreasonable to think someone could need a 2D-array of such memory areas:

    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.

  • (disco) in reply to dkf

    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.

  • (disco) in reply to TheCPUWizard
    TheCPUWizard:
    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

    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.

  • (disco) in reply to Ragnax
    Ragnax:
    switches internal array sizes up by prime number size

    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:

  • (disco) in reply to dkf
    dkf:
    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.

    "Save the fancy algorithms for when it actually matters."

  • TheresaTut (unregistered)

    What do you wish to tell it?

    care chastity belt (bdsm)

  • MarilynRexum (unregistered)

    Absolutely casual concurrence

    circumspection spank girlfriend

  • Eddiegah (unregistered)

    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

  • Oliva (unregistered)

    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

  • Enrique (unregistered)

    I could not refrain from commenting. Well written! help refuges

Leave a comment on “The Forest of Trees”

Log In or post as a guest

Replying to comment #:

« Return to Article