Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

memory usage

By: a guest on Mar 25th, 2011  |  syntax: C++  |  size: 1.16 KB  |  views: 59  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. vector<OBMol> molecules;
  2. OBMol mol;
  3. while (!feof(f)) {
  4.         fscanf(f, "%c %c", &type, &comment);
  5.                 if (type == comment)
  6.             continue;
  7.        
  8.         //molecule title and its frequency
  9.         if (type == 't') {
  10.             fscanf(f, "%256s %d\n", buffer, &frequency );
  11.             m.SetTitle(buffer);
  12.         }        
  13.        
  14.         //molecule nodes and edges
  15.         while (!feof(f)) {
  16.             fscanf(f, "%c", &type);
  17.             if (type == 'v' || type == 'V') {
  18.                 fscanf(f, "%d %256s\n", &v1, buffer);
  19.                 m.NewAtom(v1);    
  20.                
  21.                 //set atom type
  22.                 m.GetAtomById(v1)->SetType(buffer);    
  23.             }
  24.             else if (type == 'u' || type == 'U' ){
  25.                 fscanf(f, "%d %d %d\n", &v1, &v2, &order);
  26.                 m.AddBond(v1+1, v2+1, order);
  27.                 POS = ftell(f);
  28.             }
  29.             else if(type == 't') {
  30.                 //go back one line to get new molecule header
  31.                 fseek(f, POS, SEEK_SET);  
  32.                 molecules.push_back(m);
  33.                 break;
  34.             }
  35.         }
  36.         m.Clear();
  37.         }
  38. }