#ifndef __SFJP_MYU__AGH_DEFS_STL_H__
#define __SFJP_MYU__AGH_DEFS_STL_H__

/*
template <typename _Con>
class agh_stl_container_base : public _Con
{
public:
}
*/

//	agh_stl_container_value
template <typename _Ty>
class agh_stl_container_value
{
public:
	virtual _Ty& value()=0;
};


//	agh_map
template <typename _K, typename _Ty>
class agh_map : public std::map<_K, _Ty>
{
private:
	//typedef typename std::map<_K, _Ty> _BASE;
	typedef typename std::map<_K, _Ty>::iterator _BASE_ITR;

public:
	class iterator : public agh_stl_container_value<_Ty>
	{
	protected:
		_BASE_ITR m_it;
	public:
		iterator(){}
		iterator(const _BASE_ITR &it) : m_it(it){}
		iterator(const iterator &it) : m_it(it.m_it) {}

		void operator = (const iterator &it){ m_it = it.m_it; }
		void operator = (const _BASE_ITR &it){ m_it = it; }

		///////////////////////////
		//	仕方ねぇからstd::_Treeからコピーしてきたさ・・・

		typedef iterator this_iterator;
		typedef const _Ty _FARQ& const_reference;
		typedef const _Ty _FARQ *const_pointer;
		typedef _Ty _FARQ *_Ctptr;

		const_reference operator*() const { return m_it.operator *(); }
		_Ctptr operator->() const { return &(m_it->second); } //{ return m_it.operator ->(); }
		const_iterator& operator++() { return m_it.operator ++(); }
		const_iterator operator++(int) { return m_it.operator ++(0); }
		const_iterator& operator--() { return m_it.operator --(); }
		const_iterator operator--(int) { return m_it.operator --(0); }
		bool operator==(const const_iterator& _X) { return m_it.operator ==(_X); }
		bool operator!=(const const_iterator& _X) { return m_it.operator !=(_X); }

		//	追加
		bool operator==(const this_iterator& it) { return m_it.operator ==(it.m_it); }
		bool operator!=(const this_iterator& it) { return m_it.operator !=(it.m_it); }

		/////////////////////////////

		_K first(){ return m_it->first; }
		_K key(){ return m_it->first; }
		_Ty& value(){ return m_it->second; }
	};
	
	/*
	class iterator : public _BASE_ITR, public agh_stl_container_value<_Ty>
	{
	public:
		iterator() : _BASE_ITR(){}
		//iterator(const iterator &it) : _BASE_ITR( *((_BASE_ITR*)&it) ){}
		iterator(const iterator &it) : _BASE_ITR( it._Ptr ){}
		iterator(const _BASE_ITR &it) : _BASE_ITR(it){}

		//void operator = (const iterator &it){ _BASE_ITR::operator = ( *((_BASE_ITR*)&it) ); }
		//void operator = (const _BASE_ITR &it){ _BASE_ITR::operator = (it); }
		//void operator = (const iterator &it){ _BASE_ITR( *((_BASE_ITR*)&it) ); }
		void operator = (const iterator &it){ _BASE_ITR( it._Ptr ); }
		void operator = (const _BASE_ITR &it){ _BASE_ITR(it); }

		//CTRL_T* operator ->(){ return _BASE_ITR::operator ->(); }
		//CTRL_T* operator ->(){ return &((std::pair<KEY_T,CTRL_T>*)_BASE_ITR::operator ->())->second; }
		_Ty* operator ->(){ return &operator *().second; }

		_K first(){ return operator *().first; }
		_K key(){ return operator *().first; }
		_Ty& value(){ return operator *().second; }
	};
	*/
};


template <typename _K, typename _Ty>
class map : public agh_map<_K, _Ty>{};

//typedef agh_map map;

/////////////////////////////////////////////////////////////////////



//	agh_list
template <typename _Ty>
class agh_list : public std::list<_Ty>
{
private:
	typedef typename std::list<_Ty> _BASE;
	typedef typename std::list<_Ty>::iterator _BASE_ITR;

public:
	class iterator : public agh_stl_container_value<_Ty>
	{
	protected:
		_BASE_ITR m_it;
	public:
		iterator(){}
		iterator(const _BASE_ITR &it) : m_it(it){}
		iterator(const iterator &it) : m_it(it.m_it) {}

		void operator = (const iterator &it){ m_it = it.m_it; }
		void operator = (const _BASE_ITR &it){ m_it = it; }

		///////////////////////////
		//	仕方ねぇからstd::_Treeからコピーしてきたさ・・・

		typedef iterator this_iterator;
		typedef const _Ty _FARQ& const_reference;
		typedef const _Ty _FARQ *const_pointer;
		typedef _Ty _FARQ *_Ctptr;

		const_reference operator*() const { return m_it.operator *(); }
		_Ctptr operator->() const { return m_it.operator ->(); } //{ return m_it.operator ->(); }
		const_iterator& operator++() { return m_it.operator ++(); }
		const_iterator operator++(int) { return m_it.operator ++(0); }
		const_iterator& operator--() { return m_it.operator --(); }
		const_iterator operator--(int) { return m_it.operator --(0); }
		bool operator==(const const_iterator& _X) { return m_it.operator ==(_X); }
		bool operator!=(const const_iterator& _X) { return m_it.operator !=(_X); }

		//	追加
		bool operator==(const this_iterator& it) { return m_it.operator ==(it.m_it); }
		bool operator!=(const this_iterator& it) { return m_it.operator !=(it.m_it); }

		/////////////////////////////

		_Ty& value(){ return *m_it; }
	};
	
	/*
	class iterator : public _BASE_ITR, public agh_stl_container_value<_Ty>
	{
	public:
		iterator() : _BASE_ITR(){}
		//iterator(const iterator &it) : _BASE_ITR( *((_BASE_ITR*)&it) ){}
		iterator(const iterator &it) : _BASE_ITR( it._Ptr ){}
		iterator(const _BASE_ITR &it) : _BASE_ITR(it){}

		//void operator = (const iterator &it){ _BASE_ITR::operator = ( *((_BASE_ITR*)&it) ); }
		//void operator = (const _BASE_ITR &it){ _BASE_ITR::operator = (it); }
		//void operator = (const iterator &it){ _BASE_ITR( *((_BASE_ITR*)&it) ); }
		void operator = (const iterator &it){ _BASE_ITR( it._Ptr ); }
		void operator = (const _BASE_ITR &it){ _BASE_ITR(it); }

		//CTRL_T* operator ->(){ return _BASE_ITR::operator ->(); }
		//CTRL_T* operator ->(){ return &((std::pair<KEY_T,CTRL_T>*)_BASE_ITR::operator ->())->second; }
		_Ty* operator ->(){ return &operator *().second; }

		_K first(){ return operator *().first; }
		_K key(){ return operator *().first; }
		_Ty& value(){ return operator *().second; }
	};
	*/
};


template <typename _Ty>
class list : public agh_list<_Ty>{};


#endif//__SFJP_MYU__AGH_DEFS_STL_H__
