POV-Ray : Newsgroups : povray.unofficial.patches : Major bug in MegaPOV Plus? : Re: Major bug in MegaPOV Plus? Server Time
2 Sep 2024 08:17:22 EDT (-0400)
  Re: Major bug in MegaPOV Plus?  
From: Warp
Date: 8 Sep 2000 07:35:34
Message: <39b8cf06$1@news.povray.org>
Chris Huff <chr### [at] maccom> wrote:
: Why would I use code from someone else for something as simple as a 
: linked list or tree?

  A list is rather simple, but it's not unusual at all that you make mistakes
easily (memory leaks, reading freed memory...).
  A weighted binary tree IS NOT easy at all to do. You have to code quite a
lot to get one done. Why should I do it when it's already done. And done well.

  I always like to show in these cases this example I made:

#include <iostream>
#include <map>
#include <string>
using namespace std;
int main()
{ typedef map<string,unsigned> wlist_t;
  wlist_t words;
  string word;
  while(cin) { cin >> word; words[word]++; }
  for(wlist_t::iterator i=words.begin(); i!=words.end(); i++)
    cout << i->first << ": " << i->second << endl;
}


  It reads words from the standard input (a word is limited by whitespaces)
and then outputs an alphabetically ordered list of the words and a number
indicating the amount of times the word appears in the text.

  Try to make that without using any STL. It must be at least as fast as
this one.
  How many code lines do you need? How much time do you need to make it?

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.