|
|
|
| 1 |
|
// queue stl/clr header |
| 2 |
|
#ifndef _CLI_QUEUE_ |
| 3 |
|
#define _CLI_QUEUE_ |
| 4 |
|
#include <cliext/algorithm> // for push/pop heap |
| 5 |
|
#include <cliext/deque> // for default queue container |
| 6 |
|
#include <cliext/functional> // for BinaryDelegate |
| 7 |
|
#include <cliext/iterator> |
| 8 |
|
#include <cliext/vector> // for default priority_queue container |
| 9 |
|
|
| 10 |
|
namespace cliext { |
| 11 |
|
namespace impl { |
| 12 |
|
// |
| 13 |
|
// TEMPLATE CLASS queue_base |
| 14 |
|
// |
| 15 |
|
template<typename _Value_t, |
| 16 |
|
typename _Cont_t> |
| 17 |
|
ref class queue_base |
| 18 |
|
: public _STLCLR IQueue<_Value_t, |
| 19 |
|
typename _Container_traits<_Cont_t>::generic_container_handle> |
| 20 |
|
{ // FIFO queue of elements |
| 21 |
|
public: |
| 22 |
|
// types |
| 23 |
|
typedef queue_base<_Value_t, _Cont_t> _Mytype_t; |
| 24 |
|
typedef _STLCLR IQueue<_Value_t, |
| 25 |
|
typename _Container_traits<_Cont_t>::generic_container_handle> |
| 26 |
|
_Mycont_it; |
| 27 |
|
typedef cli::array<_Value_t> _Myarray_t; |
| 28 |
|
|
| 29 |
|
typedef int size_type; |
| 30 |
|
typedef int difference_type; |
| 31 |
|
typedef _Value_t value_type; |
| 32 |
|
typedef value_type% reference; |
| 33 |
|
typedef value_type% const_reference; |
| 34 |
|
|
| 35 |
|
typedef _Mycont_it generic_container; |
| 36 |
|
typedef value_type generic_value; |
| 37 |
|
|
| 38 |
|
typedef typename _Dehandle<_Cont_t>::type container_type; |
| 39 |
|
|
| 40 |
|
// basics |
| 41 |
|
queue_base() |
| 42 |
|
: c(gcnew container_type) |
| 43 |
|
{ // default constructor |
| 44 |
|
} |
| 45 |
|
|
| 46 |
|
queue_base% operator=(queue_base% _Right) |
| 47 |
|
{ // assign |
| 48 |
|
assign(_Right); |
| 49 |
|
return (*this); |
| 50 |
|
} |
| 51 |
|
|
| 52 |
|
operator _Mycont_it^() |
| 53 |
|
{ // convert to interface |
| 865 |
|
explicit priority_queue(value_compare^ _Pred) |
| 866 |
|
: _Mybase_t(_Pred) |
| 867 |
|
{ // construct with empty container, specified predicate |
| 868 |
|
} |
| 869 |
|
|
| 870 |
|
priority_queue(value_compare^ _Pred, container_type% _Cont) |
| 871 |
|
: _Mybase_t(_Pred, _Cont) |
| 872 |
|
{ // construct with specified predicate and container |
| 873 |
|
cliext::make_heap(c->begin(), c->end(), comp); |
| 874 |
|
} |
| 875 |
|
|
| 876 |
|
template<typename _Iter> |
| 877 |
|
priority_queue(_Iter _First, _Iter _Last) |
| 878 |
|
{ // construct by copying [_First, _Last), default comparator |
| 879 |
|
c->insert(c->end(), _First, _Last); |
| 880 |
|
cliext::make_heap(c->begin(), c->end(), comp); |
| 881 |
|
} |
| 882 |
|
|
| 883 |
|
template<typename _Iter> |
| 884 |
|
priority_queue(_Iter _First, _Iter _Last, value_compare^ _Pred) |
| 885 |
|
: _Mybase_t(_Pred) |
| 886 |
|
{ // construct by copying [_First, _Last), specified comparator |
| 887 |
|
c->insert(c->end(), _First, _Last); |
| 888 |
|
cliext::make_heap(c->begin(), c->end(), comp); |
| 889 |
|
} |
| 890 |
|
|
| 891 |
|
template<typename _Iter> |
| 892 |
|
priority_queue(_Iter _First, _Iter _Last, value_compare^ _Pred, |
| 893 |
|
container_type% _Cont) |
| 894 |
|
: _Mybase_t(_Pred, _Cont) |
| 895 |
|
{ // construct by copying [_First, _Last), container, and comparator |
| 896 |
|
c->insert(c->end(), _First, _Last); |
| 897 |
|
cliext::make_heap(c->begin(), c->end(), comp); |
| 898 |
|
} |
| 899 |
|
|
| 900 |
|
// interfaces |
| 901 |
|
virtual System::Object^ Clone() override |
| 902 |
|
{ // clone the vector |
| 903 |
|
return (gcnew _Mytype_t(*this)); |
| 904 |
|
} |
| 905 |
|
}; |
| 906 |
|
} // namespace cliext |
| 907 |
|
#endif // _CLI_QUEUE_ |
| 908 |
|
|
| 909 |
|
/* |
| 910 |
|
* Copyright (c) 2004-2007 by Dinkumware, Ltd. ALL RIGHTS RESERVED. |
| 911 |
|
* Consult your license regarding permissions and restrictions. |
| 912 |
|
V5.03:0009 */ |
| 913 |
|
|
|
|
|