X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fcontainer.h;h=e3465c46decb803392b255cc1c364c5df9b51d08;hp=135adb966ab292dff3749bba750a8d5417d79cab;hb=6d7bf9ee5a7ce05cb3a23dae664e781d7325d7b8;hpb=68fdf425abf14d016d5f95ee7b9d06a19a3c5926 diff --git a/ginac/container.h b/ginac/container.h index 135adb96..e3465c46 100644 --- a/ginac/container.h +++ b/ginac/container.h @@ -28,6 +28,7 @@ #include #include #include +#include #include "ex.h" #include "print.h" @@ -85,19 +86,17 @@ protected: // constructors public: - container(STLT const & s, bool discardable = false) + container(STLT const & s, bool discardable = false) : inherited(get_tinfo()) { if (discardable) - seq.swap(const_cast(s)); + this->seq.swap(const_cast(s)); else - seq = s; + this->seq = s; } - explicit container(STLT * vp) + explicit container(std::auto_ptr vp) : inherited(get_tinfo()) { - GINAC_ASSERT(vp); - seq.swap(*vp); - delete vp; + this->seq.swap(*vp); } container(exvector::const_iterator b, exvector::const_iterator e) @@ -108,68 +107,68 @@ public: container(const ex & p1, const ex & p2) : inherited(get_tinfo()) { - reserve(seq, 2); - seq.push_back(p1); seq.push_back(p2); + reserve(this->seq, 2); + this->seq.push_back(p1); this->seq.push_back(p2); } container(const ex & p1, const ex & p2, const ex & p3) : inherited(get_tinfo()) { - reserve(seq, 3); - seq.push_back(p1); seq.push_back(p2); seq.push_back(p3); + reserve(this->seq, 3); + this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3); } container(const ex & p1, const ex & p2, const ex & p3, const ex & p4) : inherited(get_tinfo()) { - reserve(seq, 4); - seq.push_back(p1); seq.push_back(p2); seq.push_back(p3); - seq.push_back(p4); + reserve(this->seq, 4); + this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3); + this->seq.push_back(p4); } container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5) : inherited(get_tinfo()) { - reserve(seq, 5); - seq.push_back(p1); seq.push_back(p2); seq.push_back(p3); - seq.push_back(p4); seq.push_back(p5); + reserve(this->seq, 5); + this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3); + this->seq.push_back(p4); this->seq.push_back(p5); } container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6) : inherited(get_tinfo()) { - reserve(seq, 6); - seq.push_back(p1); seq.push_back(p2); seq.push_back(p3); - seq.push_back(p4); seq.push_back(p5); seq.push_back(p6); + reserve(this->seq, 6); + this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3); + this->seq.push_back(p4); this->seq.push_back(p5); this->seq.push_back(p6); } container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7) : inherited(get_tinfo()) { - reserve(seq, 7); - seq.push_back(p1); seq.push_back(p2); seq.push_back(p3); - seq.push_back(p4); seq.push_back(p5); seq.push_back(p6); - seq.push_back(p7); + reserve(this->seq, 7); + this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3); + this->seq.push_back(p4); this->seq.push_back(p5); this->seq.push_back(p6); + this->seq.push_back(p7); } container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8) : inherited(get_tinfo()) { - reserve(seq, 8); - seq.push_back(p1); seq.push_back(p2); seq.push_back(p3); - seq.push_back(p4); seq.push_back(p5); seq.push_back(p6); - seq.push_back(p7); seq.push_back(p8); + reserve(this->seq, 8); + this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3); + this->seq.push_back(p4); this->seq.push_back(p5); this->seq.push_back(p6); + this->seq.push_back(p7); this->seq.push_back(p8); } container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8, const ex & p9) : inherited(get_tinfo()) { - reserve(seq, 9); - seq.push_back(p1); seq.push_back(p2); seq.push_back(p3); - seq.push_back(p4); seq.push_back(p5); seq.push_back(p6); - seq.push_back(p7); seq.push_back(p8); seq.push_back(p9); + reserve(this->seq, 9); + this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3); + this->seq.push_back(p4); this->seq.push_back(p5); this->seq.push_back(p6); + this->seq.push_back(p7); this->seq.push_back(p8); this->seq.push_back(p9); } container(const ex & p1, const ex & p2, const ex & p3, @@ -177,11 +176,11 @@ public: const ex & p7, const ex & p8, const ex & p9, const ex & p10) : inherited(get_tinfo()) { - reserve(seq, 10); - seq.push_back(p1); seq.push_back(p2); seq.push_back(p3); - seq.push_back(p4); seq.push_back(p5); seq.push_back(p6); - seq.push_back(p7); seq.push_back(p8); seq.push_back(p9); - seq.push_back(p10); + reserve(this->seq, 10); + this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3); + this->seq.push_back(p4); this->seq.push_back(p5); this->seq.push_back(p6); + this->seq.push_back(p7); this->seq.push_back(p8); this->seq.push_back(p9); + this->seq.push_back(p10); } container(const ex & p1, const ex & p2, const ex & p3, @@ -189,11 +188,11 @@ public: const ex & p7, const ex & p8, const ex & p9, const ex & p10, const ex & p11) : inherited(get_tinfo()) { - reserve(seq, 11); - seq.push_back(p1); seq.push_back(p2); seq.push_back(p3); - seq.push_back(p4); seq.push_back(p5); seq.push_back(p6); - seq.push_back(p7); seq.push_back(p8); seq.push_back(p9); - seq.push_back(p10); seq.push_back(p11); + reserve(this->seq, 11); + this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3); + this->seq.push_back(p4); this->seq.push_back(p5); this->seq.push_back(p6); + this->seq.push_back(p7); this->seq.push_back(p8); this->seq.push_back(p9); + this->seq.push_back(p10); this->seq.push_back(p11); } container(const ex & p1, const ex & p2, const ex & p3, @@ -201,11 +200,11 @@ public: const ex & p7, const ex & p8, const ex & p9, const ex & p10, const ex & p11, const ex & p12) : inherited(get_tinfo()) { - reserve(seq, 12); - seq.push_back(p1); seq.push_back(p2); seq.push_back(p3); - seq.push_back(p4); seq.push_back(p5); seq.push_back(p6); - seq.push_back(p7); seq.push_back(p8); seq.push_back(p9); - seq.push_back(p10); seq.push_back(p11); seq.push_back(p12); + reserve(this->seq, 12); + this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3); + this->seq.push_back(p4); this->seq.push_back(p5); this->seq.push_back(p6); + this->seq.push_back(p7); this->seq.push_back(p8); this->seq.push_back(p9); + this->seq.push_back(p10); this->seq.push_back(p11); this->seq.push_back(p12); } container(const ex & p1, const ex & p2, const ex & p3, @@ -214,12 +213,12 @@ public: const ex & p10, const ex & p11, const ex & p12, const ex & p13) : inherited(get_tinfo()) { - reserve(seq, 13); - seq.push_back(p1); seq.push_back(p2); seq.push_back(p3); - seq.push_back(p4); seq.push_back(p5); seq.push_back(p6); - seq.push_back(p7); seq.push_back(p8); seq.push_back(p9); - seq.push_back(p10); seq.push_back(p11); seq.push_back(p12); - seq.push_back(p13); + reserve(this->seq, 13); + this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3); + this->seq.push_back(p4); this->seq.push_back(p5); this->seq.push_back(p6); + this->seq.push_back(p7); this->seq.push_back(p8); this->seq.push_back(p9); + this->seq.push_back(p10); this->seq.push_back(p11); this->seq.push_back(p12); + this->seq.push_back(p13); } container(const ex & p1, const ex & p2, const ex & p3, @@ -228,12 +227,12 @@ public: const ex & p10, const ex & p11, const ex & p12, const ex & p13, const ex & p14) : inherited(get_tinfo()) { - reserve(seq, 14); - seq.push_back(p1); seq.push_back(p2); seq.push_back(p3); - seq.push_back(p4); seq.push_back(p5); seq.push_back(p6); - seq.push_back(p7); seq.push_back(p8); seq.push_back(p9); - seq.push_back(p10); seq.push_back(p11); seq.push_back(p12); - seq.push_back(p13); seq.push_back(p14); + reserve(this->seq, 14); + this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3); + this->seq.push_back(p4); this->seq.push_back(p5); this->seq.push_back(p6); + this->seq.push_back(p7); this->seq.push_back(p8); this->seq.push_back(p9); + this->seq.push_back(p10); this->seq.push_back(p11); this->seq.push_back(p12); + this->seq.push_back(p13); this->seq.push_back(p14); } container(const ex & p1, const ex & p2, const ex & p3, @@ -242,12 +241,12 @@ public: const ex & p10, const ex & p11, const ex & p12, const ex & p13, const ex & p14, const ex & p15) : inherited(get_tinfo()) { - reserve(seq, 15); - seq.push_back(p1); seq.push_back(p2); seq.push_back(p3); - seq.push_back(p4); seq.push_back(p5); seq.push_back(p6); - seq.push_back(p7); seq.push_back(p8); seq.push_back(p9); - seq.push_back(p10); seq.push_back(p11); seq.push_back(p12); - seq.push_back(p13); seq.push_back(p14); seq.push_back(p15); + reserve(this->seq, 15); + this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3); + this->seq.push_back(p4); this->seq.push_back(p5); this->seq.push_back(p6); + this->seq.push_back(p7); this->seq.push_back(p8); this->seq.push_back(p9); + this->seq.push_back(p10); this->seq.push_back(p11); this->seq.push_back(p12); + this->seq.push_back(p13); this->seq.push_back(p14); this->seq.push_back(p15); } container(const ex & p1, const ex & p2, const ex & p3, @@ -257,25 +256,24 @@ public: const ex & p13, const ex & p14, const ex & p15, const ex & p16) : inherited(get_tinfo()) { - reserve(seq, 16); - seq.push_back(p1); seq.push_back(p2); seq.push_back(p3); - seq.push_back(p4); seq.push_back(p5); seq.push_back(p6); - seq.push_back(p7); seq.push_back(p8); seq.push_back(p9); - seq.push_back(p10); seq.push_back(p11); seq.push_back(p12); - seq.push_back(p13); seq.push_back(p14); seq.push_back(p15); - seq.push_back(p16); + reserve(this->seq, 16); + this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3); + this->seq.push_back(p4); this->seq.push_back(p5); this->seq.push_back(p6); + this->seq.push_back(p7); this->seq.push_back(p8); this->seq.push_back(p9); + this->seq.push_back(p10); this->seq.push_back(p11); this->seq.push_back(p12); + this->seq.push_back(p13); this->seq.push_back(p14); this->seq.push_back(p15); + this->seq.push_back(p16); } // functions overriding virtual functions from base classes public: - void print(const print_context & c, unsigned level = 0) const; bool info(unsigned inf) const { return inherited::info(inf); } unsigned precedence() const { return 10; } - size_t nops() const { return seq.size(); } + size_t nops() const { return this->seq.size(); } ex op(size_t i) const; ex & let_op(size_t i); ex eval(int level = 0) const; - ex subs(const lst & ls, const lst & lr, unsigned options = 0) const; + ex subs(const exmap & m, unsigned options = 0) const; protected: bool is_equal_same_type(const basic & other) const; @@ -288,7 +286,7 @@ protected: /** Similar to duplicate(), but with a preset sequence (which gets * deleted). Must be overridden by derived classes. */ - virtual ex thiscontainer(STLT * vp) const { return container(vp); } + virtual ex thiscontainer(std::auto_ptr vp) const { return container(vp); } virtual void printseq(const print_context & c, char openbracket, char delim, char closebracket, unsigned this_precedence, @@ -298,18 +296,18 @@ protected: private: void sort_(std::random_access_iterator_tag) { - std::sort(seq.begin(), seq.end(), ex_is_less()); + std::sort(this->seq.begin(), this->seq.end(), ex_is_less()); } void sort_(std::input_iterator_tag) { - seq.sort(ex_is_less()); + this->seq.sort(ex_is_less()); } void unique_() { - typename STLT::iterator p = std::unique(seq.begin(), seq.end(), ex_is_equal()); - seq.erase(p, seq.end()); + typename STLT::iterator p = std::unique(this->seq.begin(), this->seq.end(), ex_is_equal()); + this->seq.erase(p, this->seq.end()); } public: @@ -321,14 +319,18 @@ public: container & sort(); container & unique(); - const_iterator begin() const {return seq.begin();} - const_iterator end() const {return seq.end();} - const_reverse_iterator rbegin() const {return seq.rbegin();} - const_reverse_iterator rend() const {return seq.rend();} + const_iterator begin() const {return this->seq.begin();} + const_iterator end() const {return this->seq.end();} + const_reverse_iterator rbegin() const {return this->seq.rbegin();} + const_reverse_iterator rend() const {return this->seq.rend();} protected: + void do_print(const print_context & c, unsigned level) const; + void do_print_tree(const print_tree & c, unsigned level) const; + void do_print_python(const print_python & c, unsigned level) const; + void do_print_python_repr(const print_python_repr & c, unsigned level) const; STLT evalchildren(int level) const; - STLT *subschildren(const lst & ls, const lst & lr, unsigned options = 0) const; + std::auto_ptr subschildren(const exmap & m, unsigned options = 0) const; }; /** Default constructor */ @@ -342,7 +344,7 @@ container::container(const archive_node &n, lst &sym_lst) : inherited(n, sym_ for (unsigned int i=0; true; i++) { ex e; if (n.find_ex("seq", e, sym_lst, i)) - seq.push_back(e); + this->seq.push_back(e); else break; } @@ -360,7 +362,7 @@ template