⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iterator

📁 C语言库函数的原型,有用的拿去
💻
📖 第 1 页 / 共 5 页
字号:
		}

	virtual const_reference get_cref_virtual() sealed
		= _Myiter_t::get_cref
		{	// return const reference to designated element
		return (get_cref());
		}

	virtual reference get_ref_virtual() sealed
		= _Myiter_t::get_ref
		{	// return reference to designated element
		return (get_ref());
		}

	virtual void prev_virtual() sealed
		= _Myiter_t::prev
		{	// decrement
		prev();
		}

//	virtual difference_type move_virtual(difference_type _Offset);
//	virtual difference_type distance_virtual(
//		_STLCLR Generic::IRandomAccessIterator<_Value_t>^ _Right);
//	virtual bool less_than_virtual(
//		_STLCLR Generic::IRandomAccessIterator<_Value_t>^ _Right);
	};

template<typename _Cont_t>
	ConstUncheckedBidirectionalIterator<_Cont_t>
		_Unchecked(ConstBidirectionalIterator<_Cont_t> _Iter)
	{	// return unchecked version
	ConstUncheckedBidirectionalIterator<_Cont_t> _Newiter(
		(typename _Cont_t::node_type^)_Iter.get_node());

	return (_Newiter);
	}

//
// TEMPLATE VALUE CLASS BidirectionalIterator
//
template<typename _Cont_t>
	value class BidirectionalIterator
	:	public _STLCLR Generic::IBidirectionalIterator<
			typename _Cont_t::value_type>
	{	// iterator for mutable bidirectional container
public:
	// types
	typedef typename _Cont_t::value_type _Value_t;
	typedef BidirectionalIterator<_Cont_t> _Mytype_t;
	typedef _STLCLR Generic::IBidirectionalIterator<_Value_t> _Myiter_t;
	typedef typename _Cont_t::node_type node_type;

	typedef bidirectional_iterator_tag iterator_category;
	typedef _Value_t value_type;
	typedef int difference_type;
	typedef value_type% pointer;
	typedef value_type% reference;
	typedef value_type% const_reference;

	// constructors and special members
	BidirectionalIterator(node_type^ _Node)
		:	_Mynode(_Node)
		{	// construct from node
		}

	typedef ConstBidirectionalIterator<_Cont_t> _Myciter_t;

	operator _Myciter_t()
		{	// convert to const iterator
		return (_Myciter_t(_Mynode));
		}

	// generic conversions
	typedef _STLCLR Generic::ContainerBidirectionalIterator<_Value_t>
		_Mygeniter_t;

	BidirectionalIterator(_Mygeniter_t% _Right)
		:	_Mynode((node_type^)_Right.get_node())
		{	// construct by copying a generic iterator
		}

	operator _Mygeniter_t()
		{	// convert to generic iterator
		return (_Mygeniter_t(_Mynode));
		}

	// member functions
	virtual System::Object^ Clone()
		{	// return a copy
		return (gcnew BidirectionalIterator(_Mynode));
		}

	int get_bias()
		{	// get offset from wrapped iterator
		return (0);
		}

	System::Object^ get_node()
		{	// get node from wrapped iterator
		return (_Mynode);
		}

	bool valid()
		{	// test if iterator valid
		return (container() != nullptr);
		}

	System::Object^ container()
		{	// return owning container
		return (_Mynode == nullptr ? nullptr : _Mynode->container());
		}

	void next()
		{	// increment
		_Mynode = _Mynode->next_node();
		}

	bool equal_to(_STLCLR Generic::IInputIterator<_Value_t>^ _Right)
		{	// test if *this == _Right
		if (container() == nullptr
			|| container() != _Right->container())
			throw gcnew System::ArgumentException();
		return (get_bias() == _Right->get_bias()
			&& get_node() == _Right->get_node());
		}

	bool equal_to(_Mytype_t% _Right)
		{	// test if *this == _Right
		if (container() == nullptr
			|| container() != _Right.container())
			throw gcnew System::ArgumentException();
		return (get_bias() == _Right.get_bias()
			&& get_node() == _Right.get_node());
		}

	const_reference get_cref()
		{	// return const reference to designated element
		return (_Mynode->_Value);
		}

	reference get_ref()
		{	// return reference to designated element
		return (_Mynode->_Value);
		}

	void prev()
		{	// decrement
		_Mynode = _Mynode->prev_node();
		}

//	difference_type move(difference_type _Offset);
//	difference_type distance(
//		_STLCLR Generic::IRandomAccessIterator<_Value_t>^ _Right);
//	bool less_than(_STLCLR Generic::IRandomAccessIterator<_Value_t>^ _Right);

	// operators
	static const_reference operator->(
		BidirectionalIterator% _Left)
		{	// return pointer to class object
		return (_Left.get_ref());
		}

	static const_reference operator*(
		BidirectionalIterator% _Left)
		{	// return const reference to designated element
		return (_Left.get_ref());
		}

#pragma warning(push)
#pragma warning(disable:4460)
	static BidirectionalIterator operator++(
		BidirectionalIterator% _Left)
		{	// return incremented
		_Left.next();
		return (_Left);
		}
#pragma warning(pop)

	bool operator==(_STLCLR Generic::IInputIterator<_Value_t>^ _Right)
		{	// test if *this == _Right
		return (equal_to(_Right));
		}

	bool operator==(_Mytype_t% _Right)
		{	// test if *this == _Right
		return (equal_to(_Right));
		}

	bool operator!=(_STLCLR Generic::IInputIterator<_Value_t>^ _Right)
		{	// test if *this != _Right
		return (!(*this == _Right));
		}

	bool operator!=(_Mytype_t% _Right)
		{	// test if *this != _Right
		return (!(*this == _Right));
		}

#pragma warning(push)
#pragma warning(disable:4460)
	static BidirectionalIterator operator--(
		BidirectionalIterator% _Left)
		{	// return decremented
		_Left.prev();
		return (_Left);
		}

//	static BidirectionalIterator operator+(
//		BidirectionalIterator _Left,
//		difference_type _Right);
//	static BidirectionalIterator operator+(
//		difference_type _Left,
//		BidirectionalIterator _Right);
//	static BidirectionalIterator operator-(
//		difference_type _Right);
//	difference_type operator-(BidirectionalIterator _Right);
//	bool operator<(_STLCLR Generic::IBidirectionalIterator^ _Right);
//	bool operator>=(_STLCLR Generic::IBidirectionalIterator^ _Right);
//	bool operator>(_STLCLR Generic::IBidirectionalIterator^ _Right);
//	bool operator<=(_STLCLR Generic::IBidirectionalIterator^ _Right);
//	property const_reference default[difference_type];

_STLCLR_FIELD_ACCESS:
	// data members
	node_type^ _Mynode;	// node into list

private:
	virtual int get_bias_virtual() sealed
		= _Myiter_t::get_bias
		{	// get offset from wrapped iterator
		return (get_bias());
		}

	virtual System::Object^ get_node_virtual() sealed
		= _Myiter_t::get_node
		{	// get node from wrapped iterator
		return (get_node());
		}

	virtual bool valid_virtual() sealed
		= _Myiter_t::valid
		{	// test if iterator valid
		return (valid());
		}

	virtual System::Object^ container_virtual() sealed
		= _Myiter_t::container
		{	// return owning container
		return (container());
		}

	virtual void next_virtual() sealed
		= _Myiter_t::next
		{	// increment
		next();
		}

	virtual bool equal_to_virtual(
		_STLCLR Generic::IInputIterator<_Value_t>^ _Right) sealed
			= _Myiter_t::equal_to
		{	// test if *this == _Right
		return (equal_to(_Right));
		}

	virtual const_reference get_cref_virtual() sealed
		= _Myiter_t::get_cref
		{	// return const reference to designated element
		return (get_cref());
		}

	virtual reference get_ref_virtual() sealed
		= _Myiter_t::get_ref
		{	// return reference to designated element
		return (get_ref());
		}

	virtual void prev_virtual() sealed
		= _Myiter_t::prev
		{	// decrement
		prev();
		}

//	virtual difference_type move_virtual(difference_type _Offset);
//	virtual difference_type distance_virtual(
//		_STLCLR Generic::IRandomAccessIterator<_Value_t>^ _Right);
//	virtual bool less_than_virtual(
//		_STLCLR Generic::IRandomAccessIterator<_Value_t>^ _Right);
	};

