/** @file lst.h
 *
 *  Definition of GiNaC's lst. */

/*
 *  This file was generated automatically by container.pl.
 *  Please do not modify it directly, edit the perl script instead!
 *  container.pl options: $CONTAINER=lst
 *                        $STLHEADER=list
 *                        $reserve=0
 *                        $prepend=1
 *                        $sort=1
 *                        $let_op=1
 *                        $open_bracket={
 *                        $close_bracket=}
 *                        $maxargs=16
 *
 *  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
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef __GINAC_LST_H__
#define __GINAC_LST_H__

#include <list>

// CINT needs <algorithm> to work properly with <vector> and <list> 
#include <algorithm>

#include "basic.h"
#include "ex.h"

namespace GiNaC {


typedef std::list<ex> exlist;

class lst : public basic
{
	GINAC_DECLARE_REGISTERED_CLASS(lst, basic)

public:
	lst(exlist const & s, bool discardable = false);
	lst(exlist * vp); // vp will be deleted
	explicit lst(const ex & param1);
	explicit lst(const ex & param1, const ex & param2);
	explicit lst(const ex & param1, const ex & param2, const ex & param3);
	explicit lst(const ex & param1, const ex & param2, const ex & param3, const ex & param4);
	explicit lst(const ex & param1, const ex & param2, const ex & param3, const ex & param4, const ex & param5);
	explicit lst(const ex & param1, const ex & param2, const ex & param3, const ex & param4, const ex & param5, const ex & param6);
	explicit lst(const ex & param1, const ex & param2, const ex & param3, const ex & param4, const ex & param5, const ex & param6, const ex & param7);
	explicit lst(const ex & param1, const ex & param2, const ex & param3, const ex & param4, const ex & param5, const ex & param6, const ex & param7, const ex & param8);
	explicit lst(const ex & param1, const ex & param2, const ex & param3, const ex & param4, const ex & param5, const ex & param6, const ex & param7, const ex & param8, const ex & param9);
	explicit lst(const ex & param1, const ex & param2, const ex & param3, const ex & param4, const ex & param5, const ex & param6, const ex & param7, const ex & param8, const ex & param9, const ex & param10);
	explicit lst(const ex & param1, const ex & param2, const ex & param3, const ex & param4, const ex & param5, const ex & param6, const ex & param7, const ex & param8, const ex & param9, const ex & param10, const ex & param11);
	explicit lst(const ex & param1, const ex & param2, const ex & param3, const ex & param4, const ex & param5, const ex & param6, const ex & param7, const ex & param8, const ex & param9, const ex & param10, const ex & param11, const ex & param12);
	explicit lst(const ex & param1, const ex & param2, const ex & param3, const ex & param4, const ex & param5, const ex & param6, const ex & param7, const ex & param8, const ex & param9, const ex & param10, const ex & param11, const ex & param12, const ex & param13);
	explicit lst(const ex & param1, const ex & param2, const ex & param3, const ex & param4, const ex & param5, const ex & param6, const ex & param7, const ex & param8, const ex & param9, const ex & param10, const ex & param11, const ex & param12, const ex & param13, const ex & param14);
	explicit lst(const ex & param1, const ex & param2, const ex & param3, const ex & param4, const ex & param5, const ex & param6, const ex & param7, const ex & param8, const ex & param9, const ex & param10, const ex & param11, const ex & param12, const ex & param13, const ex & param14, const ex & param15);
	explicit lst(const ex & param1, const ex & param2, const ex & param3, const ex & param4, const ex & param5, const ex & param6, const ex & param7, const ex & param8, const ex & param9, const ex & param10, const ex & param11, const ex & param12, const ex & param13, const ex & param14, const ex & param15, const ex & param16);


public:
	void print(const print_context & c, unsigned level = 0) const;
	unsigned precedence(void) const {return 10;}
	bool info(unsigned inf) const;
	size_t nops() const;
	ex op(size_t i) const;
	ex & let_op(size_t i);

	ex map(map_function & f) const;
	ex eval(int level=0) const;
	ex subs(const lst & ls, const lst & lr, unsigned options = 0) const;
protected:
	bool is_equal_same_type(const basic & other) const;

	// new virtual functions which can be overridden by derived classes
public:
	virtual lst & append(const ex & b);
	virtual lst & remove_last(void);
	virtual lst & remove_all(void);
	virtual lst & prepend(const ex & b);
	virtual lst & remove_first(void);

	virtual lst & sort(void);
	virtual lst & unique(void);

protected:
	virtual void printseq(const print_context & c, char openbracket, char delim,
	                      char closebracket, unsigned this_precedence,
	                      unsigned upper_precedence = 0) const;
	virtual ex thislst(exlist const & v) const;
	virtual ex thislst(exlist * vp) const;

protected:
	bool is_canonical() const;
	exlist evalchildren(int level) const;
	exlist * subschildren(const lst & ls, const lst & lr, unsigned options = 0) const;

protected:
	exlist seq;
};

// utility functions

/** Specialization of is_exactly_a<lst>(obj) for lst objects. */
template<> inline bool is_exactly_a<lst>(const basic & obj)
{
	return obj.tinfo()==TINFO_lst;
}

} // namespace GiNaC

#endif // ndef __GINAC_LST_H__

