mirror of
https://github.com/zrwusa/data-structure-typed.git
synced 2024-11-23 12:54:04 +00:00
[README] data structures comparation
This commit is contained in:
parent
80675e2bbb
commit
89451d2c03
135
README.md
135
README.md
|
@ -35,7 +35,7 @@ yarn add data-structure-typed
|
|||
|
||||
```html
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/data-structure-typed/umd/bundle.min.js"></script>
|
||||
<script src='https://cdn.jsdelivr.net/npm/data-structure-typed/umd/bundle.min.js'></script>
|
||||
```
|
||||
|
||||
```js
|
||||
|
@ -97,7 +97,7 @@ bst.get(6); // null
|
|||
bst.isAVLBalanced(); // true
|
||||
bst.BFS()[0] === 11; // true
|
||||
|
||||
const objBST = new BST<BSTNode<{ id: number, keyA: number }>>();
|
||||
const objBST = new BST<BSTNode<{id: number, keyA: number}>>();
|
||||
objBST.add(11, {id: 11, keyA: 11});
|
||||
objBST.add(3, {id: 3, keyA: 3});
|
||||
|
||||
|
@ -678,89 +678,122 @@ optimal approach to data structure design.
|
|||
</table>
|
||||
|
||||
|
||||
### Standard library data structure comparison
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Data Structure</th>
|
||||
<th>C++ STL</th>
|
||||
<th>java.util</th>
|
||||
<th>Python collections</th>
|
||||
<th>Data Structure Typed</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Dynamic Array (ArrayList)</td>
|
||||
<td>std::vector<T></td>
|
||||
<td>ArrayList<E></td>
|
||||
<td>list</td>
|
||||
<td>Array</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Linked List</td>
|
||||
<td>std::list<T></td>
|
||||
<td>LinkedList<E></td>
|
||||
<td>deque</td>
|
||||
<td>DoublyLinkedList</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Set</td>
|
||||
<td>std::set<T></td>
|
||||
<td>HashSet<E></td>
|
||||
<td>set</td>
|
||||
<td>Set</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Map</td>
|
||||
<td>std::map<K, V></td>
|
||||
<td>HashMap<K, V></td>
|
||||
<td>dict</td>
|
||||
<td>Map</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Stack</td>
|
||||
<td>std::stack<T></td>
|
||||
<td>Stack<E></td>
|
||||
<td>N/A</td>
|
||||
<td>Stack</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Queue</td>
|
||||
<td>std::queue<T></td>
|
||||
<td>LinkedList<E></td>
|
||||
<td>Queue<E></td>
|
||||
<td>N/A</td>
|
||||
<td>Queue</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Priority Queue</td>
|
||||
<td>std::priority_queue<T></td>
|
||||
<td>PriorityQueue<E></td>
|
||||
<td>N/A</td>
|
||||
<td>PriorityQueue</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Hash Table</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>defaultdict, Counter, etc.</td>
|
||||
<td>Hashtable</td>
|
||||
<td>defaultdict</td>
|
||||
<td>HashTable</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Deque</td>
|
||||
<td>std::deque<T></td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>Deque</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Multiset</td>
|
||||
<td>std::multiset<T></td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Multimap</td>
|
||||
<td>std::multimap<K, V></td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Unordered Set</td>
|
||||
<td>std::unordered_set<T></td>
|
||||
<td>HashSet<E></td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Unordered Multiset</td>
|
||||
<td>std::unordered_multiset</td>
|
||||
<td>N/A</td>
|
||||
<td>Counter</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Unordered Map</td>
|
||||
<td>std::unordered_map<K, V></td>
|
||||
<td>HashMap<K, V></td>
|
||||
<td>defaultdict</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Unordered Multimap</td>
|
||||
<td>std::unordered_multimap<K, V></td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -768,125 +801,83 @@ optimal approach to data structure design.
|
|||
<td>std::bitset<N></td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Ordered Dictionary (OrderedDict)</td>
|
||||
<td>Ordered Dictionary</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>OrderedDict</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>User-Defined Dictionary</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>UserDict</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>User-Defined List</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>UserList</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>User-Defined Set</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>UserSet</td>
|
||||
<td>Map</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Double-Ended Queue (Deque)</td>
|
||||
<td>std::deque<T></td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Skip List</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Circular Queue</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Bit Array</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Bloom Filter</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>Deque</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Linked Hash Set</td>
|
||||
<td>N/A</td>
|
||||
<td>LinkedHashSet<E></td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Linked Hash Map</td>
|
||||
<td>N/A</td>
|
||||
<td>LinkedHashMap<K, V></td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Sorted Set</td>
|
||||
<td>N/A</td>
|
||||
<td>TreeSet<E></td>
|
||||
<td>N/A</td>
|
||||
<td>AVLTree, RBTree</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Sorted Map</td>
|
||||
<td>N/A</td>
|
||||
<td>TreeMap<K, V></td>
|
||||
<td>N/A</td>
|
||||
<td>AVLTree, RBTree</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Tree Set</td>
|
||||
<td>std::set</td>
|
||||
<td>TreeSet<E></td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>AVLTree, RBTree</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Tree Map</td>
|
||||
<td>std::map<K, V></td>
|
||||
<td>TreeMap<K, V></td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>AVLTree, RBTree</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Persistent Collections</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>std::unordered_multiset</td>
|
||||
<td>std::unordered_multiset<T></td>
|
||||
<tr>
|
||||
<td>unordered multiset</td>
|
||||
<td>unordered multiset<T></td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>std::unordered_multimap</td>
|
||||
<td>Unordered Multimap</td>
|
||||
<td>std::unordered_multimap<K, V></td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>N/A</td>
|
||||
<td>TreeSet<E></td>
|
||||
<td>TreeSet<E></td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>N/A</td>
|
||||
<td>TreeMap<K, V></td>
|
||||
<td>TreeMap<K, V></td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -894,38 +885,42 @@ optimal approach to data structure design.
|
|||
<td>LinkedBlockingQueue<E></td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>N/A</td>
|
||||
<td>ConcurrentHashMap<K, V></td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>namedtuple</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>ChainMap</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>defaultdict</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
<td>Counter</td>
|
||||
<td>N/A</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<table><thead><tr><th>Data Structure</th><th>C++ STL</th><th>java.util</th><th>Python collections</th><th>Custom Data Structure (Typescript)</th></tr></thead><tbody><tr><td>Dynamic Array (ArrayList)</td><td>std::vector<T></td><td>ArrayList<E></td><td>list</td><td>N/A</td></tr><tr><td>Linked List</td><td>std::list<T></td><td>LinkedList<E></td><td>deque</td><td>SinglyLinkedList, DoublyLinkedList, etc.</td></tr><tr><td>Set</td><td>std::set<T></td><td>HashSet<E></td><td>set</td><td>TreeMultiset, etc.</td></tr><tr><td>Map</td><td>std::map<K, V></td><td>HashMap<K, V></td><td>dict</td><td>N/A</td></tr><tr><td>Stack</td><td>std::stack<T></td><td>Stack<E></td><td>N/A</td><td>N/A</td></tr><tr><td>Queue</td><td>std::queue<T></td><td>LinkedList<E></td><td>N/A</td><td>N/A</td></tr><tr><td>Priority Queue</td><td>std::priority_queue<T></td><td>PriorityQueue<E></td><td>N/A</td><td>N/A</td></tr><tr><td>Hash Table</td><td>N/A</td><td>N/A</td><td>defaultdict, Counter, etc.</td><td>N/A</td></tr><tr><td>Deque</td><td>std::deque<T></td><td>N/A</td><td>N/A</td><td>N/A</td></tr><tr><td>Multiset</td><td>std::multiset<T></td><td>N/A</td><td>N/A</td><td>N/A</td></tr><tr><td>Multimap</td><td>std::multimap<K, V></td><td>N/A</td><td>N/A</td><td>N/A</td></tr><tr><td>Unordered Set</td><td>std::unordered_set<T></td><td>HashSet<E></td><td>N/A</td><td>N/A</td></tr><tr><td>Unordered Map</td><td>std::unordered_map<K, V></td><td>HashMap<K, V></td><td>N/A</td><td>N/A</td></tr><tr><td>Bitset</td><td>std::bitset<N></td><td>N/A</td><td>N/A</td><td>N/A</td></tr><tr><td>Ordered Dictionary (OrderedDict)</td><td>N/A</td><td>N/A</td><td>OrderedDict</td><td>N/A</td></tr><tr><td>User-Defined Dictionary</td><td>N/A</td><td>N/A</td><td>UserDict</td><td>N/A</td></tr><tr><td>User-Defined List</td><td>N/A</td><td>N/A</td><td>UserList</td><td>N/A</td></tr><tr><td>User-Defined Set</td><td>N/A</td><td>N/A</td><td>UserSet</td><td>N/A</td></tr><tr><td>Double-Ended Queue (Deque)</td><td>std::deque<T></td><td>N/A</td><td>N/A</td><td>N/A</td></tr><tr><td>Skip List</td><td>N/A</td><td>N/A</td><td>N/A</td><td>N/A</td></tr><tr><td>Circular Queue</td><td>N/A</td><td>N/A</td><td>N/A</td><td>N/A</td></tr><tr><td>Bit Array</td><td>N/A</td><td>N/A</td><td>N/A</td><td>N/A</td></tr><tr><td>Bloom Filter</td><td>N/A</td><td>N/A</td><td>N/A</td><td>N/A</td></tr><tr><td>Linked Hash Set</td><td>N/A</td><td>LinkedHashSet<E></td><td>N/A</td><td>N/A</td></tr><tr><td>Linked Hash Map</td><td>N/A</td><td>LinkedHashMap<K, V></td><td>N/A</td><td>N/A</td></tr><tr><td>Sorted Set</td><td>N/A</td><td>TreeSet<E></td><td>N/A</td><td>N/A</td></tr><tr><td>Sorted Map</td><td>N/A</td><td>TreeMap<K, V></td><td>N/A</td><td>N/A</td></tr><tr><td>Tree Set</td><td>N/A</td><td>N/A</td><td>N/A</td><td>N/A</td></tr><tr><td>Tree Map</td><td>N/A</td><td>N/A</td><td>N/A</td><td>N/A</td></tr><tr><td>Persistent Collections</td><td>N/A</td><td>N/A</td><td>N/A</td><td>N/A</td></tr><tr><td>std::unordered_multiset</td><td>std::unordered_multiset<T></td><td>N/A</td><td>N/A</td><td>N/A</td></tr><tr><td>std::unordered_multimap</td><td>std::unordered_multimap<K, V></td><td>N/A</td><td>N/A</td><td>N/A</td></tr><tr><td>N/A</td><td>TreeSet<E></td><td>TreeSet<E></td><td>N/A</td><td>N/A</td></tr><tr><td>N/A</td><td>TreeMap<K, V></td><td>TreeMap<K, V></td><td>N/A</td><td>N/A</td></tr><tr><td>N/A</td><td>LinkedBlockingQueue<E></td><td>N/A</td><td>N/A</td><td>N/A</td></tr><tr><td>N/A</td><td>ConcurrentHashMap<K, V></td><td>N/A</td><td>N/A</td><td>N/A</td></tr><tr><td>N/A</td><td>N/A</td><td>namedtuple</td><td>N/A</td><td>N/A</td></tr><tr><td>N/A</td><td>N/A</td><td>ChainMap</td><td>N/A</td><td>N/A</td></tr><tr><td>N/A</td><td>N/A</td><td>defaultdict</td><td>N/A</td><td>N/A</td></tr><tr><td>N/A</td><td>N/A</td><td>Counter</td><td>N/A</td><td>N/A</td></tr></tbody></table>
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang='en'>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta charset='UTF-8'>
|
||||
<title>CDN Test</title>
|
||||
<script src="https://cdn.jsdelivr.net/npm/data-structure-typed/umd/bundle.min.js"></script>
|
||||
<script src='https://cdn.jsdelivr.net/npm/data-structure-typed/umd/bundle.min.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<ul class="modules">
|
||||
<div id='app'>
|
||||
<ul class='modules'>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -36,7 +36,7 @@
|
|||
last = queue.dequeue();
|
||||
}
|
||||
|
||||
console.log(performance.now() - startTime)
|
||||
console.log(performance.now() - startTime);
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
|
Loading…
Reference in a new issue