#ifndef VCZH_COLLECTIONS_OPERATION
#define VCZH_COLLECTIONS_OPERATION
#include "OperationCopyFrom.h"
#include "OperationEnumerable.h"
#include "OperationSelect.h"
#include "OperationWhere.h"
#include "OperationConcat.h"
#include "OperationSequence.h"
#include "OperationSet.h"
#include "OperationPair.h"
#include "OperationString.h"
#include "OperationForEach.h"
namespace
{
namespace
{
template
<
typename
,
typename
>
void
(
*
,
,
)
{
if
(
==
0
)
return
;
=
0
;
=
0
;
=
0
;
bool
=
false
;
while
(
left
+
right
+
1
!=
)
{
&
= (
flag
?
left
:
right
);
&
= (
flag
?
right
:
left
);
= (
flag
?
left
:
-
right
-
1
);
= (
flag
? -
1
:
1
);
if
(
(
[
pivot
],
[
candidate
])*
factor
<=
0
)
{
mine
++;
}
else
{
theirs
++;
=
[
pivot
];
[
pivot
] =
[
candidate
];
[
candidate
] =
temp
;
pivot
=
candidate
;
flag
= !
flag
;
}
}
(
,
left
,
);
(
+
left
+
1
,
right
,
);
}
template
<
typename
>
void
(
*
,
,
const
<
(
,
)>&
)
{
<
,
<
(
,
)>>(
,
,
);
}
template
<
typename
>
class
:
public
,
public
<
>
{
protected
:
<
<
>>
;
<
>*
()
const
{
return
();
}
public
:
(
<
>*
)
:enumeratorPrototype(
)
{
}
(
<
<
>>
)
:enumeratorPrototype(
)
{
}
(
const
<
>&
)
:enumeratorPrototype(
.
())
{
}
(
const
<
>&
)
:enumeratorPrototype(
.
)
{
}
template
<
typename
>
(
<
>
)
:enumeratorPrototype(
new
<
,
>(
))
{
}
()
:enumeratorPrototype(
<
>().
())
{
}
<
>&
(
const
<
>&
)
{
.
;
return
*
this
;
}
<
>*
()
const
{
return
();
}
template
<
typename
>
LazyList<FUNCTION_RESULT_TYPE(F)> Select(F f)const
<
typename
vl
::
function_lambda
::
FunctionObjectRetriveType
<
>::
>
(
)
const
{
return new SelectEnumerator<T, FUNCTION_RESULT_TYPE(F)>(xs(), f);
return
new
<
,
typename
vl
::
function_lambda
::
FunctionObjectRetriveType
<
>::
>(
(),
);
}
template
<
typename
>
<
>
(
)
const
{
return
new
<
>(
(),
);
}
template
<
typename
>
<
<
>>
()
const
{
<
<
>(
)>
=[](
)->
<
>{
return
t
.
template
Cast<
>();};
return
new
<
,
<
>>(
(),
f
);
}
template
<
typename
>
<
<
>>
()
const
{
return
<
>().
([](
<
>
){
return
t
;});
}
template
<
typename
>
<
>
(
)
const
{
<
<
>>
=
new
<
>;
(*
sorted
.
(), *
this
);
if
(
sorted
()>
0
)
{
<
,
>(&
sorted
0
),
sorted
(),
);
}
return
new
<
,
<
>>(
sorted
);
}
template
<
typename
>
(
)
const
{
<
<
>>
=
();
if
(!
enumerator
())
{
throw
(
L"LazyList<T>::Aggregate(F)#Aggregate failed to calculate from an empty container."
);
}
=
enumerator
();
while
(
enumerator
())
{
result
=
(
result
,
enumerator
());
}
return
result
;
}
template
<
typename
,
typename
>
(
,
)
const
{
FOREACH(T, t, *this)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
>&
= ::
vl
::
collections
::
(*
this
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
;
__foreach_iterator__
.
(
t
);)
{
=
(
,
t
);
}
return
;
}
template
<
typename
>
bool
(
)
const
{
return
(
).
(
true
, [](
bool
,
bool
){
return
a
&&
b
;});
}
template
<
typename
>
bool
(
)
const
{
return
(
).
(
false
, [](
bool
,
bool
){
return
a
||
b
;});
}
()
const
{
return
([](
,
){
return
a
>
b
?
a
:
b
;});
}
()
const
{
return
([](
,
){
return
a
<
b
?
a
:
b
;});
}
()
const
{
<
<
>>
=
();
if
(!
enumerator
())
{
throw
(
L"LazyList<T>::First(F)#First failed to calculate from an empty container."
);
}
return
enumerator
();
}
(
)
const
{
<
<
>>
=
();
if
(!
enumerator
())
{
return
;
}
return
enumerator
();
}
()
const
{
<
<
>>
=
();
if
(!
enumerator
())
{
throw
(
L"LazyList<T>::Last(F)#Last failed to calculate from an empty container."
);
}
else
{
=
enumerator
();
while
(
enumerator
())
{
value
=
enumerator
();
}
return
value
;
}
}
(
)
const
{
<
<
>>
=
();
while
(
enumerator
())
{
=
enumerator
();
}
return
;
}
()
const
{
=
0
;
<
<
>>
=
();
while
(
enumerator
())
{
result
++;
}
return
result
;
}
bool
()
const
{
<
<
>>
=
();
return
!
enumerator
();
}
<
>
(
const
<
>&
)
const
{
return
new
<
>(
(),
.
());
}
<
>
(
)
const
{
return
new
<
>(
(),
);
}
<
>
(
)
const
{
return
new
<
>(
(),
);
}
<
>
(
)
const
{
return
new
<
>(
(),
);
}
<
>
()
const
{
return
new
<
>(
());
}
<
>
()
const
{
return
new
<
>(*
this
);
}
template
<
typename
>
<
<
,
>>
(
const
<
>&
)
const
{
return
new
<
,
>(
(),
.
());
}
<
>
(
const
<
>&
)
const
{
return
<
>(
new
IntersectExceptEnumerator
<
,
true
>(
(),
)).
();
}
<
>
(
const
<
>&
)
const
{
return
<
>(
new
IntersectExceptEnumerator
<
,
false
>(
(),
)).
();
}
<
>
(
const
<
>&
)
const
{
return
(
).
();
}
<
>
(
bool
=
false
)
const
{
if
(!
&&
())
{
return
*
this
;
}
else
{
<
<
>>
=
new
<
>;
(*
xs
.
(), *
this
);
return
xs
;
}
}
template
<
typename
>
FUNCTION_RESULT_TYPE(F) SelectMany(F f)const
typename
vl
::
function_lambda
::
FunctionObjectRetriveType
<
>::
(
)
const
{
typedef FUNCTION_RESULT_TYPE(F) LazyListU;
typedef
typename
vl
::
function_lambda
::
FunctionObjectRetriveType
<
>::
;
typedef
typename
::ElementType
;
return
(
).
(
<
>(), [](
const
<
>&
,
const
<
>&
)->
<
>{
return
a
.
(
b
);});
}
template
<
typename
>
LazyList<Pair<FUNCTION_RESULT_TYPE(F), LazyList<T>>> GroupBy(F f)const
<
<
typename
vl
::
function_lambda
::
FunctionObjectRetriveType
<
>::
,
<
>>>
(
)
const
{
typedef FUNCTION_RESULT_TYPE(F) K;
typedef
typename
vl
::
function_lambda
::
FunctionObjectRetriveType
<
>::
;
auto
= *
this
;
return
(
)
.
()
.
([=](
)
{
return
<
,
<
>>(
k
,
self
.
([=](
){
return
k
==
(
t
);})
);
});
}
};
template
<
typename
>
<
>
(
,
)
{
return
new
<
>(
,
);
}
template
<
typename
>
<
>
(
const
<
>&
)
{
return
;
}
template
<
typename
>
<
>
(
const
<
>&
)
{
return
;
}
template
<
typename
>
<
>
(
const
*
,
const
*
)
{
return
(
,
);
}
template
<
typename
,
int
>
<
>
(
(&
)[
])
{
return
(
);
}
template
<
typename
,
int
>
<
>
(
const
(&
)[
])
{
return
(
);
}
}
}
#endif