|
|
|
| 1 |
|
// list stl/clr header |
| 2 |
|
#ifndef _CLI_LIST_ |
| 3 |
|
#define _CLI_LIST_ |
| 4 |
|
#include <cliext/functional> |
| 5 |
|
#include <cliext/iterator> |
| 6 |
|
|
| 7 |
|
namespace cliext { |
| 8 |
|
namespace impl { |
| 9 |
|
// |
| 10 |
|
// TEMPLATE REF CLASS list_node |
| 11 |
|
// |
| 12 |
|
template<typename _Value_t> |
| 13 |
|
ref class list_node |
| 14 |
|
: public _STLCLR Generic::INode<_Value_t> |
| 15 |
|
{ // list node |
| 16 |
|
public: |
| 17 |
|
typedef list_node<_Value_t> _Mytype_t; |
| 18 |
|
typedef _STLCLR Generic::INode<_Value_t> _Mynode_it; |
| 19 |
|
typedef _STLCLR Generic::IBidirectionalContainer<_Value_t> _Mycont_it; |
| 20 |
|
typedef _Value_t value_type; |
| 21 |
|
|
| 22 |
|
list_node(_Mycont_it^ _Owner) |
| 23 |
|
: _Mycont(_Owner) |
| 24 |
|
{ // construct a node with defaults |
| 25 |
|
} |
| 26 |
|
|
| 27 |
|
_Mycont_it^ container() |
| 28 |
|
{ // return owning container |
| 29 |
|
return (_Head == nullptr ? nullptr : _Head->_Mycont); |
| 30 |
|
} |
| 31 |
|
|
| 32 |
|
bool is_head() |
| 33 |
|
{ // test if head node |
| 34 |
|
return (_Mycont != nullptr); |
| 35 |
|
} |
| 36 |
|
|
| 37 |
|
_Mytype_t^ next_node() |
| 38 |
|
{ // return successor node |
| 39 |
|
if (this == _Head || _Head == nullptr) |
| 40 |
|
throw gcnew System::InvalidOperationException(); |
| 41 |
|
return (_Next); |
| 42 |
|
} |
| 43 |
|
|
| 44 |
|
_Mytype_t^ prev_node() |
| 45 |
|
{ // return predecessor node |
| 46 |
|
if (_Head == _Prev || _Head == nullptr) |
| 47 |
|
throw gcnew System::InvalidOperationException(); |
| 48 |
|
return (_Prev); |
| 49 |
|
} |
| 50 |
|
|
| 51 |
|
property _Value_t% _Value |
| 52 |
|
{ // get or set _Myval |
| 53 |
|
virtual _Value_t% get() |
| 1821 |
|
if (_Pleft->_Myval < _Pright->_Myval) |
| 1822 |
|
return (true); |
| 1823 |
|
else if (_Pright->_Myval < _Pleft->_Myval) |
| 1824 |
|
return (false); |
| 1825 |
|
_Pleft = _Pleft->_Next; |
| 1826 |
|
_Pright = _Pright->_Next; |
| 1827 |
|
} |
| 1828 |
|
return (_Idx == _Left.size() && _Idx != _Right.size()); |
| 1829 |
|
} |
| 1830 |
|
|
| 1831 |
|
template<typename _Value_t> inline |
| 1832 |
|
bool operator>=(list<_Value_t>% _Left, |
| 1833 |
|
list<_Value_t>% _Right) |
| 1834 |
|
{ // test if _Left >= _Right |
| 1835 |
|
return (!(_Left < _Right)); |
| 1836 |
|
} |
| 1837 |
|
|
| 1838 |
|
template<typename _Value_t> inline |
| 1839 |
|
bool operator>(list<_Value_t>% _Left, |
| 1840 |
|
list<_Value_t>% _Right) |
| 1841 |
|
{ // test if _Left > _Right |
| 1842 |
|
return (_Right < _Left); |
| 1843 |
|
} |
| 1844 |
|
|
| 1845 |
|
template<typename _Value_t> inline |
| 1846 |
|
bool operator<=(list<_Value_t>% _Left, |
| 1847 |
|
list<_Value_t>% _Right) |
| 1848 |
|
{ // test if _Left <= _Right |
| 1849 |
|
return (!(_Right < _Left)); |
| 1850 |
|
} |
| 1851 |
|
|
| 1852 |
|
// |
| 1853 |
|
// TEMPLATE FUNCTION swap |
| 1854 |
|
// |
| 1855 |
|
template<typename _Value_t> inline |
| 1856 |
|
void swap(list<_Value_t>% _Left, |
| 1857 |
|
list<_Value_t>% _Right) |
| 1858 |
|
{ // swap two lists |
| 1859 |
|
_Left.swap(_Right); |
| 1860 |
|
} |
| 1861 |
|
|
| 1862 |
|
} // namespace cliext |
| 1863 |
|
#endif // _CLI_LIST_ |
| 1864 |
|
|
| 1865 |
|
/* |
| 1866 |
|
* Copyright (c) 2004-2007 by Dinkumware, Ltd. ALL RIGHTS RESERVED. |
| 1867 |
|
* Consult your license regarding permissions and restrictions. |
| 1868 |
|
V5.03:0009 */ |
| 1869 |
|
|
|
|
|