docs: Chinese version README.md

This commit is contained in:
Revone 2023-12-07 14:03:58 +08:00
parent 3cd5316f2a
commit d038e03ef2
4 changed files with 125 additions and 16 deletions

View file

@ -9,15 +9,62 @@
[//]: # (![npm bundle size](https://img.shields.io/bundlephobia/min/data-structure-typed))
## Why
<p><a href="https://github.com/zrwusa/data-structure-typed/blob/main/README.md">English</a> | <a href="https://github.com/zrwusa/data-structure-typed/blob/main/README_zh-CN.md">简体中文</a></p>
Data Structures of Javascript & TypeScript.
Do you envy C++ with [STL]() (std::), Python with [collections](), and Java with [java.util]() ? Well, no need to envy
anymore! JavaScript and TypeScript now have [data-structure-typed]().**`Benchmark`** compared with C++ STL. **`API standards`** aligned with ES6 and Java. **`Usability`** is comparable to Python
### We provide data structures that are not available in JavaScript/TypeScript
Heap, Binary Tree, RedBlack Tree, Linked List, Deque, Trie, Directed Graph, Undirected Graph, BST, AVL Tree, Priority Queue, Queue, Tree Multiset, Linked List.
### Performance superior to native JavaScript/TypeScript
**`Queue vs. native Array, 100,000 scale`**
<table style="display: table; width:100%; table-layout: fixed;">
<thead>
<tr>
<th>Test Methods</th>
<th>Time Taken (ms)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Queue push &amp; shift</td>
<td>5.83</td>
</tr>
<tr>
<td>Array push &amp; shift</td>
<td>2829.59</td>
</tr>
</tbody>
</table>
**`Deque vs. native Array, 100,000 scale`**
<table style="display: table; width:100%; table-layout: fixed;">
<thead>
<tr>
<th>Test Methods</th>
<th>Time Taken (ms)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Deque unshift &amp; shift</td>
<td>2.44</td>
</tr>
<tr>
<td>Array unshift &amp; shift</td>
<td>4750.37</td>
</tr>
</tbody>
</table>
[//]: # (![Branches]&#40;https://img.shields.io/badge/branches-55.47%25-red.svg?style=flat&#41;)
[//]: # (![Statements]&#40;https://img.shields.io/badge/statements-67%25-red.svg?style=flat&#41;)

View file

@ -9,6 +9,8 @@
[//]: # (![npm bundle size]&#40;https://img.shields.io/bundlephobia/min/data-structure-typed&#41;)
## 为什么
<p><a href="https://github.com/zrwusa/data-structure-typed/blob/main/README.md">English</a> | <a href="https://github.com/zrwusa/data-structure-typed/blob/main/README_zh-CN.md">简体中文</a></p>
JavaScript和TypeScript的数据结构。
@ -19,6 +21,54 @@ JavaScript和TypeScript的数据结构。
**`基准测试`** 与C++ STL相比。**`API 标准`** 与ES6和Java对齐。**`易用性`** 可与Python媲美。
### 提供了JavaScript/TypeScript中没有的数据结构
Heap, Binary Tree, RedBlack Tree, Linked List, Deque, Trie, Directed Graph, Undirected Graph, BST, AVL Tree, Priority Queue, Queue, Tree Multiset, Linked List.
### 性能超越原生JavaScript/TypeScript
**`Queue和原生Array, 在100,000数据规模下性能对比`**
<table style="display: table; width:100%; table-layout: fixed;">
<thead>
<tr>
<th>Test Methods</th>
<th>Time Taken (ms)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Queue push &amp; shift</td>
<td>5.83</td>
</tr>
<tr>
<td>Array push &amp; shift</td>
<td>2829.59</td>
</tr>
</tbody>
</table>
**`Deque和原生Array在100,000数据规模下的性能对比`**
<table style="display: table; width:100%; table-layout: fixed;">
<thead>
<tr>
<th>Test Methods</th>
<th>Time Taken (ms)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Deque unshift &amp; shift</td>
<td>2.44</td>
</tr>
<tr>
<td>Array unshift &amp; shift</td>
<td>4750.37</td>
</tr>
</tbody>
</table>
[//]: # (![Branches]&#40;https://img.shields.io/badge/branches-55.47%25-red.svg?style=flat&#41;)
[//]: # (![Statements]&#40;https://img.shields.io/badge/statements-67%25-red.svg?style=flat&#41;)

View file

@ -5,7 +5,7 @@ import { magnitude } from '../../../utils';
import { isCompetitor } from '../../../config';
export const suite = new Benchmark.Suite();
const { LINEAR } = magnitude;
const { LINEAR, HUNDRED_THOUSAND } = magnitude;
suite.add(`${LINEAR.toLocaleString()} push`, () => {
const deque = new Deque<number>();
@ -26,16 +26,28 @@ suite.add(`${LINEAR.toLocaleString()} push & pop`, () => {
for (let i = 0; i < LINEAR; i++) _deque.push(i);
for (let i = 0; i < LINEAR; i++) _deque.pop();
});
suite.add(`${LINEAR.toLocaleString()} push & shift`, () => {
const _deque = new Deque<number>();
})
.add(`${HUNDRED_THOUSAND.toLocaleString()} push & shift`, () => {
const _deque = new Deque<number>();
for (let i = 0; i < LINEAR; i++) _deque.push(i);
for (let i = 0; i < LINEAR; i++) _deque.shift();
});
suite.add(`${LINEAR.toLocaleString()} unshift & shift`, () => {
const _deque = new Deque<number>();
for (let i = 0; i < HUNDRED_THOUSAND; i++) _deque.push(i);
for (let i = 0; i < HUNDRED_THOUSAND; i++) _deque.shift();
})
.add(`${HUNDRED_THOUSAND.toLocaleString()} Array push & shift`, () => {
const _deque = new Array<number>();
for (let i = 0; i < LINEAR; i++) _deque.unshift(i);
for (let i = 0; i < LINEAR; i++) _deque.shift();
});
for (let i = 0; i < HUNDRED_THOUSAND; i++) _deque.push(i);
for (let i = 0; i < HUNDRED_THOUSAND; i++) _deque.shift();
})
.add(`${HUNDRED_THOUSAND.toLocaleString()} unshift & shift`, () => {
const _deque = new Deque<number>();
for (let i = 0; i < HUNDRED_THOUSAND; i++) _deque.unshift(i);
for (let i = 0; i < HUNDRED_THOUSAND; i++) _deque.shift();
})
.add(`${HUNDRED_THOUSAND.toLocaleString()} Array unshift & shift`, () => {
const _deque = new Array<number>();
for (let i = 0; i < HUNDRED_THOUSAND; i++) _deque.unshift(i);
for (let i = 0; i < HUNDRED_THOUSAND; i++) _deque.shift();
});

View file

@ -51,7 +51,7 @@ suite.add(`${HUNDRED_THOUSAND.toLocaleString()} Array push & shift`, () => {
}
for (let i = 0; i < HUNDRED_THOUSAND; i++) {
arr.shift();
arr.pop();
}
});