splitse.hh

00001 // Copyright (C) 2001, 2002, 2004  EPITA Research and Development Laboratory
00002 //
00003 // This file is part of the Olena Library.  This library is free
00004 // software; you can redistribute it and/or modify it under the terms
00005 // of the GNU General Public License version 2 as published by the
00006 // Free Software Foundation.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this library; see the file COPYING.  If not, write to
00015 // the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
00016 // MA 02111-1307, USA.
00017 //
00018 // As a special exception, you may use this file as part of a free
00019 // software library without restriction.  Specifically, if other files
00020 // instantiate templates or use macros or inline functions from this
00021 // file, or you compile this file and link it with other files to
00022 // produce an executable, this file does not by itself cause the
00023 // resulting executable to be covered by the GNU General Public
00024 // License.  This exception does not however invalidate any other
00025 // reasons why the executable file might be covered by the GNU General
00026 // Public License.
00027 
00028 #ifndef OLENA_MORPHO_SPLITSE_HH
00029 # define OLENA_MORPHO_SPLITSE_HH
00030 
00031 # include <oln/basics.hh>
00032 
00033 namespace oln {
00034   namespace morpho {
00035 
00048     template<class E>
00049     mlc_exact_type(E)
00050       get_plus_se_only(const abstract::struct_elt<E>& se)
00051     {
00052       oln_iter_type(E) dp(se);
00053       E out;
00054 
00055       for_all (dp)
00056         {
00057           unsigned n;
00058           for (n = 0; n < E::dim; ++n)
00059             if (dp.cur().nth(n) < 0) {
00060               out.add(dp);
00061               break;
00062             } else if (dp.cur().nth(n) > 0) {
00063               break;
00064             }
00065         }
00066       return out;
00067     }
00068 
00082     template<class E>
00083     mlc_exact_type(E)
00084       get_plus_se_p(const abstract::struct_elt<E>& se)
00085     {
00086       oln_iter_type(E) dp(se);
00087       E out;
00088 
00089       for_all (dp)
00090         {
00091           unsigned n;
00092           for (n = 0; n < E::dim; ++n)
00093             if (dp.cur().nth(n) < 0) {
00094               out.add(dp);
00095               break;
00096             } else if (dp.cur().nth(n) > 0) {
00097               break;
00098             }
00099           // All p.nth(n) are 0.
00100           if (n == E::dim)
00101             out.add(dp);
00102         }
00103       return out;
00104     }
00105 
00118     template<class E>
00119     mlc_exact_type(E)
00120       get_minus_se_only(const abstract::struct_elt<E>& se)
00121     {
00122       oln_iter_type(E) dp(se);
00123       E out;
00124 
00125       for_all (dp)
00126         {
00127           unsigned n;
00128           for (n = 0; n < E::dim; ++n)
00129             if (dp.cur().nth(n) > 0) {
00130               out.add(dp);
00131               break;
00132             } else if (dp.cur().nth(n) < 0) {
00133               break;
00134             }
00135         }
00136       return out;
00137     }
00138 
00152     template<class E>
00153     mlc_exact_type(E)
00154       get_minus_se_p(const abstract::struct_elt<E>& se)
00155     {
00156       oln_iter_type(E) dp(se);
00157       E out;
00158 
00159       for_all (dp)
00160         {
00161           unsigned n;
00162           for (n = 0; n < E::dim; ++n)
00163             if (dp.cur().nth(n) > 0) {
00164               out.add(dp);
00165               break;
00166             } else if (dp.cur().nth(n) < 0) {
00167               break;
00168             }
00169           // All p.nth(n) are 0.
00170           if (n == E::dim)
00171             out.add(dp);
00172         }
00173       return out;
00174     }
00175 
00176   } // morpho
00177 } // oln
00178 
00179 #endif // OLENA_MORPHO_SPLITSE_HH

Generated on Thu Apr 15 20:13:14 2004 for Olena by doxygen 1.3.6-20040222