- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# /Users/fpy/titan-1-5-MBARI/Mers/Solvers/SAT/ISAT/ISATPropositions.cpp

    00001 //========================================================================================
    00002 //
    00003 // Copyright (c) 2001           Model-based Embedded and Robotic Systems Group
    00004 // All Rights Reserved          Massachusetts Institute of Technology
    00005 //
    00006 // This software is provided as is. Model-based Embedded and Robotic Systems (MERS) group
    00007 // does not assume any responsibility.
    00008 //
    00009 // Author:                      Seung H. Chung
    00010 //
    00011 // Organization:        Model-based Embedded and Robotic Systems Group
    00012 //                                      Massachusetts Institute of Technology
    00013 //
    00014 // File:                        ISATPropositions.cpp
    00015 //
    00016 // Description:         Circularly linked list of proposition pointers. It follows the C++
    00017 //                                      Standard Template Library specifications.
    00018 //
    00019 //========================================================================================
    00020
    00021 #include "ISATPropositions.h"
    00022
    00023 #include <cstdio>
    00024 #include <cassert>
    00025 #include "ISATProposition.h"
    00026
    00028
    00029 using namespace Mers::Solvers::SAT::ISAT;
    00030 using std::ostream;
    00031 using std::list;
    00032
    00034 // Public Constructors, Copy Constructors, & Destructors
    00036
    00037 ISATPropositions::ISATPropositions()
    00038 {
    00039 }
    00040
    00041 ISATPropositions::ISATPropositions(ISATPropositions const &other)
    00042 : list<ISATProposition *>(other)
    00043 {
    00044         for (const_iterator it = other.begin(); it != other.end(); it++)
    00045         {
    00046                 push_back(*it);
    00047         }
    00048 }
    00049
    00050 ISATPropositions::~ISATPropositions()
    00051 {
    00052 }
    00053
    00054 //----------------------------------------------------------------------------------------
    00055 // Public Function Members
    00056 //----------------------------------------------------------------------------------------
    00057
    00058 bool
    00059 ISATPropositions::is_empty() const
    00060 {
    00061         return list<ISATProposition *>::empty();
    00062 }
    00063
    00064 int
    00065 ISATPropositions::get_size() const
    00066 {
    00067         return size();
    00068 }
    00069
    00070 ISATProposition *
    00071 ISATPropositions::get_front() const
    00072 {
    00073         return list<ISATProposition *>::front();
    00074 }
    00075
    00076 void
    00077 ISATPropositions::push_front(ISATProposition *proposition_p)
    00078 {
    00079         list<ISATProposition *>::push_front(proposition_p);
    00080         return;
    00081 }
    00082
    00083 void
    00084 ISATPropositions::pop_front()
    00085 {
    00086         list<ISATProposition *>::pop_front();
    00087         return;
    00088 }
    00089
    00090 void
    00091 ISATPropositions::remove_proposition(ISATProposition *proposition_p)
    00092 {
    00093         for (iterator it = begin(); it != end(); it++)
    00094         {
    00095                 if (*it == proposition_p)
    00096                 {
    00097                         erase(it);
    00098                         return;
    00099                 }
    00100         }
    00101 }
    00102 //----------------------------------------------------------------------------------------
    00103 // Public Operators
    00104 //----------------------------------------------------------------------------------------
    00105
    00106 ISATPropositions const &
    00107 ISATPropositions::operator =(ISATPropositions const &other)
    00108 {
    00109         if (this != &other)
    00110         {
    00111                 clear();
    00112                 for (const_iterator it = other.begin(); it != other.end(); it++)
    00113                 {
    00114                         push_back(*it);
    00115                 }
    00116         }
    00117         return (*this);
    00118 }
    00119
    00120 ISATPropositions const &
    00121 ISATPropositions::operator +=(ISATProposition &proposition)
    00122 {
    00123         push_back(&proposition);
    00124         return (*this);
    00125 }
    00126
    00127 ISATPropositions const &
    00128 ISATPropositions::operator +=(ISATPropositions const &other)
    00129 {
    00130         if (this != &other)
    00131         {
    00132                 for (const_iterator it = other.begin(); it != other.end(); it++)
    00133                 {
    00134                         push_back(*it);
    00135                 }
    00136         }
    00137         return (*this);
    00138 }
    00139
    00140 namespace Mers {
    00141         namespace Solvers {
    00142                 namespace SAT {
    00143                         namespace ISAT {
    00144
    00145                                 ostream &
    00146                                 operator <<(ostream &stream, ISATPropositions const &propositions)
    00147                                 {
    00148                                         stream << "(";
    00149                                         ISATPropositions::const_iterator const_it = propositions.begin();
    00150                                         if (const_it != propositions.end())
    00151                                         {
    00152                                                 stream << **const_it;
    00153                                                 const_it++;
    00154                                                 while (const_it != propositions.end())
    00155                                                 {
    00156                                                         stream << " " << **const_it;
    00157                                                         const_it++;
    00158                                                 }
    00159                                         }
    00160                                         stream << ")";
    00161                                         return stream;
    00162                                 }
    00163                         }
    00164                 }
    00165         }
    00166 }
    00167