#ifndef VCZH_COLLECTIONS_PARTIALORDERING
#define VCZH_COLLECTIONS_PARTIALORDERING
#include "Dictionary.h"
namespace
{
namespace
{
namespace
{
struct
{
bool
=
false
;
= -
1
;
const
<
>*
=
nullptr
;
const
<
>*
=
nullptr
;
const
*
=
nullptr
;
=
0
;
};
struct
{
const
*
=
nullptr
;
=
0
;
};
}
}
namespace
{
class
:
public
{
template
<
typename
>
using
=
<
typename
::ElementType,
typename
::ElementType>;
protected
:
<
>
;
<
,
>
;
<
,
>
;
<
>
;
<
>
;
void
(
);
void
(
po
::
&
,
<
>&
,
&
);
void
(
po
::
&
,
,
&
);
public
:
<
po
::
>
;
<
po
::
>
;
void
();
template
<
typename
>
void
(
const
&
,
const
<
>&
)
{
CHECK_ERROR(nodes.Count() == 0, L"PartialOrdering::InitWithGroup(items, depGroup)#Initializing twice is not allowed.");
do
{
if
(!(
.
() ==
0
))
throw
(
L"PartialOrdering::InitWithGroup(items, depGroup)#Initializing twice is not allowed."
);}
while
(
0
);
for
(
=
0
;
i
<
.
();
i
++)
{
=
.IndexOf(
<
typename
::ElementType>::
(
.
()
i
]));
CHECK_ERROR(fromNode != -1, L"PartialOrdering::InitWithGroup(items, depGroup)#The key in outsGroup does not exist in items.");
do
{
if
(!(
fromNode
!= -
1
))
throw
(
L"PartialOrdering::InitWithGroup(items, depGroup)#The key in outsGroup does not exist in items."
);}
while
(
0
);
auto
&
=
.
(
i
);
for
(
=
0
;
j
<
edges
.
();
j
++)
{
=
.IndexOf(
<
typename
::ElementType>::
(
edges
j
]));
CHECK_ERROR(toNode != -1, L"PartialOrdering::InitWithGroup(items, depGroup)#The value in outsGroup does not exist in items.");
do
{
if
(!(
toNode
!= -
1
))
throw
(
L"PartialOrdering::InitWithGroup(items, depGroup)#The value in outsGroup does not exist in items."
);}
while
(
0
);
.
(
fromNode
,
toNode
);
.
(
toNode
,
fromNode
);
}
}
(
.Count());
}
template
<
typename
,
typename
>
void
(
const
&
,
&&
)
{
<
>
;
for
(
=
0
;
i
<
.Count();
i
++)
{
for
(
=
0
;
j
<
.Count();
j
++)
{
if
(
(
[
i
],
[
j
]))
{
depGroup
.
(
[
i
],
[
j
]);
}
}
}
(
,
depGroup
);
}
template
<
typename
,
typename
>
void
(
const
&
,
const
<
>&
,
const
<
typename
::ElementType,
>&
)
{
CHECK_ERROR(nodes.Count() == 0, L"PartialOrdering::InitWithSubClass(items, degGroup, subClasses)#Initializing twice is not allowed.");
do
{
if
(!(
.
() ==
0
))
throw
(
L"PartialOrdering::InitWithSubClass(items, degGroup, subClasses)#Initializing twice is not allowed."
);}
while
(
0
);
using
=
typename
::ElementType;
using
=
<
>;
<
,
>
;
<
>
;
for
(
=
0
;
i
<
.
();
i
++)
{
const
auto
&
=
.
()
i
];
const
auto
&
=
.
()
i
];
scItems
.
(
value
,
key
);
}
for
(
=
0
;
i
<
.Count();
i
++)
{
const
auto
&
=
[
i
];
if
(!
.
().
(
::
(
item
)))
{
singleItems
.
(
item
);
}
}
auto
= [&](
const
&
)
{
=
.
().
(
::
(
item
));
if
(
index
!= -
1
)
{
index
=
scItems
.
().
(
<
>::
(
.
()
index
]));
CHECK_ERROR(index != -1, L"PartialOrdering::InitWithSubClass(items, degGroup, subClasses)#Internal Error.");
do
{
if
(!(
index
!= -
1
))
throw
(
L"PartialOrdering::InitWithSubClass(items, degGroup, subClasses)#Internal Error."
);}
while
(
0
);
return
index
;
}
else
{
index
=
singleItems
.
(
::
(
item
));
CHECK_ERROR(index != -1, L"PartialOrdering::InitWithSubClass(items, degGroup, subClasses)#Internal Error.");
do
{
if
(!(
index
!= -
1
))
throw
(
L"PartialOrdering::InitWithSubClass(items, degGroup, subClasses)#Internal Error."
);}
while
(
0
);
return
scItems
.
() +
index
;
}
};
for
(
=
0
;
i
<
.
();
i
++)
{
const
auto
&
=
.
()
i
];
=
getSubClass
(
key
);
const
auto
&
=
.
(
i
);
for
(
=
0
;
j
<
values
.
();
j
++)
{
const
auto
&
=
values
j
];
=
getSubClass
(
value
);
if
(!
.
(
keyIndex
,
valueIndex
))
{
.
(
keyIndex
,
valueIndex
);
}
}
}
for
(
=
0
;
i
<
.
();
i
++)
{
=
.
()
i
];
const
auto
&
=
.
(
i
);
for
(
=
0
;
j
<
values
.
();
j
++)
{
.
(
values
j
],
key
);
}
}
(
scItems
.
() +
singleItems
.
());
.
(
.Count());
=
0
;
=
scItems
.
().
();
for
(
=
0
;
i
<
.
();
i
++)
{
auto
&
=
i
];
node
.
= &
used
];
if
(
i
<
scItemCount
)
{
const
auto
&
=
scItems
.
(
i
);
for
(
=
0
;
j
<
values
.
();
j
++)
{
used
++] =
.IndexOf(
::
(
values
j
]));
}
node
.
=
values
.
();
}
else
{
used
++] =
.IndexOf(
::
(
singleItems
i
-
scItemCount
]));
node
.
=
1
;
}
}
}
};
}
}
#endif