{"id":20279555,"url":"https://github.com/xukeawsl/threewaysmergesort","last_synced_at":"2025-08-03T06:38:01.436Z","repository":{"id":213897643,"uuid":"735208459","full_name":"xukeawsl/threeWaysMergeSort","owner":"xukeawsl","description":"三路归并排序 qt 可视化","archived":false,"fork":false,"pushed_at":"2023-12-29T10:27:07.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-14T07:11:57.426Z","etag":null,"topics":["cpp","qt","sorting-visualization"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xukeawsl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-24T04:00:25.000Z","updated_at":"2024-03-16T17:10:57.000Z","dependencies_parsed_at":"2024-11-14T13:45:20.430Z","dependency_job_id":null,"html_url":"https://github.com/xukeawsl/threeWaysMergeSort","commit_stats":null,"previous_names":["xukeawsl/threewaysmergesort"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xukeawsl%2FthreeWaysMergeSort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xukeawsl%2FthreeWaysMergeSort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xukeawsl%2FthreeWaysMergeSort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xukeawsl%2FthreeWaysMergeSort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xukeawsl","download_url":"https://codeload.github.com/xukeawsl/threeWaysMergeSort/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241773256,"owners_count":20018064,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","qt","sorting-visualization"],"created_at":"2024-11-14T13:31:24.551Z","updated_at":"2025-03-04T02:40:29.711Z","avatar_url":"https://github.com/xukeawsl.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 三路归并排序可视化\n\n[![License](https://img.shields.io/npm/l/mithril.svg)](https://github.com/xukeawsl/threeWaysMergeSort/blob/main/LICENSE)\n\n## 实现思路\n\n1. 窗体大小固定, 便于编写代码。\n2. 排序元素随机生成，但是排序后的序列是指定的，即排序后元素\n的间隔是相同的，随机只是打乱顺序，这样绘制出来比较好看。\n3. 绘制操作必须在主线程进行，子线程负责执行排序流程，每一步操作执行后\n如果需要移动或者绘制图形颜色则通过信号的方式发送给主线程绘制。\n4. 图像分为两层，上层展示原数组，下层展示临时数组，当原数组中的元素\n放入临时数组时，则将上层对应元素的矩形先更换颜色，然后先向下移动，再水平移动到临时数组对应位置，\n当这一层三路的元素都放置到临时数组后，从首个元素开始向上移动，每移动完成一个\n元素，颜色就重新恢复。\n5. 最后当所有元素都排序完成后，从第一个元素开始依次更新元素的颜色。\n6. 关于矩形元素的宽度，设置为 [scene 宽度 / 元素数量]，类型为 qreal，矩形的高度\n即是元素的大小，排序则就是按矩形的高度进行从小到大排列。\n7. 排序线程构造时传入 items 的不可变引用 `const vector\u003cQGraphicsItem *\u003e\u0026` ，子线程根据它维护一个索引\n数组，排序实际上是对索引数组的排序, 比较的时候通过索引访问对应的 item 高度。\n8. 当需要对元素进行操作时，通过发送信号操作指定索引对应的 item。\n\n## 效果图\n\n![demo.png](https://s2.loli.net/2023/12/24/eu9cEhDtOBPGxXa.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxukeawsl%2Fthreewaysmergesort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxukeawsl%2Fthreewaysmergesort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxukeawsl%2Fthreewaysmergesort/lists"}