|
|
|
| 1 |
|
// iterator stl/clr header |
| 2 |
|
#ifndef _CLI_ITERATOR_ |
| 3 |
|
#define _CLI_ITERATOR_ |
| 4 |
|
#include <cliext/xutility> |
| 5 |
|
|
| 6 |
|
namespace cliext { |
| 7 |
|
// |
| 8 |
|
// TEMPLATE FUNCTION _Unchecked |
| 9 |
|
// |
| 10 |
|
template<typename _Iter_t> inline |
| 11 |
|
_Iter_t _Unchecked(_Iter_t _Iter) |
| 12 |
|
{ // return unknown iterator unchanged |
| 13 |
|
return (_Iter); |
| 14 |
|
} |
| 15 |
|
|
| 16 |
|
// |
| 17 |
|
// TEMPLATE VALUE CLASS ConstBidirectionalIterator |
| 18 |
|
// |
| 19 |
|
template<typename _Cont_t> |
| 20 |
|
value class ConstBidirectionalIterator |
| 21 |
|
: public _STLCLR Generic::IBidirectionalIterator< |
| 22 |
|
typename _Cont_t::value_type> |
| 23 |
|
{ // iterator for nonmutable bidirectional container |
| 24 |
|
public: |
| 25 |
|
// types |
| 26 |
|
typedef typename _Cont_t::value_type _Value_t; |
| 27 |
|
typedef ConstBidirectionalIterator<_Cont_t> _Mytype_t; |
| 28 |
|
typedef _STLCLR Generic::IBidirectionalIterator<_Value_t> _Myiter_t; |
| 29 |
|
typedef typename _Cont_t::node_type node_type; |
| 30 |
|
|
| 31 |
|
typedef bidirectional_iterator_tag iterator_category; |
| 32 |
|
typedef _Value_t value_type; |
| 33 |
|
typedef int difference_type; |
| 34 |
|
typedef value_type% pointer; |
| 35 |
|
typedef value_type% reference; |
| 36 |
|
typedef value_type% const_reference; |
| 37 |
|
|
| 38 |
|
// constructors and special members |
| 39 |
|
ConstBidirectionalIterator(node_type^ _Node) |
| 40 |
|
: _Mynode(_Node) |
| 41 |
|
{ // construct from node |
| 42 |
|
} |
| 43 |
|
|
| 44 |
|
// generic conversions |
| 45 |
|
typedef _STLCLR Generic::ConstContainerBidirectionalIterator<_Value_t> |
| 46 |
|
_Mygeniter_t; |
| 47 |
|
|
| 48 |
|
ConstBidirectionalIterator(_Mygeniter_t% _Right) |
| 49 |
|
: _Mynode((node_type^)_Right.get_node()) |
| 50 |
|
{ // construct by copying a generic iterator |
| 51 |
|
} |
| 52 |
|
|
| 53 |
|
operator _Mygeniter_t() |
| 4217 |
|
|
| 4218 |
|
// iterator generators |
| 4219 |
|
iterator make_iterator(size_type _Offset) |
| 4220 |
|
{ // return iterator for offset |
| 4221 |
|
return (_Myiter_t(this, _Offset)); |
| 4222 |
|
} |
| 4223 |
|
|
| 4224 |
|
iterator begin() |
| 4225 |
|
{ // return iterator for beginning of mutable sequence |
| 4226 |
|
return (make_iterator(0)); |
| 4227 |
|
} |
| 4228 |
|
|
| 4229 |
|
iterator end() |
| 4230 |
|
{ // return iterator for end of mutable sequence |
| 4231 |
|
return (make_iterator(_Myarray->Length)); |
| 4232 |
|
} |
| 4233 |
|
|
| 4234 |
|
// size controllers |
| 4235 |
|
int size() |
| 4236 |
|
{ // return length of sequence |
| 4237 |
|
return (_Myarray->Length); |
| 4238 |
|
} |
| 4239 |
|
|
| 4240 |
|
_STLCLR_FIELD_ACCESS: |
| 4241 |
|
_Myarray_t^ _Myarray; // the wrapped array |
| 4242 |
|
}; |
| 4243 |
|
|
| 4244 |
|
// |
| 4245 |
|
// TEMPLATE FUNCTION _Iter_container |
| 4246 |
|
// |
| 4247 |
|
template<typename _Iter_t> inline |
| 4248 |
|
System::Object^ _Iter_container(_Iter_t% _Next) |
| 4249 |
|
{ // get container for arbitrary iterator |
| 4250 |
|
return (_Next.container()); |
| 4251 |
|
} |
| 4252 |
|
|
| 4253 |
|
template<typename _Iter_t> inline |
| 4254 |
|
System::Object^ _Iter_container(_Iter_t^ _Next) |
| 4255 |
|
{ // get container for arbitrary iterator |
| 4256 |
|
return (_Next->container()); |
| 4257 |
|
} |
| 4258 |
|
} // namespace cliext |
| 4259 |
|
#endif // _CLI_ITERATOR_ |
| 4260 |
|
|
| 4261 |
|
/* |
| 4262 |
|
* Copyright (c) 2004-2007 by Dinkumware, Ltd. ALL RIGHTS RESERVED. |
| 4263 |
|
* Consult your license regarding permissions and restrictions. |
| 4264 |
|
V5.03:0009 */ |
| 4265 |
|
|
|
|
|