X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fcontainer.pl;h=5e4837d17e0faa185285315e4fc7fb67efde5d9c;hp=8f7cb87d6eedd4cc4f596133df89eb51a9a4fc4b;hb=91dc5170396860518ac517c03a80c12ecb4ad82c;hpb=ed21ddd5e2bc0af018c10934342f526d0ae4b7a7 diff --git a/ginac/container.pl b/ginac/container.pl index 8f7cb87d..5e4837d1 100755 --- a/ginac/container.pl +++ b/ginac/container.pl @@ -23,6 +23,7 @@ if ($type eq 'exprseq') { $STLHEADER="vector"; $reserve=1; $prepend=0; + $sort=0; $let_op=0; $open_bracket='('; $close_bracket=')'; @@ -34,6 +35,7 @@ if ($type eq 'exprseq') { $STLHEADER="list"; $reserve=0; $prepend=1; + $sort=1; $let_op=1; $open_bracket='{'; $close_bracket='}'; @@ -64,6 +66,7 @@ ${CONTAINER} & ${CONTAINER}::prepend(const ex & b) seq.push_front(b); return *this; } + ${CONTAINER} & ${CONTAINER}::remove_first(void) { ensure_if_modifiable(); @@ -76,6 +79,32 @@ END_OF_PREPEND_IMPLEMENTATION $PREPEND_IMPLEMENTATION=""; } +if ($sort) { + $SORT_INTERFACE=<(). - * This is unsafe: you need to check the type first. */ -inline const ${CONTAINER} &ex_to_${CONTAINER}(const ex &e) -{ - return static_cast(*e.bp); -} - /** Specialization of is_exactly_a<${CONTAINER}>(obj) for ${CONTAINER} objects. */ template<> inline bool is_exactly_a<${CONTAINER}>(const basic & obj) { return obj.tinfo()==TINFO_${CONTAINER}; } -inline ${CONTAINER} &ex_to_nonconst_${CONTAINER}(const ex &e) -{ - return static_cast<${CONTAINER} &>(*e.bp); -} - } // namespace GiNaC #endif // ndef __GINAC_${CONTAINER_UC}_H__ @@ -305,7 +323,6 @@ $implementation=<(s)); } else { @@ -356,7 +369,6 @@ ${CONTAINER}::${CONTAINER}(${STLT} const & s, bool discardable) : basic(TINFO_$ ${CONTAINER}::${CONTAINER}(${STLT} * vp) : basic(TINFO_${CONTAINER}) { - debugmsg("${CONTAINER} ctor from ${STLT} *",LOGLEVEL_CONSTRUCT); GINAC_ASSERT(vp!=0); seq.swap(*vp); delete vp; @@ -371,7 +383,6 @@ ${constructors_implementation} /** Construct object from archive_node. */ ${CONTAINER}::${CONTAINER}(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst) { - debugmsg("${CONTAINER} ctor from archive_node", LOGLEVEL_CONSTRUCT); for (unsigned int i=0; true; i++) { ex e; if (n.find_ex("seq", e, sym_lst, i)) @@ -399,15 +410,13 @@ void ${CONTAINER}::archive(archive_node &n) const } ////////// -// functions overriding virtual functions from bases classes +// functions overriding virtual functions from base classes ////////// // public void ${CONTAINER}::print(const print_context & c, unsigned level) const { - debugmsg("${CONTAINER} print", LOGLEVEL_PRINT); - if (is_a(c)) { c.s << std::string(level, ' ') << class_name() @@ -439,6 +448,8 @@ ${LET_OP_IMPLEMENTATION} ex ${CONTAINER}::map(map_function & f) const { + // This implementation is here because basic::map() uses let_op() + // which is not defined for all containers ${STLT} s; RESERVE(s,seq.size()); ${STLT}::const_iterator i = seq.begin(), end = seq.end(); @@ -462,7 +473,7 @@ ex ${CONTAINER}::subs(const lst & ls, const lst & lr, bool no_pattern) const { ${STLT} *vp = subschildren(ls, lr, no_pattern); if (vp) - return this${CONTAINER}(vp).bp->basic::subs(ls, lr, no_pattern); + return ex_to(this${CONTAINER}(vp)).basic::subs(ls, lr, no_pattern); else return basic::subs(ls, lr, no_pattern); } @@ -534,6 +545,8 @@ ${CONTAINER} & ${CONTAINER}::remove_last(void) ${PREPEND_IMPLEMENTATION} +${SORT_IMPLEMENTATION} + // protected void ${CONTAINER}::printseq(const print_context & c, char openbracket, char delim,