Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

inference_engine.cc

Go to the documentation of this file.
00001 // Inference Engine Basics implementation -*- C++ -*-
00002 
00003 // Copyright (C) 2001-2003 Hermann Schichl
00004 //
00005 // This file is part of the COCONUT API.  This library
00006 // is free software; you can redistribute it and/or modify it under the
00007 // terms of the Library GNU General Public License as published by the
00008 // Free Software Foundation; either version 2, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // Library GNU General Public License for more details.
00015 
00016 // As a special exception, you may use this file as part of a free software
00017 // library without restriction.  Specifically, if other files instantiate
00018 // templates or use macros or inline functions from this file, or you compile
00019 // this file and link it with other files to produce an executable, this
00020 // file does not by itself cause the resulting executable to be covered by
00021 // the Library GNU General Public License.  This exception does not however
00022 // invalidate any other reasons why the executable file might be covered by
00023 // the Library GNU General Public License.
00024 
00027 #include <inference_engine.h>
00028 #include <print_seq.h>
00029 
00030 void inference_engine::__prep_delta_list()
00031 {
00032   if(!_new_deltas.empty())
00033     _new_deltas.erase(_new_deltas.begin(), _new_deltas.end());
00034   _new_deltas.reserve((*__wnode)->deltas.size());
00035   std::copy((*__wnode)->deltas.begin(), (*__wnode)->deltas.end(),
00036       _new_deltas.end());
00037   if(!_new_deltas.empty())
00038     std::sort(_new_deltas.begin(), _new_deltas.end());
00039 }
00040 
00041 std::pair<std::list<delta_id>,std::list<delta_id> > inference_engine::new_deltas()
00042 {
00043   std::list<delta_id> _app, _unapp;
00044   std::vector<delta_id>::const_iterator _o, _n, _eo, _en;
00045   
00046   _eo = _old_deltas.end();
00047   _en = _new_deltas.end();
00048   
00049   _o = _old_deltas.begin();
00050   _n = _new_deltas.begin();
00051   
00052   while(_o != _eo && _n != _en)
00053   {
00054     if(_o == _eo)
00055     {
00056       _app.push_back(*_n);
00057       ++_n;
00058     }
00059     else if(_n == _en)
00060     {
00061       _unapp.push_back(*_o);
00062       ++_o;
00063     }
00064     else if(*_o < *_n) // o needs to be unapplied
00065     {
00066       _unapp.push_back(*_o);
00067       ++_o;
00068     }
00069     else if(*_o > *_n) // n needs to be applied
00070     {
00071       _app.push_back(*_n);
00072       ++_n;
00073     }
00074     else // _o == _n
00075     {
00076       ++_o;
00077       ++_n;
00078     }
00079   }
00080 
00081   return std::make_pair(_app,_unapp);
00082 }

Generated on Tue Nov 4 01:57:57 2003 for COCONUT API by doxygen1.2.18