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

# /Users/fpy/titan-1-5-MBARI/Mers/Solvers/SAT/ISAT/ISATClauses.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:                        ISATClauses.cpp
    00015 //
    00016 // Description:         Circularly linked list of clause pointers. It follows the C++
    00017 //                                      Standard Template Library specifications.
    00018 //
    00019 //========================================================================================
    00020
    00021 #include <cassert>
    00022 #include <cstdio>
    00023 #include "ISATClause.h"
    00024 #include "ISATClauses.h"
    00025
    00027
    00028 using namespace Mers::Solvers::SAT::ISAT;
    00029 using std::ostream;
    00030
    00032 // Public Constructors, Copy Constructors, & Destructors
    00034
    00035 ISATClauses::ISATClauses()
    00036 {
    00037 }
    00038 /*
    00039 ISATClauses::ISATClauses(ISATClauses &other)
    00040 {
    00041         if (this != &other)
    00042         {
    00043                 _head_node_p                                    = new Node();
    00044                 copy(other);
    00045         }
    00046 }
    00047 */
    00048 ISATClauses::~ISATClauses()
    00049 {
    00050 }
    00051
    00052 //----------------------------------------------------------------------------------------
    00053 // Public Function Members
    00054 //----------------------------------------------------------------------------------------
    00055
    00056 bool
    00057 ISATClauses::is_empty() const
    00058 {
    00059         return empty();
    00060 }
    00061
    00062 void
    00063 ISATClauses::insert_clause(ISATClause *clause_p)
    00064 {
    00065         push_back(clause_p);
    00066 }
    00067
    00068 void
    00069 ISATClauses::remove_clause(ISATClause *clause_p)
    00070 {
    00071         for (iterator it = begin(); it != end(); it++)
    00072         {
    00073                 if (*it == clause_p)
    00074                 {
    00075                         erase(it);
    00076                         return;
    00077                 }
    00078         }
    00079 }
    00080
    00081 //----------------------------------------------------------------------------------------
    00082 // Public Operators
    00083 //----------------------------------------------------------------------------------------
    00084
    00085 bool
    00086 ISATClauses::operator ==(ISATClauses const &other) const
    00087 {
    00088         ISATClauses::const_iterator this_const_it;
    00089         ISATClauses::const_iterator other_const_it;
    00090         if (this == &other)
    00091         {
    00092                 return true;
    00093         }
    00094         else
    00095         {
    00096                 if (this->size() != other.size())
    00097                 {
    00098                         return false;
    00099                 }
    00100                 else
    00101                 {
    00102                         for (this_const_it = begin(), other_const_it = other.begin();
    00103                         this_const_it != end() && other_const_it != other.end();
    00104                         this_const_it++, other_const_it++)
    00105                         {
    00106                                 if (**this_const_it != **other_const_it)
    00107                                 {
    00108                                         return false;
    00109                                 }
    00110                         }
    00111                         return true;
    00112                 }
    00113         }
    00114 }
    00115
    00116 bool
    00117 ISATClauses::operator !=(ISATClauses const &other) const
    00118 {
    00119         return !(*this == other);
    00120 }
    00121
    00122 ISATClauses const &
    00123 ISATClauses::operator+=(ISATClause &clause)
    00124 {
    00125         insert_clause(&clause);
    00126         return (*this);
    00127 }
    00128
    00129 ISATClauses const &
    00130 ISATClauses::operator+=(ISATClauses const &other)
    00131 {
    00132         if (this != &other)
    00133         {
    00134                 const_iterator it;
    00135                 for (it = other.begin(); it != other.end(); it++)
    00136                 {
    00137                         insert_clause(*it);
    00138                 }
    00139         }
    00140         return (*this);
    00141 }
    00142
    00143
    00144 /*ISATClauses const &
    00145 ISATClauses::operator =(ISATClauses &other)
    00146 {
    00147         if (this != &other)
    00148         {
    00149                 clear();
    00150                 copy(other);
    00151         }
    00152         return (*this);
    00153 }*/
    00154
    00155 namespace Mers {
    00156         namespace Solvers {
    00157                 namespace SAT {
    00158                         namespace ISAT {
    00159
    00160                                 ostream &
    00161                                 operator <<(ostream &stream, ISATClauses const &clauses)
    00162                                 {
    00163                                         stream << "(";
    00164                                         ISATClauses::const_iterator const_it = clauses.begin();
    00165                                         if (const_it != clauses.end())
    00166                                         {
    00167                                                 stream << **const_it;
    00168                                                 const_it++;
    00169                                                 while (const_it != clauses.end())
    00170                                                 {
    00171                                                         stream << ", " << **const_it;
    00172                                                         const_it++;
    00173                                                 }
    00174                                         }
    00175                                         stream << ")";
    00176                                         return stream;
    00177                                 }
    00178                         }
    00179                 }
    00180         }
    00181 }
    00182