//
// TEMPLATE VALUE CLASS UncheckedBidirectionalIterator
//
template<typename _Cont_t>
	value class UncheckedBidirectionalIterator
	:	public _STLCLR Generic::IBidirectionalIterator<
			typename _Cont_t::value_type>
	{	// iterator for mutable bidirectional container
public:
	// types
	typedef typename _Cont_t::value_type _Value_t;
	typedef UncheckedBidirectionalIterator<_Cont_t> _Mytype_t;
	typedef _STLCLR Generic::IBidirectionalIterator<_Value_t> _Myiter_t;
	typedef typename _Cont_t::node_type node_type;

	typedef bidirectional_iterator_tag iterator_category;
	typedef _Value_t value_type;
	typedef int difference_type;
	typedef value_type% pointer;
	typedef value_type% reference;
	typedef value_type% const_reference;

	// constructors and special members
	UncheckedBidirectionalIterator(node_type^ _Node)
		:	_Mynode(_Node)
		{	// construct from node
		}

	typedef ConstUncheckedBidirectionalIterator<_Cont_t> _Myciter_t;

	operator _Myciter_t()
		{	// convert to const iterator
		return (_Myciter_t(_Mynode));
		}

	operator BidirectionalIterator<_Cont_t>()
		{	// convert to checked iterator
		return (BidirectionalIterator<_Cont_t>(_Mynode));
		}

	// generic conversions
	typedef _STLCLR Generic::ContainerBidirectionalIterator<_Value_t>
		_Mygeniter_t;

	UncheckedBidirectionalIterator(_Mygeniter_t% _Right)
		:	_Mynode((node_type^)_Right.get_node())
		{	// construct by copying a generic iterator
		}

	operator _Mygeniter_t()
		{	// convert to generic iterator
		return (_Mygeniter_t(_Mynode));
		}

	// member functions
	virtual System::Object^ Clone()
		{	// return a copy
		return (gcnew UncheckedBidirectionalIterator(_Mynode));
		}

	int get_bias()
		{	// get offset from wrapped iterator
		return (0);
		}

	System::Object^ get_node()
		{	// get node from wrapped iterator
		return (_Mynode);
		}

	bool valid()
		{	// test if iterator valid
		return (true);	// UNCHECKED
//		return (container() != nullptr);
		}

	System::Object^ container()
		{	// return owning container
		return (_Mynode->container());	// UNCHECKED
//		return (_Mynode == nullptr ? nullptr : _Mynode->container());
		}

	void next()
		{	// increment
		_Mynode = _Mynode->next_node();
		}

	bool equal_to(_STLCLR Generic::IInputIterator<_Value_t>^ _Right)
		{	// test if *this == _Right
//		if (container() == nullptr	// UNCHECKED
//			|| container() != _Right->container())
//			throw gcnew System::ArgumentException();
		return (get_bias() == _Right->get_bias()
			&& get_node() == _Right->get_node());
		}

	bool equal_to(_Mytype_t% _Right)
		{	// test if *this == _Right
//		if (container() == nullptr	// UNCHECKED
//			|| container() != _Right.container())
//			throw gcnew System::ArgumentException();
		return (get_bias() == _Right.get_bias()
			&& get_node() == _Right.get_node());
		}

	const_reference get_cref()
		{	// return const reference to designated element
		return (_Mynode->_Value);
		}

	reference get_ref()
		{	// return reference to designated element
		return (_Mynode->_Value);
		}

	void prev()
		{	// decrement
		_Mynode = _Mynode->prev_node();
		}

//	difference_type move(difference_type _Offset);
//	difference_type distance(
//		_STLCLR Generic::IRandomAccessIterator<_Value_t>^ _Right);
//	bool less_than(_STLCLR Generic::IRandomAccessIterator<_Value_t>^ _Right);

	// operators
	static const_reference operator->(
		UncheckedBidirectionalIterator% _Left)
		{	// return pointer to class object
		return (_Left.get_ref());
		}

	static const_reference operator*(
		UncheckedBidirectionalIterator% _Left)
		{	// return const reference to designated element
		return (_Left.get_ref());
		}

#pragma warning(push)
#pragma warning(disable:4460)
	static UncheckedBidirectionalIterator operator++(
		UncheckedBidirectionalIterator% _Left)
		{	// return incremented
		_Left.next();
		return (_Left);
		}
#pragma warning(pop)

	bool operator==(_STLCLR Generic::IInputIterator<_Value_t>^ _Right)
		{	// test if *this == _Right
		return (equal_to(_Right));
		}

	bool operator==(_Mytype_t% _Right)
		{	// test if *this == _Right
		return (equal_to(_Right));
		}

	bool operator!=(_STLCLR Generic::IInputIterator<_Value_t>^ _Right)
		{	// test if *this != _Right
		return (!(*this == _Right));
		}

	bool operator!=(_Mytype_t% _Right)
		{	// test if *this != _Right
		return (!(*this == _Right));
		}

#pragma warning(push)
#pragma warning(disable:4460)
	static UncheckedBidirectionalIterator operator--(
		UncheckedBidirectionalIterator% _Left)
		{	// return decremented
		_Left.prev();
		return (_Left);
		}

//	static UncheckedBidirectionalIterator operator+(
//		UncheckedBidirectionalIterator _Left,
//		difference_type _Right);
//	static UncheckedBidirectionalIterator operator+(
//		difference_type _Left,
//		UncheckedBidirectionalIterator _Right);
//	static UncheckedBidirectionalIterator operator-(
//		difference_type _Right);
//	difference_type operator-(UncheckedBidirectionalIterator _Right);
//	bool operator<(_STLCLR Generic::IBidirectionalIterator^ _Right);
//	bool operator>=(_STLCLR Generic::IBidirectionalIterator^ _Right);
//	bool operator>(_STLCLR Generic::IBidirectionalIterator^ _Right);
//	bool operator<=(_STLCLR Generic::IBidirectionalIterator^ _Right);
//	property const_reference default[difference_type];

_STLCLR_FIELD_ACCESS:
	// data members
	node_type^ _Mynode;	// node into list

private:
	virtual int get_bias_virtual() sealed
		= _Myiter_t::get_bias
		{	// get offset from wrapped iterator
		return (get_bias());
		}

	virtual System::Object^ get_node_virtual() sealed
		= _Myiter_t::get_node

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -