Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

foreache

Name: Anonymous 2014-01-20 18:58

what is you're opinion on foreache loops?

i don't like em cuz they ache in the fore

Name: Anonymous 2014-01-24 3:07

>>149
I mean the following: I give you a set of structures and/or algorithms. I then say ``This collection of structures and algorithms is a list''. You then use them as a list.

If the set of structures and/or algorithms I gave you is actually a linked list, and you used them in a sort of average-y, amortized-y manner of all uses of a list (not a linked list), unaware that the implementation is a linked list, you'll probably conclude that I have given you a pretty crappy list. Addition and deletion require individual memory allocation/deallocation calls, seeking in the list is linear, etc. I can try to make that list a little better by making changes to it while retaining the basic concept of a linked list, but it's still going to be a pretty terrible list, as you have completely picked up upon and pointed out. My claim is ``it's still going to be better than Sglist, assuming somebody is holding a gun to the author's head and demanding that he use linked list-ish things as his implementation''.

Frankly, I would say that a plain linked list is terrible as a basis for a tree as well (for one thing, how do you get a list of all children of a node without tacking on other bits that are likely to be O(n)?), and I don't want to touch the ``infinite sequences'' statement, but as a queue, they are a serviceable implementation.

>>150
For your reference, Sglib stands for ``Simple Generic Library''. It is on this basis (specifically the ``generic'' part) that I evaluate (and reject) the algorithms it offers, specifically SGLIB_LIST_LEN. When given a circular list, for example, SGLIB_LIST_LEN will enter an infinite loop, mindlessly dereferencing next->next->next->next->... pointers for eternity.

To clarify on the first point above, Sglib offers algorithms that work on any (reasonable) data structure. So what could actually happen is that I could write a skiplist structure and apply the algorithms Sglib offers. But because of the disconnect between the way Sglib is written and my data structure*, I would see no benefit of anything I have put into my data structure. Sglib simply treats any list as a dumb linked list.

* Actually, this whole discussion started out as a few other people discussing macros, right? Sglib offers all of its algorithms in the form of macros. That's the gimmick.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List