添加算法改进
This commit is contained in:
parent
46fc8b0cb2
commit
a3e255a991
|
@ -6,9 +6,9 @@
|
|||
<LocalDebuggerCommandArguments>-path "D:\手作小说\科学+修仙+创造世界"</LocalDebuggerCommandArguments>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<QtLastBackgroundBuild>2024-05-04T09:33:58.7289365Z</QtLastBackgroundBuild>
|
||||
<QtLastBackgroundBuild>2024-05-04T13:29:44.1342154Z</QtLastBackgroundBuild>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<QtLastBackgroundBuild>2024-05-04T09:33:58.9501188Z</QtLastBackgroundBuild>
|
||||
<QtLastBackgroundBuild>2024-05-04T13:29:44.5012357Z</QtLastBackgroundBuild>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -5,9 +5,9 @@
|
|||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<QtLastBackgroundBuild>2024-05-04T09:33:59.3486956Z</QtLastBackgroundBuild>
|
||||
<QtLastBackgroundBuild>2024-05-04T13:29:47.7605591Z</QtLastBackgroundBuild>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<QtLastBackgroundBuild>2024-05-04T09:33:59.5091441Z</QtLastBackgroundBuild>
|
||||
<QtLastBackgroundBuild>2024-05-04T13:29:47.9767101Z</QtLastBackgroundBuild>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -122,39 +122,51 @@ void FragmentOrdersCheck::elements_link_build(const QList<std::shared_ptr<StoryS
|
|||
}
|
||||
}
|
||||
|
||||
void FragmentOrdersCheck::sort_cycle_check(const QList<std::shared_ptr<FragmentSortHelper>>& tracks, std::shared_ptr<FragmentSortHelper> current, int story_sort_source)
|
||||
template<class InputIt, class OutputIt, class Operate>
|
||||
void cast(InputIt Begin, InputIt End, OutputIt Dst, Operate fn) {
|
||||
while (Begin != End) {
|
||||
*Dst++ = fn(*Begin++);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FragmentOrdersCheck::sort_cycle_check(const QList<std::shared_ptr<FragmentSortHelper>>& tracks, std::shared_ptr<FragmentSortHelper> _current, int story_sort_source)
|
||||
{
|
||||
if (!current)
|
||||
if (!_current || !_current->next())
|
||||
return;
|
||||
|
||||
if (tracks.contains(current)) {
|
||||
auto target = _current->next();
|
||||
|
||||
if (tracks.contains(peaks_appoint_element(target))) {
|
||||
QString error_cycle;
|
||||
for (auto& it : tracks)
|
||||
error_cycle += u8"->" + it->nodeBind()->element()->signature() + u8"\n";
|
||||
error_cycle += u8"->" + current->nodeBind()->element()->signature() + u8"¡£";
|
||||
error_cycle += u8"->" + target->nodeBind()->element()->signature() + u8"¡£";
|
||||
|
||||
throw new lib_parse::CheckException(u8"Parse[0x0003]ÅÅÐòÒì³££º\n" + error_cycle);
|
||||
}
|
||||
|
||||
auto nlist = tracks;
|
||||
nlist.append(peaks_appoint_element(target));
|
||||
|
||||
if (current->nodeType() == example_novel::FragmentSortHelper::Type::REFER) {
|
||||
decltype (current->siblings()) fork_list;
|
||||
for (auto& vit : current->siblings()) {
|
||||
if (target->nodeType() == example_novel::FragmentSortHelper::Type::REFER) {
|
||||
decltype (target->siblings()) sibling_forks;
|
||||
|
||||
auto siblings = target->siblings();
|
||||
for (auto& vit : siblings) {
|
||||
if (vit->storySort() <= story_sort_source)
|
||||
fork_list << vit;
|
||||
sibling_forks << vit;
|
||||
}
|
||||
|
||||
for (auto& fork : fork_list) {
|
||||
for (auto& fork : sibling_forks) {
|
||||
sort_cycle_check(nlist, fork, story_sort_source);
|
||||
}
|
||||
}
|
||||
|
||||
nlist.append(peaks_appoint_element(current));
|
||||
sort_cycle_check(nlist, current->next(), story_sort_source);
|
||||
sort_cycle_check(nlist, target, story_sort_source);
|
||||
}
|
||||
|
||||
std::shared_ptr<FragmentSortHelper> example_novel::FragmentOrdersCheck::peaks_appoint_element(std::shared_ptr<FragmentSortHelper> refer_n)
|
||||
std::shared_ptr<FragmentSortHelper> example_novel::FragmentOrdersCheck::peaks_appoint_element(std::shared_ptr<FragmentSortHelper> refer_n) const
|
||||
{
|
||||
if (refer_n->nodeType() == example_novel::FragmentSortHelper::Type::ELEMENT)
|
||||
return refer_n;
|
||||
|
@ -230,8 +242,14 @@ void FragmentOrdersCheck::validCheck(std::shared_ptr<const ast_gen::ElementAcces
|
|||
|
||||
const_cast<FragmentOrdersCheck*>(this)->elements_link_build(this->stories_list);
|
||||
|
||||
for (auto& s : this->stories_list)
|
||||
const_cast<FragmentOrdersCheck*>(this)->sort_cycle_check(QList<std::shared_ptr<FragmentSortHelper>>(), s->fragmentSort(), s->sortValue());
|
||||
for (auto& s : this->stories_list) {
|
||||
if(!s->fragmentSort())
|
||||
continue;
|
||||
|
||||
QList<std::shared_ptr<FragmentSortHelper>> tracks;
|
||||
tracks << peaks_appoint_element(s->fragmentSort());
|
||||
const_cast<FragmentOrdersCheck*>(this)->sort_cycle_check(tracks, s->fragmentSort(), s->sortValue());
|
||||
}
|
||||
}
|
||||
|
||||
StorySortHelper::StorySortHelper(std::shared_ptr<const ast_gen::ElementAccess> story_bind) {
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace example_novel {
|
|||
void sort_cycle_check(const QList<std::shared_ptr<FragmentSortHelper>>& tracks, std::shared_ptr<FragmentSortHelper> current,
|
||||
int story_sort_source);
|
||||
|
||||
std::shared_ptr<FragmentSortHelper> peaks_appoint_element(std::shared_ptr<FragmentSortHelper> refer_n);
|
||||
std::shared_ptr<FragmentSortHelper> peaks_appoint_element(std::shared_ptr<FragmentSortHelper> refer_n) const;
|
||||
|
||||
// CheckProvider interface
|
||||
public:
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<QtLastBackgroundBuild>2024-05-04T09:33:59.5719569Z</QtLastBackgroundBuild>
|
||||
<QtLastBackgroundBuild>2024-05-04T13:29:47.3997896Z</QtLastBackgroundBuild>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<QtLastBackgroundBuild>2024-05-04T09:33:59.7159031Z</QtLastBackgroundBuild>
|
||||
<QtLastBackgroundBuild>2024-05-04T13:29:47.5416879Z</QtLastBackgroundBuild>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -2,9 +2,9 @@
|
|||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<QtLastBackgroundBuild>2024-05-04T09:33:59.0218626Z</QtLastBackgroundBuild>
|
||||
<QtLastBackgroundBuild>2024-05-04T13:29:46.3016809Z</QtLastBackgroundBuild>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<QtLastBackgroundBuild>2024-05-04T09:33:59.1804633Z</QtLastBackgroundBuild>
|
||||
<QtLastBackgroundBuild>2024-05-04T13:29:46.7433247Z</QtLastBackgroundBuild>
|
||||
</PropertyGroup>
|
||||
</Project>
|
Loading…
Reference in New Issue