|
|
|
1 |
|
// deque stl/clr header |
2 |
|
#ifndef _CLI_DEQUE_ |
3 |
|
#define _CLI_DEQUE_ |
4 |
|
#include <cliext/iterator> |
5 |
|
|
6 |
|
namespace cliext { |
7 |
|
namespace impl { |
8 |
|
// |
9 |
|
// TEMPLATE CLASS _Get_sizeof |
10 |
|
// |
11 |
|
template<typename _Value_t> |
12 |
|
value struct _Get_sizeof |
13 |
|
{ // get size of a type |
14 |
|
static int value() |
15 |
|
{ // return size |
16 |
|
try |
17 |
|
{ // try to determine size of type |
18 |
|
return (System::Runtime::InteropServices::Marshal:: |
19 |
|
SizeOf(_Value_t::typeid)); |
20 |
|
} |
21 |
|
catch (System::Object^) |
22 |
|
{ // failed, assume int |
23 |
|
return (4); |
24 |
|
} |
25 |
|
} |
26 |
|
}; |
27 |
|
|
28 |
|
template<typename _Value_t> |
29 |
|
value struct _Get_sizeof<_Value_t^> |
30 |
|
{ // get size of a handle type |
31 |
|
static int value() |
32 |
|
{ // return size |
33 |
|
return (System::Runtime::InteropServices::Marshal:: |
34 |
|
SizeOf(System::IntPtr::typeid)); |
35 |
|
} |
36 |
|
}; |
37 |
|
|
38 |
|
// |
39 |
|
// TEMPLATE CLASS deque_impl |
40 |
|
// |
41 |
|
template<typename _Value_t, |
42 |
|
bool _Is_ref> |
43 |
|
ref class deque_impl |
44 |
|
: public _STLCLR IDeque<_Value_t> |
45 |
|
{ // double-ended queue of elements |
46 |
|
public: |
47 |
|
// types |
48 |
|
typedef deque_impl<_Value_t, _Is_ref> _Mytype_t; |
49 |
|
typedef _STLCLR IDeque<_Value_t> _Mycont_it; |
50 |
|
typedef System::Collections::Generic::IEnumerable<_Value_t> _Myenum_it; |
51 |
|
typedef cli::array<_Value_t> _Myarray_t; |
52 |
|
typedef cli::array<_Myarray_t^> _Mymap_t; |
53 |
|
typedef _Cont_make_value<_Value_t, _Is_ref> _Mymake_t; |
1624 |
|
{ // test if _Left < _Right |
1625 |
|
deque<_Value_t>::size_type _Idx = 0; |
1626 |
|
|
1627 |
|
for (; _Idx != _Left.size() && _Idx != _Right.size(); ++_Idx) |
1628 |
|
if (_Left.at(_Idx) < _Right.at(_Idx)) |
1629 |
|
return (true); |
1630 |
|
else if (_Right.at(_Idx) < _Left.at(_Idx)) |
1631 |
|
return (false); |
1632 |
|
return (_Idx == _Left.size() && _Idx != _Right.size()); |
1633 |
|
} |
1634 |
|
|
1635 |
|
template<typename _Value_t> inline |
1636 |
|
bool operator>=(deque<_Value_t>% _Left, |
1637 |
|
deque<_Value_t>% _Right) |
1638 |
|
{ // test if _Left >= _Right |
1639 |
|
return (!(_Left < _Right)); |
1640 |
|
} |
1641 |
|
|
1642 |
|
template<typename _Value_t> inline |
1643 |
|
bool operator>(deque<_Value_t>% _Left, |
1644 |
|
deque<_Value_t>% _Right) |
1645 |
|
{ // test if _Left > _Right |
1646 |
|
return (_Right < _Left); |
1647 |
|
} |
1648 |
|
|
1649 |
|
template<typename _Value_t> inline |
1650 |
|
bool operator<=(deque<_Value_t>% _Left, |
1651 |
|
deque<_Value_t>% _Right) |
1652 |
|
{ // test if _Left <= _Right |
1653 |
|
return (!(_Right < _Left)); |
1654 |
|
} |
1655 |
|
|
1656 |
|
// |
1657 |
|
// TEMPLATE FUNCTION std::swap |
1658 |
|
// |
1659 |
|
template<typename _Value_t> inline |
1660 |
|
void swap(deque<_Value_t>% _Left, |
1661 |
|
deque<_Value_t>% _Right) |
1662 |
|
{ // swap two deques |
1663 |
|
_Left.swap(_Right); |
1664 |
|
} |
1665 |
|
} // namespace cliext |
1666 |
|
#endif // _CLI_DEQUE_ |
1667 |
|
|
1668 |
|
/* |
1669 |
|
* Copyright (c) 2004-2007 by Dinkumware, Ltd. ALL RIGHTS RESERVED. |
1670 |
|
* Consult your license regarding permissions and restrictions. |
1671 |
|
V5.03:0009 */ |
1672 |
|
|
|
|
|