$STLHEADER="vector";
$reserve=1;
$prepend=0;
+ $sort=0;
$let_op=0;
$open_bracket='(';
$close_bracket=')';
$STLHEADER="list";
$reserve=0;
$prepend=1;
+ $sort=1;
$let_op=1;
$open_bracket='{';
$close_bracket='}';
seq.push_front(b);
return *this;
}
+
${CONTAINER} & ${CONTAINER}::remove_first(void)
{
ensure_if_modifiable();
$PREPEND_IMPLEMENTATION="";
}
+if ($sort) {
+ $SORT_INTERFACE=<<END_OF_SORT_INTERFACE;
+ virtual ${CONTAINER} & sort(void);
+ virtual ${CONTAINER} & unique(void);
+END_OF_SORT_INTERFACE
+
+ $SORT_IMPLEMENTATION=<<END_OF_SORT_IMPLEMENTATION;
+${CONTAINER} & ${CONTAINER}::sort(void)
+{
+ ensure_if_modifiable();
+ seq.sort(ex_is_less());
+ return *this;
+}
+
+${CONTAINER} & ${CONTAINER}::unique(void)
+{
+ ensure_if_modifiable();
+ seq.unique(ex_is_equal());
+ return *this;
+}
+END_OF_SORT_IMPLEMENTATION
+} else {
+ $SORT_INTERFACE=" // no sort possible for ${CONTAINER}";
+ $SORT_IMPLEMENTATION="";
+}
+
if ($let_op) {
$LET_OP_IMPLEMENTATION=<<END_OF_LET_OP_IMPLEMENTATION
ex & ${CONTAINER}::let_op(int i)
<<'END_OF_CONSTRUCTORS_IMPLEMENTATION','const ex & param${N}',', ',' seq.push_back(param${N});',"\n");
${CONTAINER}::${CONTAINER}(${SEQ1}) : basic(TINFO_${CONTAINER})
{
- debugmsg(\"${CONTAINER} ctor from ${N}*ex\",LOGLEVEL_CONSTRUCT);
RESERVE(seq,${N});
${SEQ2}
}
* \$STLHEADER=${STLHEADER}
* \$reserve=${reserve}
* \$prepend=${prepend}
+ * \$sort=${sort}
* \$let_op=${let_op}
* \$open_bracket=${open_bracket}
* \$close_bracket=${close_bracket}
* \$maxargs=${maxargs}
*
- * GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
virtual ${CONTAINER} & append(const ex & b);
virtual ${CONTAINER} & remove_last(void);
${PREPEND_INTERFACE}
+${SORT_INTERFACE}
protected:
virtual void printseq(const print_context & c, char openbracket, char delim,
char closebracket, unsigned this_precedence,
// utility functions
-/** Return the ${CONTAINER} object handled by an ex. Deprecated: use ex_to<${CONTAINER}>().
- * This is unsafe: you need to check the type first. */
-inline const ${CONTAINER} &ex_to_${CONTAINER}(const ex &e)
-{
- return static_cast<const ${CONTAINER} &>(*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__
* \$close_bracket=${close_bracket}
* \$maxargs=${maxargs}
*
- * GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "ex.h"
#include "print.h"
#include "archive.h"
-#include "debugmsg.h"
namespace GiNaC {
${RESERVE_IMPLEMENTATION}
//////////
-// default ctor, dtor, copy ctor assignment operator and helpers
+// default ctor, dtor, copy ctor, assignment operator and helpers
//////////
// public
-${CONTAINER}::${CONTAINER}() : basic(TINFO_${CONTAINER})
-{
- debugmsg("${CONTAINER} default ctor",LOGLEVEL_CONSTRUCT);
-}
+${CONTAINER}::${CONTAINER}() : basic(TINFO_${CONTAINER}) {}
// protected
${CONTAINER}::${CONTAINER}(${STLT} const & s, bool discardable) : basic(TINFO_${CONTAINER})
{
- debugmsg("${CONTAINER} ctor from ${STLT}", LOGLEVEL_CONSTRUCT);
if (discardable) {
seq.swap(const_cast<${STLT} &>(s));
} else {
${CONTAINER}::${CONTAINER}(${STLT} * vp) : basic(TINFO_${CONTAINER})
{
- debugmsg("${CONTAINER} ctor from ${STLT} *",LOGLEVEL_CONSTRUCT);
GINAC_ASSERT(vp!=0);
seq.swap(*vp);
delete vp;
/** 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))
}
//////////
-// 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<print_tree>(c)) {
c.s << std::string(level, ' ') << class_name()
++i;
}
c.s << std::string(level + delta_indent,' ') << "=====" << std::endl;
-
+ } else if (is_a<print_python>(c)) {
+ printseq(c, '[', ',', ']', precedence(), precedence()+1);
+ } else if (is_a<print_python_repr>(c)) {
+ c.s << class_name ();
+ printseq(c, '(', ',', ')', precedence(), precedence()+1);
} else {
// always print brackets around seq, ignore upper_precedence
printseq(c, '${open_bracket}', ',', '${close_bracket}', precedence(), precedence()+1);
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();
{
${STLT} *vp = subschildren(ls, lr, no_pattern);
if (vp)
- return this${CONTAINER}(vp).bp->basic::subs(ls, lr, no_pattern);
+ return ex_to<basic>(this${CONTAINER}(vp)).basic::subs(ls, lr, no_pattern);
else
return basic::subs(ls, lr, no_pattern);
}
${PREPEND_IMPLEMENTATION}
+${SORT_IMPLEMENTATION}
+
// protected
void ${CONTAINER}::printseq(const print_context & c, char openbracket, char delim,