Full Code of wangzheng0822/algo for AI

master b2c1228ff915 cached
622 files
1.0 MB
341.3k tokens
2401 symbols
1 requests
Download .txt
Showing preview only (1,169K chars total). Download the full file or copy to clipboard to get everything.
Repository: wangzheng0822/algo
Branch: master
Commit: b2c1228ff915
Files: 622
Total size: 1.0 MB

Directory structure:
gitextract_2921o4fk/

├── .gitignore
├── DynamicStackBaseArray.java
├── LICENSE
├── README.md
├── StackBaseArray.java
├── c-cpp/
│   ├── .gitignore
│   ├── .gitkeep
│   ├── 05_array/
│   │   ├── .gitkeep
│   │   ├── Array_gp.c
│   │   ├── Array_gp.h
│   │   └── array.c
│   ├── 06_linkedlist/
│   │   ├── .gitkeep
│   │   ├── Dlist/
│   │   │   ├── Dlist.c
│   │   │   └── Dlist.h
│   │   ├── LRUBasedLinkedList.cpp
│   │   ├── list_isPalindrome/
│   │   │   ├── LinkList.cpp
│   │   │   └── LinkList.h
│   │   ├── palindromeList/
│   │   │   ├── LinkedList.hpp
│   │   │   ├── ListNode.hpp
│   │   │   └── palindromeList.cpp
│   │   ├── single_list.c
│   │   └── singlelist_gc/
│   │       ├── singleList.c
│   │       └── singleList.h
│   ├── 07_linkedlist/
│   │   ├── .gitkeep
│   │   ├── LinkedListAlgo.c
│   │   ├── SingleList.cpp
│   │   ├── linked_list.h
│   │   ├── linked_list_algo.hpp
│   │   └── linklist_jinshaohui.c
│   ├── 08_stack/
│   │   ├── StackBasedOnArray/
│   │   │   ├── StackBasedOnArray.cpp
│   │   │   └── StackBasedOnArray.h
│   │   ├── StackBasedOnLinkedList/
│   │   │   ├── StackBasedOnLinkedList.cpp
│   │   │   └── StackBasedOnLinkedList.h
│   │   ├── arrayStack/
│   │   │   ├── arrayStack.c
│   │   │   └── arrayStack.h
│   │   ├── linkList/
│   │   │   ├── linklist_stack.c
│   │   │   └── linklist_stack.h
│   │   ├── linked_list.h
│   │   └── stack_based_on_linked_list.hpp
│   ├── 09_queue/
│   │   ├── .gitkeep
│   │   ├── array_queue/
│   │   │   ├── array_queue.c
│   │   │   └── array_queue.h
│   │   ├── array_queue.hpp
│   │   ├── array_queue_test.cc
│   │   ├── block_queue.hpp
│   │   ├── circular_queue.hpp
│   │   ├── circular_queue_test.cc
│   │   ├── concurrency_queue.hpp
│   │   ├── dynamic_array_queue.hpp
│   │   ├── dynamic_array_queue_test.cc
│   │   ├── linked_queue.hpp
│   │   ├── linked_queue_test.cc
│   │   ├── list_queue/
│   │   │   ├── list_queue.c
│   │   │   └── list_queue.h
│   │   ├── lock_free_queue.hpp
│   │   └── ring_queue.c
│   ├── 10_recursive/
│   │   ├── .gitkeep
│   │   ├── one_two_step.c
│   │   └── one_two_step.cc
│   ├── 11_sorts/
│   │   ├── .gitkeep
│   │   ├── sorts.c
│   │   ├── sorts.cpp
│   │   ├── sorts.hpp
│   │   ├── sorts_jinshaohui.c
│   │   └── sorts_test.cc
│   ├── 12_sorts/
│   │   ├── .gitkeep
│   │   ├── merge_sort.c
│   │   ├── merge_sort.hpp
│   │   ├── merge_sort_test.cc
│   │   ├── my12_sorts/
│   │   │   ├── merge_sort.c
│   │   │   └── quick_sort.c
│   │   ├── quick_sort.c
│   │   ├── quick_sort.hpp
│   │   └── quick_sort_test.cc
│   ├── 13_sorts/
│   │   ├── .gitkeep
│   │   ├── bucket_sort.hpp
│   │   ├── bucket_sort_test.cc
│   │   ├── counting_sort.hpp
│   │   ├── counting_sort_test.cc
│   │   └── sort.c
│   ├── 14_sorts/
│   │   ├── .gitkeep
│   │   ├── analytics_of_std_sort.md
│   │   └── counting_sort.c
│   ├── 15_bsearch/
│   │   ├── .gitkeep
│   │   ├── binary_search.c
│   │   ├── bsearch.hpp
│   │   ├── bsearch_c/
│   │   │   ├── bsearch.c
│   │   │   └── sqrt.c
│   │   └── bsearch_test.cc
│   ├── 16_bsearch/
│   │   ├── .gitkeep
│   │   ├── bsearch.c
│   │   ├── bsearch_variant.c
│   │   ├── bsearch_varients.hpp
│   │   └── bsearch_varients_test.cc
│   ├── 17_skiplist/
│   │   ├── .gitkeep
│   │   ├── SkipList.cpp
│   │   ├── skiplist.c
│   │   ├── skiplist.hpp
│   │   ├── skiplist_c/
│   │   │   ├── skiplist.c
│   │   │   └── skiplist.h
│   │   ├── skiplist_test.cc
│   │   ├── skiplist_tr.hpp
│   │   └── skiplist_tr_test.cc
│   ├── 18_hashtable/
│   │   ├── .gitkeep
│   │   ├── hash_map.cc
│   │   ├── hashtable.c
│   │   └── listhash/
│   │       ├── listhash.c
│   │       └── listhash.h
│   ├── 19_Dlisthash/
│   │   ├── Dlist.h
│   │   ├── LinkedHashMap.c
│   │   └── LinkedHashMap.h
│   ├── 23_binarytree/
│   │   ├── binarytree.c
│   │   └── tree/
│   │       ├── binarytree.c
│   │       ├── list_queue.c
│   │       └── list_queue.h
│   ├── 24_binarysearchtree/
│   │   ├── binary_search_tree.cpp
│   │   ├── binarysearchtree.c
│   │   ├── binarysearchtree.h
│   │   └── bst.c
│   ├── 24_tree/
│   │   ├── Trie.c
│   │   └── binarysearchtree.c
│   ├── 28_heap/
│   │   └── heap.c
│   ├── 30_Graph/
│   │   └── graph.c
│   └── bst.c
├── csharp/
│   ├── 05-array/
│   │   ├── Array.cs
│   │   └── algo05_array.csproj
│   ├── 06-linkedlist/
│   │   ├── LRUWithArray.cs
│   │   ├── LRUWithLinkedList.cs
│   │   ├── LRU缓存实现思路.txt
│   │   ├── SingleLinkedList.cs
│   │   └── algo06_linked_list.csproj
│   ├── 07-linkedlist/
│   │   └── _07_linkedlist/
│   │       ├── SingleLinkedListAlgo.cs
│   │       └── algo07_linkedlist.csproj
│   ├── 08-stack/
│   │   └── algo08_stack/
│   │       ├── ArrayStack.cs
│   │       ├── LinkedStack.cs
│   │       ├── LinkedStackBrowser.cs
│   │       └── algo08_stack.csproj
│   ├── Tests/
│   │   ├── _05_array_tests/
│   │   │   ├── Array.Tests.cs
│   │   │   └── algo05_array_tests.csproj
│   │   ├── _06_linkedlist_tests/
│   │   │   ├── BaseLinkedListTests.cs
│   │   │   ├── LRUWithArray.Tests.cs
│   │   │   ├── LRUWithLinkedList.Tests.cs
│   │   │   ├── SingleLinkedList.Tests.cs
│   │   │   └── algo06_linkedlist_tests.csproj
│   │   ├── _07_linkedlist_tests/
│   │   │   ├── SingleLinkedListAlgo.Tests.cs
│   │   │   └── algo07_linkedlist_tests.csproj
│   │   └── algo08_stack_tests/
│   │       ├── ArrayStack.Tests.cs
│   │       ├── LinkedStack.Tests.cs
│   │       ├── LinkedStackBrowser.Tests.cs
│   │       └── algo08_stack_tests.csproj
│   ├── csharp.sln
│   └── csharp.sln.DotSettings.user
├── f21
├── go/
│   ├── .gitkeep
│   ├── 05_array/
│   │   ├── .gitkeep
│   │   ├── array.go
│   │   └── array_test.go
│   ├── 06_linkedlist/
│   │   ├── .gitkeep
│   │   ├── palindrome-linked-list.go
│   │   ├── palindrome.go
│   │   ├── palindrome_test.go
│   │   ├── singlelinkedlist.go
│   │   └── singlelinkedlist_test.go
│   ├── 07_linkedlist/
│   │   ├── .gitkeep
│   │   ├── main.go
│   │   └── main_test.go
│   ├── 08_stack/
│   │   ├── SimpleBrowser.go
│   │   ├── SimpleBrowser_test.go
│   │   ├── StackBasedOnArray.go
│   │   ├── StackBasedOnArray_test.go
│   │   ├── StackBasedOnLinkedList.go
│   │   ├── StackBasedOnLinkedList_test.go
│   │   └── StatckInterface.go
│   ├── 09_queue/
│   │   ├── CircularQueue.go
│   │   ├── CircularQueue_test.go
│   │   ├── QueueBasedOnArray.go
│   │   ├── QueueBasedOnArray_test.go
│   │   ├── QueueBasedOnLinkedList.go
│   │   └── QueueBasedOnLinkedList_test.go
│   ├── 10_recursion/
│   │   ├── Factorial.go
│   │   ├── Factorial_test.go
│   │   ├── Fibonacci.go
│   │   ├── Fibonacci_test.go
│   │   ├── RangAll.go
│   │   └── RangAll_test.go
│   ├── 11_sorts/
│   │   ├── Sort.go
│   │   └── Sort_test.go
│   ├── 12_sorts/
│   │   ├── MergeSort.go
│   │   ├── MergeSort_test.go
│   │   ├── QuickSort.go
│   │   └── QuickSort_test.go
│   ├── 13_sorts/
│   │   ├── BucketSort.go
│   │   └── BucketSort_test.go
│   ├── 14_sorts/
│   │   ├── CountingSort.go
│   │   └── CountingSort_test.go
│   ├── 15_binarysearch/
│   │   ├── binarysearch.go
│   │   └── binarysearch_test.go
│   ├── 17_skiplist/
│   │   ├── skiplist.go
│   │   └── skiplist_test.go
│   ├── 20_lru/
│   │   ├── lru_cache.go
│   │   └── lru_cache_test.go
│   ├── 23_binarytree/
│   │   ├── binarytree.go
│   │   └── binarytree_test.go
│   ├── 24_tree/
│   │   ├── BinarySearchTree.go
│   │   ├── BinarySearchTree_test.go
│   │   ├── BinaryTree.go
│   │   ├── BinaryTree_test.go
│   │   ├── StackBasedOnArray.go
│   │   └── TreeNode.go
│   ├── 28_heap/
│   │   ├── heap.go
│   │   └── heap_sort.go
│   ├── 29_priority_queue/
│   │   ├── heap.go
│   │   ├── heap_test.go
│   │   ├── priority_queue.go
│   │   ├── priority_queue_test.go
│   │   └── readme.md
│   ├── 31_graph/
│   │   └── graph_search.go
│   ├── 32_string/
│   │   ├── string_bf.go
│   │   └── string_bm.go
│   ├── 34_kmp/
│   │   └── kmp.go
│   ├── 41_dynamic_programming/
│   │   ├── backtracking/
│   │   │   ├── leastcoins.go
│   │   │   └── leastcoins_test.go
│   │   └── dp/
│   │       ├── leastcoins.go
│   │       └── leastcoins_test.go
│   ├── 42_dynamic_programming/
│   │   └── longest_common_substring.go
│   ├── 45_bitmap/
│   │   ├── bitmap.go
│   │   └── bitmap_test.go
│   └── binarysearch2.go
├── java/
│   ├── 05_array/
│   │   ├── .gitkeep
│   │   ├── Array.java
│   │   └── GenericArray.java
│   ├── 06_linkedlist/
│   │   ├── .gitkeep
│   │   ├── LRUBaseLinkedList.java
│   │   ├── LRUBasedArray.java
│   │   └── SinglyLinkedList.java
│   ├── 07_linkedlist/
│   │   ├── .gitkeep
│   │   └── LinkedListAlgo.java
│   ├── 08_stack/
│   │   ├── SampleBrowser.java
│   │   └── StackBasedOnLinkedList.java
│   ├── 09_queue/
│   │   ├── ArrayQueue.java
│   │   ├── CircularQueue.java
│   │   ├── DynamicArrayQueue.java
│   │   └── QueueBasedOnLinkedList.java
│   ├── 11_sorts/
│   │   ├── InsertionSortAdd.java
│   │   ├── Sorts.java
│   │   └── SortsAddOn.java
│   ├── 12_sorts/
│   │   ├── KthSmallest.java
│   │   ├── MergeSort.java
│   │   ├── QuickSort.java
│   │   └── Sorts.java
│   ├── 13_sorts/
│   │   ├── BucketSort.java
│   │   ├── CountingSort.java
│   │   └── RadixSort.java
│   ├── 17_skiplist/
│   │   ├── SkipList.java
│   │   └── SkipList2.java
│   ├── 18_hashtable/
│   │   └── HashTable.java
│   ├── 20_hashtable/
│   │   └── LRUBaseHashTable.java
│   ├── 24_tree/
│   │   └── BinarySearchTree.java
│   ├── 28_sorts/
│   │   └── HeapSort.java
│   ├── 30_graph/
│   │   └── Graph.java
│   ├── 32_BFRK
│   └── 36_ac_automata/
│       └── ACAutoMata.java
├── javascript/
│   ├── .gitkeep
│   ├── 05_array/
│   │   ├── .gitkeep
│   │   └── Array.md
│   ├── 06_linkedlist/
│   │   ├── .gitkeep
│   │   └── SinglyLinkedList.js
│   ├── 07_linkedlist/
│   │   ├── .gitkeep
│   │   └── LinkedListAlgo.js
│   ├── 08_stack/
│   │   ├── SampleBrowser.js
│   │   └── StackBasedOnLinkedList.js
│   ├── 09_queue/
│   │   ├── CircularQueueBasedOnLinkedList.js
│   │   └── QueueBasedOnLinkedList.js
│   ├── 11_sorts/
│   │   └── sort.js
│   ├── 12_sorts/
│   │   ├── KthNum.js
│   │   ├── MergeSort.js
│   │   └── QuickSort.js
│   ├── 13_sorts/
│   │   ├── bucketSort.js
│   │   └── countingSort.js
│   ├── 15_binary/
│   │   └── binaryFind.js
│   ├── 16_binary/
│   │   └── binary-find.js
│   ├── 17_skiplist/
│   │   └── SkipList.js
│   ├── 18_hashmap/
│   │   └── HashTable.html
│   ├── 19_hashTable/
│   │   └── hashtable.js
│   ├── 23_tree/
│   │   └── binary_tree.js
│   ├── 28_heapsort/
│   │   ├── heap-sort.js
│   │   └── heap.js
│   ├── 35_trie/
│   │   └── trie.js
│   ├── 36_ac_automata/
│   │   ├── ac_automata.js
│   │   └── ac_automata_unicode.js
│   ├── 42_dynamic_programming/
│   │   └── levenshtein_distance.js
│   ├── 43_topological_sorting/
│   │   └── dsf.js
│   └── 45_bitmap/
│       └── bitmap.js
├── kotlin/
│   ├── 05_array/
│   │   ├── ArrayKt.kt
│   │   └── DynamicArray.kt
│   ├── 06_linkedlist/
│   │   └── SinglyLinkedList.kt
│   ├── 07_linkedlist/
│   │   └── LinkedListAlgo.kt
│   └── 08_stack/
│       └── StackBasedOnLinkedList.kt
├── notes/
│   ├── .gitkeep
│   ├── 10_recursion/
│   │   └── readme.md
│   ├── 11_sorts/
│   │   └── readme.md
│   ├── 12_sorts/
│   │   ├── .gitkeep
│   │   └── readme.md
│   ├── 13_sorts/
│   │   ├── .gitkeep
│   │   └── readme.md
│   ├── 14_sorts/
│   │   ├── .gitkeep
│   │   └── readme.md
│   ├── 15_bsearch/
│   │   ├── .gitkeep
│   │   └── readme.md
│   ├── 16_bsearch/
│   │   ├── .gitkeep
│   │   └── readme.md
│   ├── 17_skiplist/
│   │   ├── .gitkeep
│   │   └── readme.md
│   ├── 18_hashtable/
│   │   ├── .gitkeep
│   │   └── readme.md
│   ├── 19_hashtable/
│   │   ├── .gitkeep
│   │   └── readme.md
│   └── 20_hashtable/
│       ├── .gitkeep
│       └── readme.md
├── object-c/
│   ├── .gitkeep
│   ├── 05_array/
│   │   ├── .gitkeep
│   │   ├── MyArray.h
│   │   └── MyArray.m
│   ├── 06_linkedlist/
│   │   ├── .gitkeep
│   │   ├── ListNode.h
│   │   ├── ListNode.m
│   │   ├── SinglyLinkedList.h
│   │   ├── SinglyLinkedList.m
│   │   └── SinglyLinkedListTests.m
│   ├── 07_linkedlist/
│   │   └── .gitkeep
│   ├── 08_stack/
│   │   ├── LinkedStack.h
│   │   ├── LinkedStack.m
│   │   ├── LinkedStackTests.m
│   │   ├── ListNode.h
│   │   ├── ListNode.m
│   │   └── stack_practice/
│   │       ├── ArrayStack.h
│   │       ├── ArrayStack.m
│   │       ├── BalancedParentheses.h
│   │       ├── BalancedParentheses.m
│   │       ├── FourOperation.h
│   │       ├── FourOperation.m
│   │       └── main.m
│   ├── 11_Sort/
│   │   ├── Sort.h
│   │   └── Sort.m
│   └── 33_bm_match/
│       ├── BM.h
│       ├── BM.m
│       └── main.m
├── php/
│   ├── .gitignore
│   ├── 05_array/
│   │   ├── .gitkeep
│   │   ├── array.php
│   │   └── array_test.php
│   ├── 06_linkedlist/
│   │   ├── .gitkeep
│   │   ├── SingleLinkedList.php
│   │   ├── SingleLinkedListNode.php
│   │   └── main.php
│   ├── 07_linkedlist/
│   │   ├── .gitkeep
│   │   └── main.php
│   ├── 08_stack/
│   │   ├── .gitkeep
│   │   ├── Compute.php
│   │   ├── StackOnLinkedList.php
│   │   └── main.php
│   ├── 09_queue/
│   │   ├── QueueOnLinkedList.php
│   │   ├── Sequential.php
│   │   └── main.php
│   ├── 10_heap/
│   │   ├── Heap.php
│   │   ├── findmiddle.php
│   │   ├── main.php
│   │   └── topn.php
│   ├── 11_sort/
│   │   └── Sort.php
│   ├── 12_sort/
│   │   ├── mergeSort.php
│   │   └── quicksort.php
│   ├── 13_sort/
│   │   ├── bucketSort.php
│   │   ├── countingSort.php
│   │   └── radixSort.php
│   ├── 15_binary/
│   │   └── binary.php
│   ├── 16_binary/
│   │   └── binary.php
│   ├── 17_skiplist/
│   │   └── skipList.php
│   ├── 24_tree/
│   │   ├── Tree.php
│   │   ├── TreeNode.php
│   │   ├── levelOrder.php
│   │   └── main.php
│   ├── 38_divide_and_conquer/
│   │   └── matrix_production.php
│   ├── 39_backtracking/
│   │   └── queens.php
│   ├── README.md
│   ├── Stack/
│   │   └── Compute.php
│   ├── buildAutoLoad.sh
│   └── composer.json
├── python/
│   ├── .gitkeep
│   ├── 05_array/
│   │   ├── .gitkeep
│   │   └── myarray.py
│   ├── 06_linkedlist/
│   │   ├── .gitkeep
│   │   ├── LRUCache.py
│   │   ├── palindrome.py
│   │   ├── singlyLinkedList.py
│   │   └── singly_linked_list.py
│   ├── 07_linkedlist/
│   │   ├── .gitkeep
│   │   └── linked_list_algo.py
│   ├── 08_stack/
│   │   ├── linked_stack.py
│   │   └── simple_browser.py
│   ├── 09_queue/
│   │   ├── array_queue.py
│   │   ├── circular_queue.py
│   │   ├── dynamic_array_queue.py
│   │   └── linked_queue.py
│   ├── 11_sorts/
│   │   └── sorts.py
│   ├── 12_sorts/
│   │   ├── merge_sort.py
│   │   ├── quick_sort.py
│   │   └── quicksort_twoway.py
│   ├── 14_sorts/
│   │   └── counting_sort.py
│   ├── 15_bsearch/
│   │   ├── bsearch.py
│   │   └── bsearch_recursion.py
│   ├── 16_bsearch/
│   │   └── bsearch_variants.py
│   ├── 17_skiplist/
│   │   ├── skip_list.py
│   │   └── skip_list_comments.py
│   ├── 23_binarytree/
│   │   ├── binary_search_tree.py
│   │   └── binary_tree.py
│   ├── 24_tree/
│   │   └── binary_search_tree.py
│   ├── 26_red_black_tree/
│   │   └── red_black_tree.py
│   ├── 28_binary_heap/
│   │   ├── binary_heap.py
│   │   ├── binary_heap_sort.py
│   │   ├── heap.py
│   │   ├── priority_queue.py
│   │   └── top_k.py
│   ├── 28_heap/
│   │   ├── heap.py
│   │   └── min_heap.py
│   ├── 31_bfs_dfs/
│   │   ├── bfs_dfs.py
│   │   ├── graph.py
│   │   └── graph_application.py
│   ├── 32_bf_rk/
│   │   └── bf_rk.py
│   ├── 33_bm/
│   │   ├── bm.py
│   │   └── bm_.py
│   ├── 34_kmp/
│   │   ├── kmp.py
│   │   └── kmp_.py
│   ├── 35_trie/
│   │   ├── trie.py
│   │   └── trie_.py
│   ├── 36_ac_automata/
│   │   ├── ac_automata.py
│   │   └── ac_automata_.py
│   ├── 38_divide_and_conquer/
│   │   └── merge_sort_counting.py
│   ├── 39_back_track/
│   │   ├── 01_bag.py
│   │   ├── eight_queens.py
│   │   ├── permutations.py
│   │   └── regex.py
│   ├── 39_backtracking/
│   │   └── backtracking.py
│   ├── 40_dynamic_programming/
│   │   ├── 01_bag.py
│   │   ├── knapsack.py
│   │   └── yh_triangle.py
│   ├── 41_dynamic_programming/
│   │   ├── coins_problem.py
│   │   └── min_dist.py
│   ├── 42_dynamic_programming/
│   │   ├── longest_increasing_subsequence.py
│   │   └── min_edit_dist.py
│   ├── 43_topological_sorting/
│   │   └── topological_sorting.py
│   ├── 44_shortest_path/
│   │   ├── dijkstra.py
│   │   └── shortest_path.py
│   ├── 45_bitmap/
│   │   └── bitmap.py
│   └── array.py
├── rust/
│   ├── 05_array/
│   │   └── main.rs
│   ├── 07_linkedlist/
│   │   ├── linked_list_cycle.rs
│   │   ├── merge_two_sorted_lists.rs
│   │   ├── middle_of_the_linked_list.rs
│   │   ├── remove_nth_node_from_end_of_list.rs
│   │   ├── reverse_linked_list.rs
│   │   └── util/
│   │       └── linked_list.rs
│   ├── 08_stack/
│   │   ├── simple_browser.rs
│   │   ├── stack_based_on_array.rs
│   │   └── stack_based_on_linked_list.rs
│   ├── 09_queue/
│   │   ├── array_queue.rs
│   │   ├── circle_queue.rs
│   │   └── linked_list_queue.rs
│   ├── 11_sorts/
│   │   ├── bubble_sort.rs
│   │   ├── insertion_sort.rs
│   │   └── selection_sort.rs
│   ├── 12_sorts/
│   │   ├── kth_largest.rs
│   │   ├── merge_sort.rs
│   │   └── quick_sort.rs
│   ├── 13_sorts/
│   │   ├── bucket_sort.rs
│   │   ├── counting_sort.rs
│   │   ├── radix_sort.rs
│   │   └── sort_string.rs
│   ├── 15_binary_search/
│   │   ├── binary_search.rs
│   │   └── sqrtx.rs
│   ├── 16_binary_search/
│   │   ├── binary_search.rs
│   │   └── search_in_rotated_sorted_array.rs
│   ├── 19_hash_table/
│   │   └── hash_table.rs
│   ├── 23_binary_tree/
│   │   ├── inorder_traversal.rs
│   │   ├── level_order_traversal.rs
│   │   ├── postorder_traversal.rs
│   │   ├── preorder_traversal.rs
│   │   └── util/
│   │       └── tree.rs
│   ├── 24_binary_tree/
│   │   ├── insert_in_binary_tree.rs
│   │   ├── max_depth_in_binary_tree.rs
│   │   ├── search_in_binary_tree.rs
│   │   └── util/
│   │       └── tree.rs
│   ├── 28_heap/
│   │   ├── build_heap.rs
│   │   ├── heap.rs
│   │   └── sort_heap.rs
│   ├── 29_heap/
│   │   ├── get_median.rs
│   │   ├── get_top_k.rs
│   │   └── merge_sorted_array.rs
│   ├── 31_graph/
│   │   └── graph_search.rs
│   ├── 32_string/
│   │   └── bf_rk.rs
│   ├── 33_string/
│   │   └── bm.rs
│   ├── 34_string/
│   │   └── kmp.rs
│   ├── 35_trie/
│   │   └── trie.rs
│   ├── 38_divide_and_conquer/
│   │   └── merge_sort_count.rs
│   ├── 39_back_tracking/
│   │   ├── bag.rs
│   │   ├── bag_exec.rs
│   │   ├── n_queens.rs
│   │   └── regex.rs
│   ├── 40_dynamic_programming/
│   │   ├── bag.rs
│   │   ├── knapsack.rs
│   │   └── triangle.rs
│   ├── 41_dynamic_programming/
│   │   ├── coin_change.rs
│   │   └── min_dis_path.rs
│   └── 42_dynamic_programming/
│       ├── edit_distance.rs
│       └── longest_increasing_subsequence.rs
├── scala/
│   ├── .gitignore
│   ├── build.sbt
│   ├── project/
│   │   └── build.properties
│   └── src/
│       ├── main/
│       │   └── scala/
│       │       ├── ch05_array/
│       │       │   └── ArrayDemo.scala
│       │       ├── ch06_linkedlist/
│       │       │   └── SinglyLinkedList.scala
│       │       ├── ch07_linkedlist/
│       │       │   └── LinkedListAlgo.scala
│       │       ├── ch08_stack/
│       │       │   ├── BrowserDemo.scala
│       │       │   └── StackDemo.scala
│       │       ├── ch09_queue/
│       │       │   ├── ArrayQueue.scala
│       │       │   ├── CircularQueue.scala
│       │       │   ├── DemoQueue.scala
│       │       │   ├── DynamicArrayQueue.scala
│       │       │   └── LinkedListQueue.scala
│       │       ├── ch10_recursive/
│       │       │   └── RecursiveDemo.scala
│       │       ├── ch11_sorts/
│       │       │   └── Sorts.scala
│       │       ├── ch12_sorts/
│       │       │   ├── MergeSort.scala
│       │       │   └── QuickSort.scala
│       │       ├── ch15_bsearch/
│       │       │   ├── BSearch.scala
│       │       │   └── BSearchRecursive.scala
│       │       ├── ch16_bsearch/
│       │       │   └── BSearch.scala
│       │       ├── ch17_skip_list/
│       │       │   └── SkipList.scala
│       │       ├── ch20_linked_hash_map/
│       │       │   └── LRUCache.scala
│       │       ├── ch23_binary_tree/
│       │       │   └── BinaryTree.scala
│       │       ├── ch24_binary_search_tree/
│       │       │   └── BinarySearchTree.scala
│       │       ├── ch28_heap/
│       │       │   └── Heap.scala
│       │       ├── ch29_heap_solutions/
│       │       │   ├── FileMerger.scala
│       │       │   ├── MiddleNumberKeeper.scala
│       │       │   └── TopKItemsKeeper.scala
│       │       ├── ch31_graph/
│       │       │   └── Graph.scala
│       │       ├── ch32_matching/
│       │       │   ├── BruteForce.scala
│       │       │   └── RabinKarp.scala
│       │       ├── ch35_tire_tree/
│       │       │   └── TrieTree.scala
│       │       ├── ch39_back_tracking/
│       │       │   ├── BagWeight.scala
│       │       │   ├── EightQueens.scala
│       │       │   ├── NQueens.scala
│       │       │   └── Sudoku.scala
│       │       └── ch43_topology_sort/
│       │           └── GraphTopology.scala
│       └── test/
│           └── scala/
│               ├── ch05_array/
│               │   └── ArrayDemoSpec.scala
│               ├── ch06_linkedlist/
│               │   ├── NodeTest.scala
│               │   └── SinglyLinkedListTest.scala
│               ├── ch07_linkedlist/
│               │   └── LinkedListAlgoTest.scala
│               ├── ch08_stack/
│               │   ├── BrowserDemoTest.scala
│               │   └── StackDemoTest.scala
│               ├── ch09_queue/
│               │   ├── ArrayQueueTest.scala
│               │   ├── CircularQueueTest.scala
│               │   ├── DemoQueueTest.scala
│               │   ├── DynamicArrayQueueTest.scala
│               │   └── LinkedListQueueTest.scala
│               ├── ch10_recursive/
│               │   └── RecursiveDemoTest.scala
│               ├── ch11_sorts/
│               │   └── SortsTest.scala
│               ├── ch12_sorts/
│               │   ├── MergeSortTest.scala
│               │   └── QuickSortTest.scala
│               ├── ch15_bsearch/
│               │   ├── BSearchRecursiveTest.scala
│               │   └── BSearchTest.scala
│               ├── ch16_bsearch/
│               │   └── BSearchTest.scala
│               ├── ch17_skip_list/
│               │   └── SkipListTest.scala
│               ├── ch20_linked_hash_map/
│               │   └── LRUCacheTest.scala
│               ├── ch23_binary_tree/
│               │   └── BinaryTreeTest.scala
│               ├── ch24_binary_search_tree/
│               │   └── BinarySearchTreeTest.scala
│               ├── ch28_heap/
│               │   └── HeapTest.scala
│               ├── ch29_heap_solutions/
│               │   ├── FileMergerTest.scala
│               │   ├── MiddleNumberKeeperTest.scala
│               │   └── TopKItemsKeeperTest.scala
│               ├── ch31_graph/
│               │   └── GraphTest.scala
│               ├── ch32_matching/
│               │   ├── BruteForceTest.scala
│               │   └── RabinKarpTest.scala
│               ├── ch35_tire_tree/
│               │   └── TrieTreeTest.scala
│               ├── ch39_back_tracking/
│               │   ├── BagWeightTest.scala
│               │   ├── EightQueensTest.scala
│               │   ├── NQueensTest.scala
│               │   └── SudokuTest.scala
│               └── ch43_topology_sort/
│                   └── GraphTopologyTest.scala
├── swift/
│   ├── 05_array/
│   │   └── MyArray.swift
│   ├── 06_linkedlist/
│   │   └── SinglyLinkedList.swift
│   ├── 07_linkedlist/
│   │   └── LinkedListAlgo.swift
│   ├── 08_stack/
│   │   ├── Browser.swift
│   │   ├── BrowserDemo.swift
│   │   ├── Stack.swift
│   │   └── StackBasedOnLinkedList.swift
│   ├── 09_queue/
│   │   ├── ArrayQueue.swift
│   │   ├── CircularQueue.swift
│   │   ├── Queue.swift
│   │   └── QueueBasedOnLinkedList.swift
│   ├── 11_sorts/
│   │   └── Sorts.swift
│   ├── 12_sorts/
│   │   ├── QuickSort.swift
│   │   ├── SortsTests.swift
│   │   └── mergeSort.swift
│   └── 14_sorts/
│       └── CountingSort.swift
└── typescript/
    ├── 06_linkedlist/
    │   ├── LRUCache.ts
    │   ├── LinkedList.ts
    │   ├── List.ts
    │   └── SingleLinkedList.ts
    ├── 07_linkedlist/
    │   └── LinkedListAlog.ts
    ├── 08_stack/
    │   └── StackAndBrowser.ts
    ├── 09_queue/
    │   ├── CircularQueue.ts
    │   ├── README.md
    │   └── SimpleQueue.ts
    ├── 10_recursive/
    │   └── climbStairs.ts
    ├── 11_sorts/
    │   └── simpleSort.ts
    ├── 12_sorts/
    │   ├── KthNum.ts
    │   ├── MergeSort.ts
    │   └── quickSort.ts
    ├── 13_sorts/
    │   ├── BucketSort.ts
    │   └── CountingSort.ts
    ├── 14_binarysearch/
    │   └── BinarySearch.ts
    ├── 15_binarysearch/
    │   └── BinaryFind.ts
    ├── 17_skiplist/
    │   └── SkipList.ts
    └── 24_treesearch/
        └── TreeSearch.ts

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
*.DS_Store
*.exe

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# editor files
.vscode
.*.swp

# WebStorm
.idea/

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/

# Visual Studio 2015/2017 cache/options directory
.vs/

**/*.idea
**/*.iml
**/*out


================================================
FILE: DynamicStackBaseArray.java
================================================
package Stack;

import java.util.Iterator;

/**
 * 顺序栈的动态扩容
 * Author: PeiJiaNi
 * @param <T>  顺序栈元素类型
 */

public class DynamicStackBaseArray<T> implements Iterable<T> {
    private T[] items;   // 数组
    private int count;   // 栈中的元素个数
    private int length;  // 栈空间大小

    /**
     * 初始化栈
     *
     * @param length 栈空间大小
     */
    public DynamicStackBaseArray(int length) {
        this.items = (T[]) new Object[length];
        this.count = 0;
        this.length = length;
    }

    /**
     * 入栈操作 平均时间复杂度O(1)
     *
     * @param item 入栈元素
     */
    public void push(T item) {
        // 栈空间已满,则扩容
        if (count == length) {
            resize(2 * items.length);
        }

        items[count++] = item;
    }

    /**
     * 出栈操作 平均时间复杂度O(1)
     *
     * @return 如果栈内不为空,则返回栈顶元素,否则返回-1
     */
    public T pop() {
        if (count == 0) {
            System.out.println("当前栈已空,无法进行出栈操作");
            return null;
        }

        T item = items[--count];
        items[count] = null;

        if (count > 0 && (count == items.length / 4)) {
            resize(items.length / 2);
        }

        // 返回下标为 count-1 的数组元素,并且栈中元素个数count-1
        return item;
    }

    /**
     * 栈空间动态增加或减小
     *
     * @param size
     */
    private void resize(int size) {
        T[] newItems = (T[]) new Object[size];
        for (int i = 0; i < count; i++) {
            newItems[i] = this.items[i];
        }
        this.items = newItems;
    }

    //返回栈中最近添加的元素而不删除它
    public T peek() {
        return items[count - 1];
    }

    /**
     * 判断当前栈是否为空
     *
     * @return 栈为空,则返回true,否则返回-1
     */
    public boolean isEmpty() {
        return count == 0;
    }

    /**
     * 返回栈中元素个数
     *
     * @return
     */
    public int size() {
        return count;
    }

    @Override
    public Iterator<T> iterator() {
        return new ArrayIterator();
    }

    // 内部类
    class ArrayIterator implements Iterator {
        int numOfItems = count;

        @Override
        public boolean hasNext() {
            return numOfItems > 0;
        }

        @Override
        public T next() {
            return items[--numOfItems];
        }
    }

    public static void main(String[] args) {
        DynamicStackBaseArray<Integer> stack = new DynamicStackBaseArray<Integer>(6);
        stack.push(1);
        stack.push(2);
        stack.push(3);
        stack.push(4);
        stack.push(5);
        // System.out.println(stack.peek());
        Iterator iterator = stack.iterator();
        // System.out.println(iterator.hasNext());
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }

    }

}



================================================
FILE: LICENSE
================================================
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [yyyy] [name of copyright owner]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.


================================================
FILE: README.md
================================================
# 数据结构和算法必知必会的50个代码实现
### 微信搜索我的公众号“小争哥”,或者微信扫描下面二维码关注
### 关注微信公众号,回复”PDF“获取独家算法资料。
### 前Google工程师,10万人跟着学的《数据结构和算法之美》《设计模式之美》专栏作者
![t2](https://github.com/wangzheng0822/markdownphotos/blob/master/pics/qrcode_for_gh_9b0e7afdff20_258.jpg)

## 数组
* 实现一个支持动态扩容的数组
* 实现一个大小固定的有序数组,支持动态增删改操作
* 实现两个有序数组合并为一个有序数组

## 链表
* 实现单链表、循环链表、双向链表,支持增删操作
* 实现单链表反转
* 实现两个有序的链表合并为一个有序链表
* 实现求链表的中间结点

## 栈
* 用数组实现一个顺序栈
* 用链表实现一个链式栈
* 编程模拟实现一个浏览器的前进、后退功能

## 队列
* 用数组实现一个顺序队列
* 用链表实现一个链式队列
* 实现一个循环队列

## 递归
* 编程实现斐波那契数列求值f(n)=f(n-1)+f(n-2)
* 编程实现求阶乘n!
* 编程实现一组数据集合的全排列

## 排序
* 实现归并排序、快速排序、插入排序、冒泡排序、选择排序
* 编程实现O(n)时间复杂度内找到一组数据的第K大元素

## 二分查找
* 实现一个有序数组的二分查找算法
* 实现模糊二分查找算法(比如大于等于给定值的第一个元素)

## 散列表
* 实现一个基于链表法解决冲突问题的散列表
* 实现一个LRU缓存淘汰算法

## 字符串
* 实现一个字符集,只包含a~z这26个英文字母的Trie树
* 实现朴素的字符串匹配算法

## 二叉树
* 实现一个二叉查找树,并且支持插入、删除、查找操作
* 实现查找二叉查找树中某个节点的后继、前驱节点
* 实现二叉树前、中、后序以及按层遍历

## 堆
* 实现一个小顶堆、大顶堆、优先级队列
* 实现堆排序
* 利用优先级队列合并K个有序数组
* 求一组动态数据集合的最大Top K

## 图
* 实现有向图、无向图、有权图、无权图的邻接矩阵和邻接表表示方法
* 实现图的深度优先搜索、广度优先搜索
* 实现Dijkstra算法、A*算法
* 实现拓扑排序的Kahn算法、DFS算法

## 回溯
* 利用回溯算法求解八皇后问题
* 利用回溯算法求解0-1背包问题

## 分治
* 利用分治算法求一组数据的逆序对个数

## 动态规划
* 0-1背包问题
* 最小路径和
* 编程实现莱文斯坦最短编辑距离
* 编程实现查找两个字符串的最长公共子序列
* 编程实现一个数据序列的最长递增子序列


================================================
FILE: StackBaseArray.java
================================================
package Stack;

/**
 * 顺序栈(基于数组实现)
 * Author: PeiJiaNi
 */
public class StackBaseArray {
    private int[] items;    // 数组
    private int count;      // 栈中元素个数
    private int length;   // 栈空间大小

    public StackBaseArray(int capactiy) {
        this.items = new int[capactiy];
        this.count = 0;
        this.length = capactiy;
    }

    /**
     * 入栈操作 时间复杂度O(1)
     * @param item 要入栈的元素
     * @return     入栈成功则返回true,否则返回false
     */
    public boolean  push(int item) {
        if(count == length) {
            System.out.println("当前栈已满,无法进行入栈操作");
            return false;
        }
        items[count] = item;
        ++count;
        return true;
    }

    /**
     * 出栈操作 时间复杂度O(1)
     * @return 如果栈内不为空,则返回栈顶元素,否则返回-1
     */
    public int  pop(){
        if(count == 0) {
            System.out.println("当前栈已空,无法进行出栈操作");
            return -1;
        }

        // 返回下标为 count-1 的数组元素,并且栈中元素个数count-1
        return items[--count];
    }

    public static void main(String[] args){
        StackBaseArray stack = new StackBaseArray(6);
        stack.push(1);
        stack.push(2);
        stack.push(3);
        stack.push(4);
        stack.push(5);
        System.out.println(stack.pop());
        System.out.println(stack.pop());
        System.out.println(stack.pop());
        System.out.println(stack.pop());
        System.out.println(stack.pop());

    }


}



================================================
FILE: c-cpp/.gitignore
================================================
# main files
main.*

# executives
a.out

# objective files
*.o
*.obj


================================================
FILE: c-cpp/.gitkeep
================================================


================================================
FILE: c-cpp/05_array/.gitkeep
================================================


================================================
FILE: c-cpp/05_array/Array_gp.c
================================================
#include "Array.h"

#include <string.h>
#include <stdbool.h>

Array* arrayCreate()
{
    struct Array *array = NULL;
    array = malloc(sizeof(*array));
    if (NULL == array)
    {
        return NULL;
    }

    array->p = NULL;

    array->size = 0;
    array->typeSize = 0;
    array->len = 0;

    array->dup = NULL;
    array->free = NULL;
    array->match = NULL;

    return array;
}

void arrayInit(Array *array, int size, int typeSize)
{
    if (NULL == array
        || typeSize <= 0
        || size < 0)
    {
        return;
    }

    void *p = calloc(1, size* typeSize);
    if (NULL == p)
    {
        return;
    }

    array->p = p;
    array->len = 0;
    array->size = size;
    array->typeSize = typeSize;
}

int arrayInsert(Array *array, size_t pos, void *const value)
{
    if (NULL == array)
    {
        return -1;
    }

    if (array->len >= array->size)
    {
        return -2;
    }

    if (pos > array->size || pos <= 0)
    {
        return -3;
    }

    char *pBegin = array->p;
    for (size_t i = array->len; i > pos - 1; --i)
    {
        void *pNew = pBegin + i * array->typeSize;
        void *pOld = pBegin + (i - 1) *array->typeSize;
        if (NULL != array->dup)
        {
            array->dup(pNew, pOld);
        }
        else
        {
            memcpy(pNew, pOld, array->typeSize);
        }
    }

    void *pCopy = (void*)(pBegin + ((pos - 1) * array->typeSize));
    if (NULL != array->dup)
    {
        array->dup(pCopy, value);
    }
    else
    {
        memcpy(pCopy, value, array->typeSize);
    }
    ++array->len;
    return 0;
}

size_t arraySearchValue(Array *array, void* const value)
{
    if (NULL == array)
    {
        return -1;
    }

    char *pBegin = array->p;
    size_t i = 0;
    for (; i < array->len; ++i)
    {
        int nCmp = 0;
        if (NULL != array->match)
        {
            nCmp = array->match(pBegin + i * array->typeSize, value);
        }
        else
        {
            nCmp = memcmp(pBegin + i * array->typeSize, value, array->typeSize);
        }

        if (nCmp == 0)
        {
            break;
        }
    }

    return i;
}

void* arrayIndex(Array *array, size_t index)
{
    if (NULL == array)
    {
        return NULL;
    }

    if (index > array->len
        || index <= 0)
    {
        return NULL;
    }

    char *pBegin = array->p;
    return pBegin + array->typeSize * (index - 1);
}

int arrayModify(Array *array, size_t pos, void *const value)
{
    if (NULL == array)
    {
        return -1;
    }
    if (pos > array->len
        || pos <= 0)
    {
        return -2;
    }

    char *pBegin = array->p;
    void *pOld = pBegin + (pos - 1) * array->typeSize;
    if (NULL != array->dup)
    {
        array->dup(pOld, value);
    }
    else
    {
        memcpy(pOld, value, array->typeSize);
    }

    return 0;
}

size_t arrayLen(Array *array)
{
    if (NULL == array)
    {
        return 0;
    }

    return array->len;
}

size_t arraySize(Array *array)
{
    if (NULL == array)
    {
        return 0;
    }

    return array->size;
}

void arrayEmpty(Array *array)
{
    if (NULL == array)
    {
        return;
    }

    free(array->p);
    array->p = NULL;
    free(array);
    array = NULL;
}

void arrayDelValue(Array *array, void *value)
{
    if (NULL == array)
    {
        return;
    }

    char* pBegin = array->p;
    bool bCopy = false;
    for (size_t i = 0; i < array->len; ++i)
    {
        if (!bCopy)
        {
            int nCmp = 0;
            if (NULL != array->match)
            {
                nCmp = array->match(pBegin + i * array->typeSize, value);
            }
            else
            {
                nCmp = memcmp(pBegin + i * array->typeSize, value, array->typeSize);
            }

            if (0 == nCmp)
            {
                bCopy = true;
                continue;
            }
        }
        else
        {
            void *pOld = pBegin + (i + 1) * array->typeSize;
            void *pNew = pBegin + i * array->typeSize;
            if (NULL != array->dup)
            {
                array->dup(pNew, pOld);
            }
            else
            {
                memcpy(pNew, pOld, array->typeSize);
            }
        }
    }

    if (bCopy)
    {
        --array->len;
    }
}

void arrayDelIndex(Array *array, size_t pos)
{
    if (NULL == array)
    {
        return;
    }

    if (pos > array->len || pos <= 0)
    {
        return;
    }

    char* pBegin = array->p;
    for (size_t i = pos - 1; i < array->len - 1; ++i)
    {
        void *pOld = pBegin + (i + 1) * array->typeSize;
        void *pNew = pBegin + i * array->typeSize;
        if (NULL != array->dup)
        {
            array->dup(pNew, pOld);
        }
        else
        {
            memcpy(pNew, pOld, array->typeSize);
        }
    }

    --array->len;
}

================================================
FILE: c-cpp/05_array/Array_gp.h
================================================
#ifndef __ARRAY_H__
#define __ARRAY_H__

#include <stdio.h>
#include <stdlib.h>

typedef struct Array
{
    // pָĿռС
    size_t size;
    // pָѾʹõĿռС
    size_t len;
    // ͵ĴС
    size_t typeSize;
    // ֵƺ
    void(*dup)(void *ptr, void *key);
    // ֵͷź
    void(*free)(void *ptr);
    // ֵȽϺ
    int(*match)(void *ptr, void *key);
    // ݵָ
    void   *p;
}Array;

#define arraySetDupMethod(a, m) ((a)->dup = (m))
#define arraySetFreeMethod(a, m) ((a)->free = (m))
#define arraySetMatchMethod(a, m) ((a)->match = (m))

#define arrayGetDupMethod(a) ((a)->dup)
#define arrayGetFree(a) ((a)->free)
#define arrayGetMatchMethod(a) ((a)->match)

Array* arrayCreate();
void arrayInit(Array *array, int size, int typeSize);

int arrayInsert(Array *array, size_t pos, void *const value);
size_t arraySearchValue(Array *array, void* const value);
void* arrayIndex(Array *array, size_t index);
int arrayModify(Array *array, size_t pos, void *const value);

size_t arrayLen(Array *array);
size_t arraySize(Array *array);

void arrayEmpty(Array *array);
void arrayDelValue(Array *array, void *value);
void arrayDelIndex(Array *array, size_t pos);

#endif // !__ARRAY_H__

================================================
FILE: c-cpp/05_array/array.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct array {
	int size;
	int used;
	int *arr;
};

void dump(struct array *array)
{
	int idx;

	for (idx = 0; idx < array->used; idx++)
		printf("[%02d]: %08d\n", idx, array->arr[idx]);
}

void alloc(struct array *array)
{
	array->arr = (int *)malloc(array->size * sizeof(int));
}

int insert(struct array *array, int elem)
{
	int idx;
	if (array->used >= array->size)
		return -1;

	for (idx = 0; idx < array->used; idx++) {
		if (array->arr[idx] > elem)
			break;
	}

	if (idx < array->used)
		memmove(&array->arr[idx+1], &array->arr[idx],
			(array->used - idx) * sizeof(int));

	array->arr[idx] = elem;
	array->used++;
	return idx;
}

int delete(struct array *array, int idx)
{
	if (idx < 0 || idx >= array->used)
		return -1;

	memmove(&array->arr[idx], &array->arr[idx+1],
		(array->used - idx - 1) * sizeof(int));
	array->used--;
	return 0;
}

int search(struct array *array, int elem)
{
	int idx;

	for (idx = 0; idx < array->used; idx++) {
		if (array->arr[idx] == elem)
			return idx;
		if (array->arr[idx] > elem)
			return -1;
	}

	return -1;
}

int main()
{
	int idx;
	struct array ten_int = {10, 0, NULL};

	alloc(&ten_int);
	if (!ten_int.arr)
		return -1;
	insert(&ten_int, 1);
	insert(&ten_int, 3);
	insert(&ten_int, 2);
	printf("=== insert 1, 3, 2\n");
	dump(&ten_int);

	idx = search(&ten_int, 2);
	printf("2 is at position %d\n", idx);
	idx = search(&ten_int, 9);
	printf("9 is at position %d\n", idx);

	printf("=== delete [6] element \n");
	delete(&ten_int, 6);
	dump(&ten_int);
	printf("=== delete [0] element \n");
	delete(&ten_int, 0);
	dump(&ten_int);
	return 0;
}


================================================
FILE: c-cpp/06_linkedlist/.gitkeep
================================================


================================================
FILE: c-cpp/06_linkedlist/Dlist/Dlist.c
================================================
/*************************************************************************
 > File Name: Dlist.c
 > Author:  jinshaohui
 > Mail:    jinshaohui789@163.com
 > Time:    18-10-07
 > Desc:    
 ************************************************************************/
#include<stdio.h>
#include <stdbool.h>
#include "./Dlist.h"



void dlist_init(stDlistHead *dlist)		//链表初始化
{
	dlist->size = 0;
	dlist->head = NULL;
	dlist->tail = NULL;
	return;
}

void dlist_destory(stDlistHead *dlist)		//删除链表
{
	stDlistNode *pNode = NULL;
	
	while(dlist->size > 0)
	{
		pNode = dlist->head;
		dlist->head = dlist->head->next;
		free(pNode);
		dlist->size--;
	}

	memset(dlist,0,sizeof(stDlistHead));

	return;
}

int dlist_insert_head(stDlistHead *dlist,stDlistNode *pNode,int data)		//插入头结点,操作的链表,操作的节点,数据
{
   if(pNode == NULL)		//当只传递一个数据时
   {
	    pNode = (stDlistNode *)malloc(sizeof(stDlistNode));		//新建节点,为节点分配空间(malloc()可能需要#include<malloc.h>)
	    if (pNode == NULL)
	    {
		    return -1;
	    }
    }

    pNode->data = data;			
	pNode->prev = NULL;
	pNode->next = NULL;

	if (dlist->size == 0)		//如果链表长度为0,即链表当前无节点,
	{
		dlist->head = pNode;
		dlist->tail = pNode;
	}
	else                           //如果链表已有节点,则令新插入节点为头节点
	{
		pNode->next = dlist->head;
		dlist->head->prev = pNode;
		dlist->head = pNode;			
	}

	dlist->size++;		//每成功调用一次,链表长度+1
	return 0;
}

stDlistNode * dlist_remove_tail(stDlistHead *dlist)		//删除尾部节点,并返回删除节点
{
	stDlistNode *pNode = NULL;

	if(dlist->size == 0)
	{
		return NULL;
	}

    pNode = dlist->tail;
	if(dlist->size > 1)
	{
		dlist->tail = dlist->tail->prev;
		dlist->tail->next = NULL;
	}
	else
	{
		dlist->head = NULL;
		dlist->tail = NULL;
	}
	dlist->size--;
	return pNode;
}

void dlist_remove_node(stDlistHead * dlist,stDlistNode *pNode) 		//删除指定节点
{
	if ((dlist == NULL)||(pNode == NULL))
	{
		return;
	}

	if (dlist->head == pNode)
	{
		dlist->head = dlist->head->next;
	}
	else if (dlist->tail == pNode)
	{
		dlist->tail = pNode->prev;

		dlist->tail->next = NULL;
	}
	else
	{
		pNode->prev->next = pNode->next;
		pNode->next->prev = pNode->prev;
	}
	dlist->size--;
	pNode->prev = NULL;
	pNode->next = NULL;
	
	if (dlist->size == 0)
	{
		memset(dlist,0,sizeof(stDlistHead)); 		//将dlist占用内存块的所有值置为0,也就是清空head,tail指针内容
	}

	return;
}
stDlistNode * dlist_search(stDlistHead * dlist,int data) 		//根据值搜索节点,并返回
{
	stDlistNode *pNode = dlist->head;
	while(pNode != NULL)
	{
		if (pNode->data == data)
		{
			return pNode;
		}
		pNode = pNode->next;

    }
	return NULL;
}

void dlist_dump(stDlistHead *dlist)		//显示链表中的数据
{
	int no = 0;
	stDlistNode *pNode = dlist->head;
	while(pNode != NULL)		
	{
		printf("\r\n [%d] = %d",no++,pNode->data);
		pNode = pNode->next;		//将pNode的下一个节点赋值给pNode,推进循环
	}

	return;
}


void Lru_dlist(stDlistHead *dlist,int data) 		//LRU(最近最少使用)缓存淘汰算法
{
	stDlistNode *pNode = NULL;

	pNode = dlist_search(dlist,data);		
	if (pNode != NULL) 				//如果在链表中找到这个值,则删除储存这个值的节点,之后吧这个节点放在头部
	{
		dlist_remove_node(dlist,pNode);
	}
	else if(dlist->size >= 4)			//没在链表中找到,且链表长度大于4,则从链表中删除尾部节点,将新数据放在头部
	{
		pNode = dlist_remove_tail(dlist);

	}
	
	dlist_insert_head(dlist ,pNode,data);

	return;
}

int main()
{
	stDlistHead dlist = {0};
    stDlistNode * pNode = NULL;

	dlist_init(&dlist);

	printf("\r\n inset 1,2,3");
	dlist_insert_head(&dlist,NULL,1);
	dlist_insert_head(&dlist,NULL,2);
	dlist_insert_head(&dlist,NULL,3);

	dlist_dump(&dlist);

	pNode = dlist_remove_tail(&dlist);
	if(pNode != NULL)
	{
		printf("\r\n remove %d",pNode->data);
	}
	dlist_insert_head(&dlist,pNode,4);
	dlist_dump(&dlist);

    Lru_dlist(&dlist,5);
	dlist_dump(&dlist);
    Lru_dlist(&dlist,6);
	dlist_dump(&dlist);
    Lru_dlist(&dlist,7);
	dlist_dump(&dlist);
    Lru_dlist(&dlist,5);
	dlist_dump(&dlist);



	while(dlist.size > 0)
	{
	    pNode = dlist_remove_tail(&dlist);
	    if(pNode != NULL)
	    { 
		    printf("\r\n remove %d",pNode->data);
	    	free (pNode);
    	}
	}

	return 0;
}


================================================
FILE: c-cpp/06_linkedlist/Dlist/Dlist.h
================================================
/*************************************************************************
 > File Name: Dlist.c
 > Author:  jinshaohui
 > Mail:    jinshaohui789@163.com
 > Time:    18-10-07
 > Desc:    
 ************************************************************************/
#include<stdio.h>

typedef struct DlistNode          //双向链表中每一个节点
{				  	
	struct DlistNode *prev;   //节点前项指针
	struct DlistNode *next;   //节点后项指针
	int    data;              //数据
}stDlistNode;

typedef struct Dlisthead          //定义链表总体
{
	int size;                 //链表长度
	stDlistNode *head;        //头指针
	stDlistNode *tail;        //尾部指针
}stDlistHead;



================================================
FILE: c-cpp/06_linkedlist/LRUBasedLinkedList.cpp
================================================
typedef int DataType;

//定义
class SNode
{
public:
    DataType data;
    SNode * next;
};

class SList 
{
public:
    SList();
    SList(int MaxSize);
    ~SList();
    void intsertElemAtBegin(DataType x);      //头部插入节点
    bool findElem(DataType x);              //查找x,存在则返回1,不存在则返回0
    void deleteElemAtEnd();             //删除尾节点
    bool deleteElem(DataType x);    //删除指定节点,如果存在则删除,返回1,如果不存在,则删除失败返回0
    bool isEmpty();                  // 查看链表是否为空,1表示不为空,0表示为空
    bool isFull();                   // 查看链表是否满,1表示不满,0表示满
    void printAll();             

    void * findElemOptim(DataType x);     //针对此应用的优化,查找,返回指定元素的前一个节点的指针
    void deleteElemOptim(void * snode);     //针对此应用的优化,删除
private:
    int MaxSize;       // 链表可以存放最大的数据
    int length;             // 链表的长度
    SNode * head;          // 指向头节点

};


/**
 * 1)单链表的插入,删除,查找操作;
 * 2)链表中存储的是 int 类型
 * 
 * Author:caozx
 */
#include<iostream>
using namespace std;

// 初始化单链表
SList::SList(){
    head = new SNode;     //申请头节点
    head -> next = NULL;
    this -> MaxSize = 10;
    this -> length = 0;
}
SList::SList(int MaxSize){
    head = new SNode;     //申请头节点
    head -> next = NULL;
    this -> MaxSize = MaxSize;
    this -> length = 0;
}

// 销毁单链表,要把开辟的空间都释放,然后再销毁。
SList::~SList(){
    SNode * ptr, * temp;
    ptr = head;
    while(ptr -> next != NULL){
        temp = ptr -> next;
        ptr -> next = ptr -> next -> next;
        delete temp;   
    }
    delete head ; //删除头节点
    this -> head = NULL;
    this -> length = 0;
}

//链表头部插入节点
void SList::intsertElemAtBegin(DataType x){
    SNode * ptr = new SNode;
    ptr -> data = x;

    ptr -> next = head ->next;
    head -> next = ptr;

    this -> length ++;
}

//查找x,存在则返回1,不存在则返回0

bool SList::findElem(DataType x)
{
    SNode * ptr;
    ptr = head;
    while(ptr -> next != NULL){
        if(ptr -> next ->data == x){
            return 1;
        }
        ptr = ptr -> next;
    }
    return 0;
}

// 删除尾结点
void SList::deleteElemAtEnd(){
    SNode * ptr , * temp;
    ptr = head;
    while(ptr -> next != NULL && ptr -> next -> next != NULL){   //倒数第二个节点
        ptr = ptr -> next;
    }
    temp = ptr -> next;
    ptr -> next = temp -> next;
    this -> length --;
    delete temp;
}

//删除指定节点,
//如果存在则删除,返回1,表示存在且删除成功;
//如果不存在则不删除,返回0,表示不存在该元素,不需要删除,也即删除失败
bool SList::deleteElem(DataType x)
{
    SNode * ptr, * temp;
    ptr = head;
    while(ptr -> next != NULL){
        if(ptr -> next ->data == x){
            temp = ptr -> next;
            ptr -> next = temp -> next;
            delete temp;
            this -> length --;
            return 1;
        }
        ptr = ptr -> next;
    }
    return 0;
}

// 查看链表是否为空,1表示不为空,0表示为空
bool SList::isEmpty()
{
    if(this -> length == 0){  //空
        return 0;
    }
    else{
        return 1;
    }
}

// 查看链表是否满,1表示不满,0表示满
bool SList::isFull()
{   
    if(this -> length == this -> MaxSize){  //满
        return 0;
    }
    else{
        return 1;
    }
}

// 打印
void SList::printAll()
{
    SNode * ptr;
    ptr = head;
    while(ptr -> next != NULL){
        ptr = ptr -> next;
        cout << ptr-> data <<"   ";
    }
    cout << endl;
}     

//针对此应用的优化,查找,
//若存在则返回指定元素的前一个节点的指针
//若不存在,则返回NULL

void * SList::findElemOptim(DataType x)
{
    SNode * ptr;
    ptr = head;
    while(ptr -> next != NULL){
        if(ptr -> next ->data == x){
            return (void *)ptr;
        }
        ptr = ptr -> next;
    }
    return NULL;
}

//针对此应用的优化,删除

void SList::deleteElemOptim(void * snode)
{
     SNode * ptr, * temp;
     ptr = (SNode *)snode;
     temp =  ptr -> next;
     ptr -> next = temp -> next;
     this -> length --;
     delete temp;
}
int main(int argc, char const *argv[])
{
    cout << "test "<< endl;   
    SList slist(10);     //缓存最大10个。
    int num = 0;
    while(1)
    {
        cout << "please enter a number,99999== exit" << endl;
        cin >> num;
        if(num == 99999)
            break;
        /* 未优化
        if(slist.findElem(num)){    //存在
            slist.deleteElem(num);     //把原来的位置删除
            slist.intsertElemAtBegin(num); //在链表头插入
        }
        */
       //优化
       SNode * prePtr = (SNode *)slist.findElemOptim(num);
       if(prePtr != NULL){    //存在
            slist.deleteElemOptim(prePtr);     //把原来的位置删除
            slist.intsertElemAtBegin(num); //在链表头插入
        }
        else{      //不存在
            if(slist.isFull()){    //不满
                slist.intsertElemAtBegin(num);
            }
            else{                   //满
                slist.deleteElemAtEnd();
                slist.intsertElemAtBegin(num);
            }
        }
        slist.printAll();
    }
    return 0;
    system("pause");
}


================================================
FILE: c-cpp/06_linkedlist/list_isPalindrome/LinkList.cpp
================================================
#include "LinkList.h"

void CreateListHead(LinkList *&L,ElemType a[],int n)
{
	int i;
	LinkList *s;
	L = (LinkList *)malloc(sizeof(LinkList));
	L->next = NULL;
	for(i = 0;i < n;i++)
	{
		s=(LinkList*)malloc(sizeof(LinkList));
		s->data = a[i];
		s->next = L->next;
		L->next = s;
	}
}
void CreateListTail(LinkList *&L,ElemType a[],int n)
{
	int i;
	LinkList * s,* r;
	L = (LinkList *)malloc(sizeof(LinkList));
	r = L;
	for(i = 0;i < n;i++)
	{
		s = (LinkList *)malloc(sizeof(LinkList));
		s->data = a[i];
		r->next = s;
		r = s;
	}
	r->next = NULL; 
}
void InitList(LinkList *&L)
{
	L=(LinkList *)malloc(sizeof(LinkList));
	L->next = NULL;
}
void DestroyList(LinkList *&L)
{
	LinkList * pre = L,*p = L->next;
	while(p!=NULL)
	{
		free(pre);
		pre = p;
		p = L->next;
	}
	free(pre);
}
bool ListEmpty(LinkList *L)
{
	return(L->next==NULL); 
}
int ListLength(LinkList *L)
{
	int n = 0;
	LinkList * p = L;
	while(p->next!=NULL)
	{
		n++;
		p=p->next;
	}
	return(n);
}
void ShowList(LinkList *L)
{
	LinkList * p = L->next;//ָʼڵ
	while(p!=NULL)
	{
		printf(" %c ",p->data);
		p = p->next; 
	} 
	printf("\n");
}
bool GetListElem(LinkList *L,int i,ElemType &e)
{
	int j = 0;
	LinkList *p = L;
	while(j<i&&p!=NULL)
	{
		j++;
		p=p->next;
	}
	if(p==NULL)
		return false;
	else
	{
		e=p->data;
		return true;
	}
}
int LocateElem(LinkList*L,ElemType e)
{
	int i=1;
	LinkList *p = L->next;
	while(p!=NULL&&p->data!=e){
		p=p->next;
		i++;
	}
	if(p==NULL)
	{
		return(0);
	}
	else
		return(i);
}
bool ListInsert(LinkList *&L,int i,ElemType e)
{
	int j=0;
	LinkList *p =L,*s;
	while(j<i-1&&p!=NULL)
	{
		j++;
		p=p->next;
	}
	if(p==NULL)
	{
		return false;
	}
	else
	{
		s= (LinkList*)malloc(sizeof(LinkList));
		s->data = e;
		s->next = p->next;
		p->next = s;
		return true;
	}
}
bool ListDelete(LinkList *&L,int i,ElemType &e)
{
	int j=0;
	LinkList * p =L,*q;
	while(j<i-1&&p!=NULL)
	{
		j++;
		p=p->next;
	}
	if(p==NULL)
		return false;
	else
	{
		q=p->next;
		if(q==NULL)
			return false;
		e=q->data;
		p->next=q->next;
		free(q);
		return true;
	}
}


================================================
FILE: c-cpp/06_linkedlist/list_isPalindrome/LinkList.h
================================================
#ifndef LINKLIST_H
#define LINKLIST_H

#include <stdlib.h>
#include <stdio.h>
typedef char ElemType;
typedef struct LNode 
{
	ElemType data;
	struct LNode*next;
}LinkList;

void CreateListHead(LinkList *&L,ElemType a[],int n);
void CreateListTail(LinkList *&L,ElemType a[],int n);
void InitList(LinkList *&L);
void DestroyList(LinkList *&L);
bool ListEmpty(LinkList *L);
int ListLength(LinkList *L);
void ShowList(LinkList *L);
bool GetListElem(LinkList *L,int i,ElemType &e);
int LocateElem(LinkList*L,ElemType e);
bool ListInsert(LinkList *&L,int i,ElemType e);
bool ListDelete(LinkList *&L,int i,ElemType &e);
#endif


================================================
FILE: c-cpp/06_linkedlist/palindromeList/LinkedList.hpp
================================================
/**
 * Author:  TripleZ<me@triplez.cn>
 * Date:    2018-10-10
 * Brief:   Linked list class.
 */

#ifndef _LINKEDLIST_HPP_
#define _LINKEDLIST_HPP_

#include <cstdio>
#include "ListNode.hpp"

class LinkedList {
public:
    int size;
    int length;
    ListNode *head;
    LinkedList();
    LinkedList(int size);
    ~LinkedList();
    ListNode* FindElem(int elemVal);
    bool DeleteElem(ListNode *elem);
    bool DeleteLastElem();
    bool InsertElemAtFront(int elemVal);
    bool InsertElemAtBack(int elemVal);
    void PrintList();
};

LinkedList::LinkedList() {
    this -> head = new ListNode();
    this -> head->next = nullptr;
    this -> head->val = -1;
    this -> size = 10; // default
    this -> length = 0;
}

LinkedList::LinkedList(int size) {
    this -> head = new ListNode();
    this -> head->next = nullptr;
    this -> head->val = -1;
    
    this -> size = size;
    this -> length = 0;
}

LinkedList::~LinkedList() {
    ListNode *p, *q;
    p = this -> head;
    while(p -> next != nullptr) {
        q = p -> next;
        p -> next = p -> next -> next;
        delete q;
    }
    delete head;
    this -> head = nullptr;
    this -> length = 0;
}

ListNode* LinkedList::FindElem(int elemVal) {
    ListNode *p;
    for (p = this -> head -> next; p != nullptr; p = p -> next) {
        if (p -> val == elemVal) {
            return p;
        }
    }
    return nullptr;
}

bool LinkedList::DeleteElem(ListNode *elem) {
    ListNode *prev, *next;
    for (prev = this -> head; prev -> next != elem; prev = prev -> next);
    next = elem -> next;
    prev -> next = next;
    delete elem;
    this -> length --;
    return true;
}

bool LinkedList::DeleteLastElem() {
    ListNode *prev, *elem;
    for (prev = this -> head; prev -> next -> next != nullptr; prev = prev -> next) ;
    elem = prev -> next;
    prev -> next = nullptr;
    delete elem;
    this -> length --;
    return true;
}

bool LinkedList::InsertElemAtFront(int elemVal) {
    ListNode *newNode = new ListNode();
    newNode -> val = elemVal;
    newNode -> next = this -> head -> next;
    this -> head -> next = newNode;
    this -> length ++;
    return true;
}

bool LinkedList::InsertElemAtBack(int elemVal) {
    ListNode *newNode = new ListNode();
    newNode -> val = elemVal;
    ListNode *end;
    for (end = this -> head; end -> next != nullptr; end = end -> next);
    end -> next = newNode;
    newNode -> next = nullptr;
    this -> length ++;
    return true;
}

void LinkedList::PrintList() {
    ListNode *elem;
    printf("List: ");
    for (elem = this -> head -> next; elem -> next != nullptr; elem = elem -> next) {
        printf("%d - ", elem -> val);
    }
    printf("%d\n", elem -> val);
}

#endif


================================================
FILE: c-cpp/06_linkedlist/palindromeList/ListNode.hpp
================================================
/**
 * Author:  TripleZ<me@triplez.cn>
 * Date:    2018-10-10
 * Brief:   ListNode class.
 */

#ifndef _LISTNODE_HPP_
#define _LISTNODE_HPP_

class ListNode {
public:
    int val;
    ListNode *next;
};

#endif


================================================
FILE: c-cpp/06_linkedlist/palindromeList/palindromeList.cpp
================================================
/**
 * Author:  TripleZ<me@triplez.cn>
 * Date:    2018-10-10
 * Brief:   Check a list whether is palindrome.
 */

#include <cstdio>
#include "LinkedList.hpp"

bool CheckPalindromeList(LinkedList *list) {
    // 使用快慢指针找链表中点
    ListNode *slow, *fast, *mid2;
    slow = list -> head;
    fast = list -> head;
    while (fast -> next != nullptr) {
        slow = slow -> next;
        fast = fast -> next;
        if (fast -> next != nullptr) {
            fast = fast -> next;
            mid2 = slow -> next;
        } else {
            mid2 = nullptr;
        }
    }

    // 从中点向后逆转链表(区分奇偶情况)
    ListNode *mid = slow;
    ListNode *elem, *prev, *save;
    if (mid2 == nullptr) {  // odd
        elem = mid;
        prev = mid -> next;
    } else {  // even
        elem = mid2;
        prev = mid2 -> next;
        mid2 -> next = nullptr;
    }
    save = prev -> next;
    mid -> next = nullptr;
    while (save != nullptr) {
        prev -> next = elem;
        elem = prev;
        prev = save;
        save = save -> next;
    }
    prev -> next = elem;

    ListNode *end = prev;
    ListNode *front = list -> head -> next;

    // 从头尾同时遍历比较,检测链表是否为回文
    bool palindrome = true;
    while (front != end) {
        // printf("%d, %d\n", front -> val, end -> val);
        if (front -> val != end -> val) {
            palindrome = false;
            break;
        }
        front = front -> next;
        end = end -> next;
    }

    palindrome ? printf("The list is palindrome~\n") : printf("The list is not palindrome!\n");

    return palindrome;
}

int main(int argc, char const *argv[]) {
    
    int init[] = {1, 2, 3, 2, 1};
    LinkedList *list = new LinkedList(5);
    for (int i = 0; i < 5; i++) {
        list -> InsertElemAtBack(init[i]);
    }
    list -> PrintList();

    CheckPalindromeList(list);  // true
    
    list -> InsertElemAtFront(5);
    CheckPalindromeList(list);  // false


    int init2[] = {1, 2, 3, 3, 2, 1};
    LinkedList *list2 = new LinkedList(10);
    for (int i = 0; i < 6; i++) list2 -> InsertElemAtBack(init2[i]);
    list2 -> PrintList();
    CheckPalindromeList(list2);

    list2 -> InsertElemAtBack(4);
    CheckPalindromeList(list2);

    return 0;
}


================================================
FILE: c-cpp/06_linkedlist/single_list.c
================================================
#include <stdio.h>
#include <stdbool.h>

struct single_list {
	struct single_list *next;
	int val;
};

struct single_list_head {
	struct single_list *head;
};

bool is_empty(struct single_list_head *head)
{
	return head->head == NULL;
}

void dump(struct single_list_head *head)
{
	struct single_list *tmp = head->head;
	int idx = 0;

	while (tmp) {
		printf("[%02d]: %08d\n", idx++, tmp->val);
		tmp = tmp->next;
	}
}

void insert(struct single_list **prev, struct single_list *elem)
{
	if (!prev)
		return;

	elem->next = *prev;
	*prev = elem;
}

void insert_head(struct single_list_head *head, struct single_list *elem)
{
	insert(&head->head, elem);
}

struct single_list* del(struct single_list **prev)
{
	struct single_list *tmp;

	if (!prev)
		return NULL;
	if (*prev == NULL)
		return NULL;
	tmp = *prev;
	*prev = (*prev)->next;
	tmp->next = NULL;

	return tmp;
};

struct single_list* delete_head(struct single_list_head* head)
{
	return del(&head->head);
};

struct single_list** search(struct single_list_head* head, int target)
{
	struct single_list **prev, *tmp;

	for (prev = &head->head, tmp = *prev;
	     tmp && (tmp->val < target);
	     prev = &tmp->next, tmp = *prev)
		;

	return prev;
};

void reverse(struct single_list_head* head)
{
	struct single_list_head tmp = {NULL};
	struct single_list *elem;

	while (!is_empty(head)) {
		elem = delete_head(head);
		insert_head(&tmp, elem);
	}

	head->head = tmp.head;
}

bool is_cyclic(struct single_list_head* head)
{
	struct single_list *s1, *s2;

	s1 = s2 = head->head;

	while(s1 && s2) {
		s1 = s1->next;
		s2 = s2->next ? s2->next->next:s2->next;

		if (s1 == s2)
			return true;
	}
	return false;
}

struct single_list* middle(struct single_list_head* head)
{
	struct single_list *s1, *s2;
	struct single_list pseudo_head;

	pseudo_head.next = head->head;
	s1 = s2 = &pseudo_head;

	while (true) {
		if (!s2 || !s2->next)
			return s1;
		s1 = s1->next;
		s2 = s2->next->next;
	}

	return NULL;
};

int main()
{
	struct single_list_head head = {NULL};
	struct single_list lists[10];
	struct single_list **prev;
	int idx;

	for (idx = 0; idx < 10; idx++) {
		lists[idx].val = idx;
		lists[idx].next = NULL;
	}

	insert_head(&head, &lists[6]);
	insert_head(&head, &lists[5]);
	insert_head(&head, &lists[4]);
	insert_head(&head, &lists[1]);
	insert_head(&head, &lists[0]);

	printf("=== insert 0, 1, 4, 5, 6\n");
	dump(&head);

	prev = search(&head, 2);
	insert(prev, &lists[2]);
	printf("=== insert 2\n");
	dump(&head);

	printf("middle elem is %d\n", middle(&head)->val);

	prev = search(&head, 2);
	if ((*prev) && ((*prev)->val == 2))
		printf("The list contains 2\n");
	else
		printf("The list not contains 2\n");

	del(prev);
	prev = search(&head, 2);
	printf("After remove 2\n");
	if ((*prev) && ((*prev)->val == 2))
		printf("The list contains 2\n");
	else
		printf("The list not contains 2\n");
	dump(&head);

	printf("After reverse \n");
	reverse(&head);
	dump(&head);

	printf("middle elem is %d\n", middle(&head)->val);

	lists[0].next = &lists[6];
	printf("list is%s cyclic\n", is_cyclic(&head)?"":" not");

	return 0;
}


================================================
FILE: c-cpp/06_linkedlist/singlelist_gc/singleList.c
================================================
#include "singleList.h"

#include <string.h>

linkedList * listCreate()
{
    linkedList *list = NULL;
    list = malloc(sizeof(*list));
    if (NULL == list)
    {
        return NULL;
    }

    list->dup = NULL;
    list->free = NULL;
    list->match = NULL;

    list->head = NULL;
    list->len = 0;

    return list;
}

// ͷ
void listRelease(linkedList *list)
{
    if (NULL == list)
    {
        return;
    }

    listEmpty(list);

    free(list);
    list = NULL;
}

void listEmpty(linkedList *list)
{
    if (NULL == list)
    {
        return;
    }

    while (NULL != list->head)
    {
        listNode *pNode = list->head;
        list->head = pNode->next;
        if (NULL != list->free)
        {
            list->free(pNode->value);
        }
        else
        {
            free(pNode->value);
        }

        pNode->next = NULL;
        free(pNode);
        pNode = NULL;
    }
}

linkedList * listAddNodeHead(linkedList *list, void * value)
{
    if (NULL == list || NULL == value)
    {
        return list;
    }

    listNode *node = NULL;
    node = malloc(sizeof(*node));
    if (NULL == node)
    {
        return list;
    }

    node->value = value;
    node->next = list->head;
    list->head = node;

    ++list->len;
    return list;
}

linkedList * listAddNodeTail(linkedList *list, void *value)
{
    if (NULL == list || NULL == value)
    {
        return list;
    }

    listNode *node = NULL;
    node = malloc(sizeof(*node));
    if (NULL == node)
    {
        return list;
    }

    node->value = value;
    node->next = NULL;

    if (NULL == list->head
        && list->len == 0)
    {
        list->head = node;
    }
    else
    {
        listNode *tail = list->head;
        listNode *pre = list->head;
        while (NULL != tail)
        {
            pre = tail;
            tail = tail->next;
        }

        pre->next = node;
    }

    ++list->len;
    return list;
}

linkedList * listInsertNode(linkedList *list, listNode *old_node, void *value, bool after)
{
    if (NULL == list || NULL == old_node)
    {
        return list;
    }

    listNode *pNode = NULL;
    pNode = malloc(sizeof(*pNode));
    if (NULL == pNode)
    {
        return list;
    }

    pNode->value = value;
    if (after)
    {
        pNode->next = old_node->next;
        old_node->next = pNode;
    }
    else
    {
        listNode *pre = list->head;
        while (pre->next != old_node)
        {
            pre = pre->next;
        }

        if (NULL != pre)
        {
            pre->next = pNode;
            pNode->next = old_node;
        }
    }

    ++list->len;
    return list;
}

// ûͷźʱͷŴ
void listDelNode(linkedList *list, listNode *node)
{
    if (NULL == list || NULL == node)
    {
        return;
    }

    listNode *pre = list->head;
    listNode *cur = list->head;
    while (NULL != cur && cur != node)
    {
        pre = cur;
        cur = cur->next;
    }

    // ڸ
    if (NULL == pre)
    {
        return;
    }

    pre->next = node->next;
    node->next = NULL;
    --list->len;

    if (NULL != list->free)
    {
        list->free(node->value);
        free(node);
        node = NULL;
    }
}

listNode * listSearchKey(linkedList *list, void *key)
{
    if (NULL == list)
    {
        return NULL;
    }

    listNode *node = list->head;
    while (NULL != node)
    {
        if (NULL != list->match)
        {
            if (list->match(key, node->value) == 0)
            {
                return node;
            }
        }
        else
        {
            if (key == node->value)
            {
                return node;
            }
        }

        node = node->next;
    }

    return NULL;
}

listNode * listIndex(linkedList *list, long index)
{
    if (NULL == list)
    {
        return NULL;
    }

    if (index <= 0
        || index > list->len)
    {
        return NULL;
    }

    listNode *pNode = list->head;
    for (long i = 0; i < index; ++i)
    {
        pNode = pNode->next;
    }

    return pNode;
}

linkedList* listRewind(linkedList *list)
{
    if (NULL == list)
    {
        return NULL;
    }

    listNode *head = list->head;
    listNode *pre = NULL;
    listNode *next = NULL;
    while (NULL != head)
    {
        next = head->next;
        head->next = pre;
        pre = head;
        head = next;
    }

    list->head = pre;
    return list;
}

size_t listLength(linkedList *list)
{
    if (NULL == list)
    {
        return 0;
    }

    return list->len;
}

================================================
FILE: c-cpp/06_linkedlist/singlelist_gc/singleList.h
================================================
#ifndef __SINGLELIST_H__
#define __SINGLELIST_H__

#include <stdlib.h>
#include <stdbool.h>

typedef struct listNode
{
    struct listNode *next;
    void *value;
}listNode;

typedef struct linkedList
{
    listNode *head;
    size_t len;
    size_t typesize;

    void(*dup)(void*, void*);
    int(*match)(void*, void*);
    void(*free)(void*);
}linkedList;

#define listSetDupMethod(l,m) ((l)->dup = (m))
#define listSetFreeMethod(l,m) ((l)->free = (m))
#define listSetMatchMethod(l,m) ((l)->match = (m))

#define listGetDupMethod(l) ((l)->dup)
#define listGetFree(l) ((l)->free)
#define listGetMatchMethod(l) ((l)->match)

linkedList *listCreate();
void listRelease(linkedList *list);
void listEmpty(linkedList *list);
linkedList *listAddNodeHead(linkedList *list, void *value);
linkedList *listAddNodeTail(linkedList *list, void *value);
linkedList *listInsertNode(linkedList *list, listNode *old_node, void *value, bool after);
void listDelNode(linkedList *list, listNode *node);

listNode *listSearchKey(linkedList *list, void *key);
listNode *listIndex(linkedList *list, long index);
linkedList* listRewind(linkedList *list);

size_t listLength(linkedList *list);

#endif // !__SINGLELIST_H__


================================================
FILE: c-cpp/07_linkedlist/.gitkeep
================================================


================================================
FILE: c-cpp/07_linkedlist/LinkedListAlgo.c
================================================
#include <stdio.h>
#include <stdlib.h>

/**
 * 1) 单链表反转
 * 2) 链表中环的检测
 * 3) 两个有序的链表合并
 * 4) 删除链表倒数第 n 个结点
 * 5) 求链表的中间结点
 *
 * Author: Smallfly
 */

typedef struct SinglyLinkedNode {
    int data;
    struct SinglyLinkedNode* next;
} SinglyLinkedNode;

void insertNode(SinglyLinkedNode** head_ref, int data);
void printLinkedList(SinglyLinkedNode* head);

/** 反转单链表 */

void reverse(SinglyLinkedNode** head_ref) {
    if (*head_ref == NULL) return;
    
    SinglyLinkedNode *prev = NULL;
    SinglyLinkedNode *current = *head_ref;
    while (current) {
        SinglyLinkedNode *next = current->next;
        if (!next) {
            // 到达尾结点时,将地址存入 head_ref
            *head_ref = current;
        }
        current->next = prev;
        prev = current;
        current = next;
    }
}

void test_reverse() {
    SinglyLinkedNode* head = NULL;
    insertNode(&head, 3);
    insertNode(&head, 2);
    insertNode(&head, 1);
    
    reverse(&head);
    printLinkedList(head);
}

/** 检测单链表是否有环 */

// 这里使用一级指针也可以
int checkCircle(SinglyLinkedNode** head_ref) {
    if (*head_ref == NULL) return 0;
    SinglyLinkedNode *slow = *head_ref, *fast = *head_ref;
    while (fast != NULL && fast->next != NULL) {
        fast = fast->next->next;
        slow = slow->next;
        if (slow == fast) return 1;
    }
    return 0;
}

void test_checkCircle() {
    SinglyLinkedNode* head = NULL;
    insertNode(&head, 3);
    insertNode(&head, 2);
    insertNode(&head, 1);
    
    int result1 = checkCircle(&head);
    printf("has circle: %d\n", result1);
    
    // make circle linklist
    SinglyLinkedNode* current = malloc(sizeof(SinglyLinkedNode));
    current->data = 0;
    SinglyLinkedNode* h = current;
    for (int i = 1; i < 4; ++i) {
        SinglyLinkedNode* node = malloc(sizeof(SinglyLinkedNode));
        node->data = i;
        current->next = node;
        //reset current node
        current = node;
    }
    current->next = h;
    
    int result2 = checkCircle(&h);
    printf("has circle: %d\n", result2);
}

/** 有序链表合并 */

void moveNode(SinglyLinkedNode** dest_ref, SinglyLinkedNode** src_ref);

SinglyLinkedNode* mergeSortedLinkedList(SinglyLinkedNode* la, SinglyLinkedNode* lb) {
    // 辅助结点,next 指针持有合并后的有序链表
    SinglyLinkedNode dummy;
    
    // 有序链表的尾结点
    SinglyLinkedNode* tail = &dummy;
    
    while (1) {
        // 如果有一个链表为空,直接与另一个链表接起来
        if (!la) {
            tail->next = lb;
            break;
        } else if (!lb) {
            tail->next = la;
            break;
        }
        
        // 将头结点较小的优先添加到 tail
        if (la->data <= lb->data) {
            moveNode(&(tail->next), &la);
        } else {
            moveNode(&(tail->next), &lb);
        }
        tail = tail->next;
    }
    
    return dummy.next;
}

// 将 src_ref 的头结点,添加到 dest_ref 的头部。
void moveNode(SinglyLinkedNode** dest_ref, SinglyLinkedNode** src_ref) {
    if (*src_ref == NULL) return;
    SinglyLinkedNode* new_node = *src_ref;
    
    *src_ref = new_node->next;
    
    new_node->next = *dest_ref;
    *dest_ref = new_node;
}

void test_mergeSortedLinkedList() {
    SinglyLinkedNode* a = NULL;
    insertNode(&a, 10);
    insertNode(&a, 5);
    insertNode(&a, 0);
    
    SinglyLinkedNode* b = NULL;
    insertNode(&b, 8);
    insertNode(&b, 6);
    insertNode(&b, 3);
    
    SinglyLinkedNode* result = mergeSortedLinkedList(a, b);
    printLinkedList(result);
    
    SinglyLinkedNode* result2 = mergeSortedLinkedList(a, NULL);
    printLinkedList(result2);
}

/** 删除倒数第 K 个结点 */

void deleteLastKth(SinglyLinkedNode** head_ref, int k) {
    if (*head_ref == NULL || k == 0) return;
    
    // 快指针向前移动 k-1
    SinglyLinkedNode* fast = *head_ref;
    int i = 1;
    while (i < k && fast != NULL) {
        fast = fast->next;
        ++i;
    }
    
    // 如果快指针为空,说明结点个数小于 k
    if (fast == NULL) return;
    
    SinglyLinkedNode* slow = *head_ref;
    SinglyLinkedNode* prev = NULL;
    while (fast->next != NULL) {
        fast = fast->next;
        prev = slow;
        slow = slow->next;
    }
    
    // 如果 prev 为空,头结点刚好是第 k 个结点
    if (!prev) {
        (*head_ref) = (*head_ref)->next;
    } else {
        prev->next = slow->next;
    }
    free(slow);
}

void test_deleteLastKth() {
    SinglyLinkedNode* head = NULL;
    insertNode(&head, 1);
    insertNode(&head, 2);
    insertNode(&head, 3);
    insertNode(&head, 4);
    insertNode(&head, 5);
    
    // 1. 删除头结点
    deleteLastKth(&head, 5);
    printLinkedList(head);
    
    // 2. 删除中间结点
    deleteLastKth(&head, 2);
    printLinkedList(head);
    
}

/** 求中间结点  */

SinglyLinkedNode* findMiddleNode(SinglyLinkedNode* head) {
    if (!head) return NULL;
    SinglyLinkedNode* slow = head;
    SinglyLinkedNode* fast = head;
    
    // 1. 慢指针走一步,快指针两步
    while (fast->next != NULL && fast->next->next != NULL) {
        slow = slow->next;
        fast = fast->next->next;
    }
    
    return slow;
}

void test_findMiddleNode() {
    SinglyLinkedNode* head = NULL;
    insertNode(&head, 1);
    insertNode(&head, 2);
    insertNode(&head, 3);
    insertNode(&head, 4);
    insertNode(&head, 5);
    
    SinglyLinkedNode* middleNode = findMiddleNode(head);
    printf("%d\n", middleNode->data);
    printLinkedList(head);
}

/** 工具方法 */

// 插入新结点到链表头部
void insertNode(SinglyLinkedNode** head_ref, int data) {
    SinglyLinkedNode* new_node = malloc(sizeof(SinglyLinkedNode));
    new_node->data = data;
    new_node->next = *head_ref;
    *head_ref = new_node;
}

// 打印链表
void printLinkedList(SinglyLinkedNode* node) {
    printf("--- start ---\n");
    while (node) {
        printf("data: %d\n", node->data);
        node = node->next;
    }
    printf("--- end ---\n");
}

// 跑测试
void test() {
    
    test_reverse();
    
//    test_checkCircle();
    
//    test_mergeSortedLinkedList();
    
//    test_deleteLastKth();
    
//    test_findMiddleNode();
}


================================================
FILE: c-cpp/07_linkedlist/SingleList.cpp
================================================
#include <iostream>
#include <string>
#include <functional>
using namespace std;


class CElement;
/***
 * @brief 
*/
class CSingleList
{
public:
    CSingleList();
    ~CSingleList();

    /**
     * @brief ..ĩβ
     * @return ɹطǿָ,ʧ
    */
    CElement* Insert(void* lpData, int iDataSize);
    /**
     * @brief ..ָλò
     * @return ɹطǿָ,ʧ
    */
    CElement* Insert(CElement* lpElement, void* lpData, int iDataSize);
    /**
     * @brief ɾ
    */
    void Delete(CElement*);

    /**
     * @brief 
    */
    CElement* Begin();
    /**
     * @brief һԪ
    */
    CElement* Next();
    /***
     * @brief β
    */
    CElement* End();

    /**
     * @brief Ƿǿ
     * @return շTRUE򷵻FALSE
    */
    bool Empty();

    /**
     * @brief ת
    */
    void Reverse();

    /**
     * @brief ⻷
     * @return TRUEʱʾڻ,򲻴ڻ.
    */
    bool CheckCircle();

    /**
     * @brief ϲ2
    */
    void Merge(CSingleList& lst, std::function<int(void* t1, void* t2)>);

    /**
     * @brief ɾK
    */
    void DeleteLastKth(int k);
    /**
     * @brief мڵ
    */
    CElement* Center();
private:
    void Insert(CElement* lpNewElement, CElement* lpCurElement, bool bBack = true);
    void Insert(CElement* lpNewElement);
    CElement* Tail();

	CSingleList(CSingleList const & rhs);
	CSingleList& operator= (CSingleList const& rhs);
private:
    /**ͷ*/
    CElement* m_lpHead;
    /**ڱ*/
    CElement* m_lpSentinel;
    /**ս㣬End() */
    CElement* m_lpNull;
    /**ǰ. öʱʹ. */
    CElement* m_lpCur;
};

/***
 * @brief Ԫ.
*/
class CElement
{
    friend class CSingleList;
protected:
    CElement();
    ~CElement();
public:
    /***
     * @brief ȡָ
    */
    void* GetDataPtr();
protected:
    /**һ*/
    CElement* m_lpNext;
    void* m_lpData;
};


void CreateList(CSingleList& lst)
{
    //ѭԪصβ
    for(int i=1; i<10;i++)
    {
        int* p = new int();
        *p = i;
        lst.Insert(p, 4);
    }
}
void PrintList(CSingleList& lst)
{
    CElement* lpElement = lst.Begin();
    while(lpElement != lst.End())
    {
        std::cout<<*((int*)lpElement->GetDataPtr())<<std::endl;
        lpElement = lst.Next();
    }
}

int main()
{
    {
        /// Ļ/ö/ɾ
        CSingleList lst;
        CElement* lpElement = NULL;
        CreateList(lst);

        std::cout<<"öǰԪ"<<std::endl;
        PrintList(lst);

        std::cout<<"ָԪ,ָԪغԪ"<<std::endl;
        lpElement = lst.Begin();
        while(lpElement != lst.End())
        {
            if(*((int*)lpElement->GetDataPtr()) == 5)
            {
                int* p = new int();
                *p = 55;
                lst.Insert(lpElement,p, 4);
                break;
            }else{
                lpElement = lst.Next();
            }
        }

        std::cout<<"öǰԪ"<<std::endl;
        PrintList(lst);

        std::cout<<"ָԪ(7Ԫ),ɾָԪ"<<std::endl;
        lpElement = lst.Begin();
        while(lpElement != lst.End())
        {
            if(*((int*)lpElement->GetDataPtr()) == 7)
            {
                lst.Delete(lpElement);
                break;
            }else{
                lpElement = lst.Next();
            }
        }
        std::cout<<"öǰԪ"<<std::endl;
        PrintList(lst);
    }

    std::cout<<"--------------------------"<<std::endl;
    {
        /// ķת
        CSingleList lst;
        CElement* lpElement = NULL;
        CreateList(lst);
        std::cout<<"ת"<<std::endl;
        lst.Reverse();
        PrintList(lst);
    }

    std::cout<<"--------------------------"<<std::endl;
    {
        /// ⻷
        CSingleList lst;
        CElement* lpElement = NULL;
        CreateList(lst);
        std::cout<<"⻷"<<std::endl;
        bool bRet = lst.CheckCircle();
        if(bRet){
            std::cout<<"ڻ."<<std::endl;
        }else{
            std::cout<<"ڻ."<<std::endl;
        }
    }

    std::cout<<"--------------------------"<<std::endl;
    {
        /// ϲ
        CSingleList lst,lst2;
        CElement* lpElement = NULL;
        for(int i=1; i<30;i++)
        {
            int* p = new int();
            *p = i;
            if(i%4){
                lst2.Insert(p, 4);
            }else{
                lst.Insert(p, 4);
            }
        }
        std::cout<<"öǰԪ"<<std::endl;
        PrintList(lst);
        std::cout<<"......"<<std::endl;
        PrintList(lst2);
        lst.Merge(lst2,[](void* lpT1, void* lpT2) -> int{
            if(*((int*)lpT1) < *((int*)lpT2)){
                return -1;
            }else if(*((int*)lpT1) == *((int*)lpT2)){
                return 0;
            }else if(*((int*)lpT1) > *((int*)lpT2)){
                return 1;
            }
            return 0;
        });
        std::cout<<"ϲ֮󣬴ӡǰ."<<std::endl;
        PrintList(lst);
    }
    std::cout<<"--------------------------"<<std::endl;
    {
        /// ɾK,鿴мڵ
        CSingleList lst;
        CreateList(lst);
        std::cout<<"ɾ0"<<std::endl;
        lst.DeleteLastKth(0);
        PrintList(lst);
        CElement* lpCenter = lst.Center();
        std::cout<<"мڵ:"<<*((int*)lpCenter->GetDataPtr())<<std::endl;

        std::cout<<"ɾ1"<<std::endl;
        lst.DeleteLastKth(1);
        PrintList(lst);
        lpCenter = lst.Center();
        std::cout<<"мڵ:"<<*((int*)lpCenter->GetDataPtr())<<std::endl;

        std::cout<<"ɾ3"<<std::endl;
        lst.DeleteLastKth(3);
        PrintList(lst);
        lpCenter = lst.Center();
        std::cout<<"мڵ:"<<*((int*)lpCenter->GetDataPtr())<<std::endl;
    }
    std::cin.ignore();

    return 0;
}

CSingleList::CSingleList()
{
    m_lpHead = new CElement();
    m_lpSentinel = new CElement();
    m_lpNull = new CElement();
    m_lpCur = NULL;
    m_lpHead->m_lpNext = m_lpSentinel;
}
CSingleList::~CSingleList()
{
    if(NULL != m_lpSentinel)
    {
        delete m_lpSentinel;
        m_lpSentinel = NULL;
    }
    if(NULL != m_lpNull)
    {
        delete m_lpNull;
        m_lpNull = NULL;
    }
    if(NULL != m_lpHead)
    {
        delete m_lpHead;
        m_lpHead = NULL;
    }
}
CElement* CSingleList::Insert(void* lpData, int iDataSize)
{
    CElement* lpNewElement = new CElement();
    if(NULL == lpNewElement)
    {
        return NULL;
    }
    lpNewElement->m_lpData = lpData;
    Insert(lpNewElement, Tail());
    return lpNewElement;
}
CElement* CSingleList::Insert(CElement* lpElement, void* lpData, int iDataSize)
{
    if((NULL == lpElement) || (End() == lpElement))
    {
        return NULL;
    }
    CElement* lpNewElement = new CElement();
    if(NULL == lpNewElement)
    {
        return NULL;
    }
    lpNewElement->m_lpData = lpData;
    Insert(lpNewElement, lpElement);
    return lpNewElement;
}
void CSingleList::Insert(CElement* lpNewElement, CElement* lpCurElement, bool bBack /*= true*/)
{
    if(bBack){//뵽ָԪصĺ
        lpNewElement->m_lpNext = lpCurElement->m_lpNext;
        lpCurElement->m_lpNext = lpNewElement;
    }else{//뵽ָԪصǰ
        CElement* lpIter = m_lpSentinel;
        while(NULL != lpIter)
        {
            if(lpIter->m_lpNext == lpCurElement)
            {
                lpNewElement->m_lpNext = lpIter->m_lpNext;
                lpIter->m_lpNext = lpNewElement;
                break;
            }else{
                lpIter = lpIter->m_lpNext;
            }
        }
    }
}

void CSingleList::Delete(CElement* lpElement)
{
    if((NULL == lpElement) || (End() == lpElement))
    {
        return;
    }
    CElement* lpCurElement = m_lpHead->m_lpNext;
    while(NULL != lpCurElement->m_lpNext)
    {
        if(lpCurElement->m_lpNext == lpElement)
        {
            lpCurElement->m_lpNext = lpCurElement->m_lpNext->m_lpNext;
            break;
        }else{
            lpCurElement = lpCurElement->m_lpNext;
        }
    }
}

CElement* CSingleList::Tail()
{
    CElement* lpCurElement = m_lpHead->m_lpNext;
    while(NULL != lpCurElement->m_lpNext)
    {
        lpCurElement = lpCurElement->m_lpNext;
    }
    return lpCurElement;
}

CElement* CSingleList::Begin()
{
    m_lpCur = NULL;
    if(NULL == m_lpHead->m_lpNext->m_lpNext)
    {
        m_lpCur = End();
    }else{
        m_lpCur = m_lpHead->m_lpNext->m_lpNext;
    }
    return m_lpCur;
}

CElement* CSingleList::Next()
{
    if((NULL == m_lpCur) || (End() == m_lpCur))
    {
        return m_lpCur;
    }
    m_lpCur = m_lpCur->m_lpNext;
    if(NULL == m_lpCur)
    {
        m_lpCur = End();
    }
    return m_lpCur;
}

CElement* CSingleList::End()
{
    return m_lpNull;
}

bool CSingleList::Empty()
{
    return Begin() == End();
}

void CSingleList::Reverse()
{
    if(Empty())
    {
        return;
    }
    CElement* lpPre = NULL;
    CElement* lpTmp = NULL;
    CElement* lpCurElement = m_lpSentinel->m_lpNext;
    while(1)
    {
        lpTmp = lpCurElement->m_lpNext;
        lpCurElement->m_lpNext = lpPre;
        if(NULL == lpTmp)
        {
            break;
        }
        lpPre = lpCurElement;
        lpCurElement = lpTmp;
    }
    m_lpSentinel->m_lpNext = lpCurElement;
}

bool CSingleList::CheckCircle()
{
    if(Empty())
    {
        return false;
    }
    CElement* lpFast = m_lpSentinel->m_lpNext;
    CElement* lpSlow = m_lpSentinel->m_lpNext;
    while ((NULL != lpFast) && (NULL != lpFast->m_lpNext)) 
    {
        lpFast = lpFast->m_lpNext->m_lpNext;
        lpSlow = lpSlow->m_lpNext;
        if (lpFast == lpSlow)
        {
            return true;
        }
    }
    return false;
}

/**
 * ϲ2
*/
void CSingleList::Merge(CSingleList& lst, std::function<int(void* t1, void* t2)> fnCompare)
{
    CElement* lpL1 = Begin();
    CElement* lpL2 = lst.Begin();

    if(!fnCompare)
    {
        return;
    }
    int iRet = 0;
    while((lpL2 != lst.End()))
    {
        if(lpL1 != End())
        {
            /**
             * Ҫȷλ
             * 
             * 1,2; 1 <- 2, 2ϲ1
             * 
             * 1ԪС2еԪأѭ1д2еĵǰԪصԪ
             * 1ҵĵԪλ[A]ʱ2еĵǰԪز뵽Ԫλ[A]ǰ;
             * 1вλ1ĩλԪ
            */
            iRet = fnCompare(lpL1->GetDataPtr(), lpL2->GetDataPtr());
            if(iRet < 0){
                lpL1 = Next();
                while(lpL1 != End()){
                    iRet = fnCompare(lpL1->GetDataPtr(), lpL2->GetDataPtr());
                    if(iRet > 0){
                        break;
                    }
                    lpL1 = Next();
                }
            }
        }else{
            iRet = -1;
        }
        CElement* lpNewElement = new CElement();
        if(NULL != lpNewElement)
        {
            lpNewElement->m_lpData = lpL2->GetDataPtr();
            if(lpL1 != End())
            {
                Insert(lpNewElement,lpL1, iRet < 0);
            }else{
                CElement* lpTail = Tail();
                Insert(lpNewElement,lpTail);
            }
        }
        lpL2 = lst.Next();
    }
}

void CSingleList::DeleteLastKth(int k)
{
    int i = 1;
    if(k <= 0)
    {
        return;
    }
    CElement* lpFast = Begin();
    while((lpFast != End()) && (i < k))
    {
        lpFast = Next();
        ++i;
    }
    if (lpFast == End())
    {
        return;
    }
    CElement* lpSlow = Begin();
    CElement* lpPrev = NULL;
    while (NULL != lpFast->m_lpNext)
    {
        lpFast = lpFast->m_lpNext;
        lpPrev = lpSlow;
        lpSlow = Next();
    }
    if(NULL != lpPrev)
    {
        lpPrev->m_lpNext = lpPrev->m_lpNext->m_lpNext;
    }
}

CElement* CSingleList::Center()
{
    CElement* lpFast = Begin();
    CElement* lpSlow = lpFast;
    while((NULL != lpFast->m_lpNext) && (NULL != lpFast->m_lpNext->m_lpNext))
    {
        lpFast = lpFast->m_lpNext->m_lpNext;
        lpSlow = lpSlow->m_lpNext;
    }
    return lpSlow;
}

CElement::CElement()
{
    m_lpNext = NULL;
    m_lpData = NULL;
}
CElement::~CElement()
{

}

void* CElement::GetDataPtr()
{
    return m_lpData;
}

================================================
FILE: c-cpp/07_linkedlist/linked_list.h
================================================
/**
 * 单链表
 *
 * Author: Liam Huang (Liam0205)
 */

#ifndef LINKEDLIST_LINKED_LIST_H_
#define LINKEDLIST_LINKED_LIST_H_

#include <memory>

template <typename T>
struct Node {
    using ptr_t = std::shared_ptr<Node<T>>;
    T     data;
    ptr_t next;

    Node(T data_) : data(data_), next(nullptr) {}
    Node() : next(nullptr) {}
};

#endif  // LINKEDLIST_LINKED_LIST_H_


================================================
FILE: c-cpp/07_linkedlist/linked_list_algo.hpp
================================================
/**
 * 0) 遍历单链表
 * 1) 单链表反转
 * 2) 链表中环的检测
 * 3) 两个有序的链表合并
 * 4) 删除链表倒数第n个结点
 * 5) 求链表的中间结点
 *
 * Author: Liam Huang (Liam0205)
 */

#ifndef LINKEDLIST_LINKED_LIST_ALGO_HPP_
#define LINKEDLIST_LINKED_LIST_ALGO_HPP_

#include <memory>

#include "linked_list.h"

template <typename T, typename UnaryFunc>
void traverse(typename Node<T>::ptr_t head, UnaryFunc do_traverse) {
    auto sentry  = std::make_shared<Node<T>>();
    sentry->next = head;
    decltype(sentry) work = sentry;
    while (work = work->next) {
        do_traverse(work);
    }
}

template <typename T>
typename Node<T>::ptr_t reverse(typename Node<T>::ptr_t head) {
    if (nullptr == head or nullptr == head->next) {
        return head;
    }
    decltype(head) prev = nullptr, curr = head, next = head->next;
    while (nullptr != next) {
        curr->next = prev;
        prev = curr;
        curr = next;
        next = curr->next;
    }
    curr->next = prev;
    return curr;
}

template <typename T>
bool check_circle(typename Node<T>::ptr_t head) {
    if (nullptr == head or nullptr == head->next) {
        return false;
    }
    decltype(head) slow = head, fast = head;
    while (nullptr != fast and nullptr != fast->next) {
        slow = slow->next;
        fast = fast->next->next;
        if (slow == fast) {
            return true;
        }
    }
    return false;
}

template <typename T>
typename Node<T>::ptr_t merge_two_sorted_lists(typename Node<T>::ptr_t lhs,
                                               typename Node<T>::ptr_t rhs) {
    if (nullptr == lhs) { return rhs; }
    if (nullptr == rhs) { return lhs; }

    decltype(lhs) l = lhs, r = rhs, head = nullptr, work = nullptr;

    if (l->data < r->data) {
        head = l;
        l = l->next;
    } else {
        head = r;
        r = r->next;
    }
    work = head;

    while (nullptr != l and nullptr != r) {
        if (l->data < r->data) {
            work->next = l;
            l = l->next;
        } else {
            work->next = r;
            r = r->next;
        }
        work = work->next;
    }

    if (nullptr != l) {
        work->next = l;
    } else {
        work->next = r;
    }

    return head;
}

template <typename T>
typename Node<T>::ptr_t deleth_last_Kth(typename Node<T>::ptr_t head,
                                                         size_t n) {
    decltype(head) sentry = std::make_shared<Node<T>>();
    sentry->next = head;
    decltype(head) prev = sentry, curr = sentry->next, fast = sentry->next;
    for (size_t i = 0; i != n; ++i) {
        if (nullptr != fast) {
            fast = fast->next;
        } else {
            return sentry->next;
        }
    }
    while (nullptr != fast) {
        prev = curr;
        curr = curr->next;
        fast = fast->next;
    }
    prev->next = curr->next;
    return sentry->next;
}

template <typename T>
typename Node<T>::ptr_t find_middle_node(typename Node<T>::ptr_t head) {
    if (nullptr == head or nullptr == head->next) {
        return head;
    }
    decltype(head) slow = head, fast = head;
    while (nullptr != fast and nullptr != fast->next) {
        slow = slow->next;
        fast = fast->next->next;
        if (slow == fast) {
            return nullptr;
        }
    }
    return slow;
}

#endif  // LINKEDLIST_LINKED_LIST_ALGO_HPP_


================================================
FILE: c-cpp/07_linkedlist/linklist_jinshaohui.c
================================================
/*************************************************************************
 > File Name: lisklist.c
 > Author:  jinshaohui
 > Mail:    jinshaohui789@163.com
 > Time:    18-10-07
 > Desc:    
 ************************************************************************/
#include<stdio.h>


struct stlistNode
{
	int val;
	struct listNode *next;
}listNode;

/*反转链表*/
listNode reverseList(listNode *head)
{
	listNode *prev = NULL;
	listNode *next = NULL;

	while(head != NULL)
	{
		next = head->next;
		head->next = prev;
		prev = head;
		head = next;
	}

	return prev;
}

/*判断链表是否有环*/
int hasCycle(listNode *head)
{
	listNode * fast = head;
	listNode * low = head;

	while(fast != NULL && fast->next != NULL)
	{
		low = low->next;
		fast = fast->next->next;
		if (low == fast)
		{
			return 1;
		}
	}

	return 0;
}
/*合并有序链表*/
listNode *mergeTwoLists(listNode *l1,listNode *l2)
{
	listNode head = {0};
	listNode *pRes = &head;

	while(1)
	{
		if(l1 == NULL)
		{
			pRes->next = l2;
		}

		if (l2 == NULL)
		{
			pRes->next = l1;
		}

		if(l1->val < l2->val)
		{
			pRes->next = l1;
			l1 = l1->next;
		}
		else
		{
			pRes->next = l2;
			l2 = l2->next;
		}
		pRes = pRes->next;
	}

	return head;
}
/*
 *删除链表倒数第n个节点,并返回链表头节点 */

listNode * removeNthFromEnd(listNode*headi,int n)
{
	listNode *fast = head;
	listNode *prev = NULL;
	listNpde *next = head;
	int k = n;
	
	/*快指针往后移动k-1*/
	while((k > 1) && (fast != NULL))
	{
		fast = fast->next;
		k--;
	}
	
	/*说明链表数目不足n个*/
	if (fast == NULL)
	{
		return head;
	}

	while (fast->next != NULL)
	{
		fast = fast->next;
		prev = next;
		next = next->next;
	}

	if(prev == NULL)
	{
		head = head->next;
	}
	else
	{
		prev->next = prev->next->next;
	}

	return head;
}
/*求链表的中间节点*/
listNode *middleNode(listNode *head)
{
	listNode * fast = head;
	listNode * low = head;

	while(fast != NULL && fast->next != NULL)
	{
		low = low->next;
		fast = fast->next->next;
	}

	return low;
}


================================================
FILE: c-cpp/08_stack/StackBasedOnArray/StackBasedOnArray.cpp
================================================
/**
 * 1)顺序栈的操作:入栈和出栈;
 * 2)采用模板的方法实现存储任意类型的数据
 * 3)采用数组的栈,支持动态扩容,每次扩容1.5 倍,初始栈的大小是 10 。
 * 
 * Author:caozx
 * time ;2018年10月11日
 */

#include <iostream>
#include "StackBasedOnArray.h"
using namespace std;

//构造函数,创建栈
//类模板成员函数的写法  template<class T> 返回值类型 类名<T>::成员函数名(参数列表){}
template<class T> ArrayStack<T>::ArrayStack()   
{   
    this -> count = 10;
    this -> flag = 0;
    this -> array = new T[this -> count];
    if (! this -> array){
        cout << "array malloc memory failure" << endl;
    }
}


//有参构造函数,创建栈
template<class T> ArrayStack<T>::ArrayStack(int count)   
{   
    this -> count = count;
    this -> flag = 0;
    this -> array = new T[this -> count];
    if (! this -> array){
        cout << "array malloc memory failure" << endl;
    }
}

//析构函数,销毁栈
template <class T> ArrayStack<T>::~ArrayStack(){
    this -> count = 0;
    this -> flag = 0;
    if(this -> array){
        delete [] this -> array;
        this -> array = NULL;
    }
    
} 

// 入栈
template<class T> void ArrayStack<T>::push(T data){
    if(this -> flag == this -> count){
        cout << "The stack is full , so need to enlarge 1.5x! "<< endl;
        this -> count = int (1.5 * this -> count);
        T * temp = new T [this -> count];
        for(int i = 0; i < this -> flag ; i++){
            temp[i] = this -> array[i];
            //cout << temp[i] <<endl;
        }
        delete [] this -> array;       //释放原来的空间
        temp[this -> flag] = data;
        this -> flag ++;
        this -> array = temp;
    }
    else{
        this -> array [this -> flag] = data;
        this -> flag ++ ;
    }
}

//出栈,并删除栈顶元素
template<class T> T ArrayStack<T>::pop(){
    this -> flag --;
    T temp = this -> array[this -> flag];
    return temp;
}

//出栈,不删除栈顶元素
template<class T> T ArrayStack<T>::peek(){
    T temp = this -> array[this -> flag - 1];
    return temp;
}

template<class T> int ArrayStack<T>::stackSize(){
    return this -> flag;
}

template<class T> int ArrayStack<T>::stackMaxSize(){
    return this -> count;
}

int main(int argc, char const *argv[])
{
    cout << " === test begin ===" << endl;
    ArrayStack <int> arrstack(12);
    arrstack.push(10);
    arrstack.push(20);
    arrstack.push(30);
    arrstack.push(40);
    arrstack.push(50);
    arrstack.push(60);
    arrstack.push(70);
    arrstack.push(80);
    arrstack.push(90);
    arrstack.push(100);
    arrstack.push(110);
    arrstack.push(120);
    arrstack.push(130);
    arrstack.push(140);
    arrstack.push(150);

    cout << "peek , not delete " << arrstack.peek() << endl;
    cout << "pop , delete " << arrstack.pop()<<endl;
    
    arrstack.push(210);
    arrstack.push(220);

    cout << "peek , not delete " << arrstack.peek() << endl;
    cout << "pop , delete " << arrstack.pop()<<endl;    
   
    system("pause");
    return 0;
}


================================================
FILE: c-cpp/08_stack/StackBasedOnArray/StackBasedOnArray.h
================================================

// 类模板的声明(line 3),类模板实例化后就是模板类
// 类模板声明的写法   template <class T> class 类名{}
template <class T> class ArrayStack
{
public:
    ArrayStack();
    ArrayStack(int count);
    ~ArrayStack();
    void push(T data);     //入栈
    T pop();      //出栈,并删除栈顶元素
    T peek();     //返回栈顶元素,不删除栈顶元素,栈顶指针不变
    int stackSize();
    int stackMaxSize();

private:
    int flag;       //栈顶标签,指向栈顶
    int count ;     //栈的容量
    T *array;       //指针
};


================================================
FILE: c-cpp/08_stack/StackBasedOnLinkedList/StackBasedOnLinkedList.cpp
================================================
/**
 * 1)链式栈的操作:入栈,出栈以及返回栈的大小;
 * 2)采用模板的方法实现存储任意类型的数据
 * 3)采用单链表实现栈
 * 4)pop和peek 出栈的返回值稍微有点问题,当栈为空的时候,返回null,cpp默认返回的是0。
 *    * 改进方法就是不用函数的返回值返回栈顶元素,而是采用参数列表的形式返回,这样稍微有点麻烦
 *    * 或者就是在使用的时候先调用size函数判断以下
 * Author:caozx
 * time ;2018年10月11日
 */

#include <iostream>
#include "StackBasedOnLinkedList.h"
using namespace std;

template<class T> LinkedListStack<T>::LinkedListStack()
{
    this -> count = 0;
    this -> head = new LinkedNode;
    this -> head -> next = NULL;
}

template<class T> LinkedListStack<T>::~LinkedListStack()
{
    LinkedNode * ptr, * temp;
    ptr = head;
    while(ptr -> next != NULL){
        temp = ptr -> next;
        ptr -> next = temp -> next;
        delete temp;   
    }
    delete head ; //删除头节点
    this -> head = NULL;
    this -> count = 0;
}

// 入栈
template<class T> void LinkedListStack<T>::push(const T & data)
{
    LinkedNode * insertPtr = new LinkedNode;
    insertPtr -> data = data;
    insertPtr -> next = this -> head -> next;
    head -> next = insertPtr;
    this -> count ++;
    cout << "push data : " << this -> head -> next -> data << endl;  
}

//返回栈顶元素,即出栈,不删除栈顶元素
template<class T> T LinkedListStack<T>::peek()
{
    if(this -> count == 0 || this -> head -> next == NULL){
        cout << " stack is empty, peek fail"<< endl;
        return NULL;
    }
    else{
        return this -> head -> next -> data;
    }
}

//出栈,删除栈顶元素
template<class T> T LinkedListStack<T>::pop()
{
    if(this -> count == 0 || this -> head -> next == NULL){
        cout << " stack is empty, pop fail"<< endl;
        return NULL;
    }
    else{
        LinkedNode * temp = this -> head -> next;
        this -> head -> next = temp -> next;
        T data = temp -> data;
        delete temp;
        this -> count --;
        return  data;
    }

}

//返回栈的大小
template<class T> int LinkedListStack<T>::size() const
{
    return this -> count;
}             

int main(int argc, char const *argv[])
{
    cout << " === StackBasedOnLinkedList test begin ===" << endl;
    LinkedListStack <float> stack;
    cout << "size==="<<stack.size()<<endl;
    stack.push(10.1);
    stack.push(20.2);
    stack.push(30.);
    stack.push(40.4);
    stack.push(50.5);
    stack.push(60.6);
    cout << "size==="<<stack.size()<<endl;
    cout << "stack peek  " << stack.peek() << endl;
    cout << "stack pop  " << stack.pop() << endl;
    cout << "size==="<<stack.size()<<endl;
    cout << "stack pop  " << stack.pop() << endl;
    cout << "stack pop  " << stack.pop() << endl;
    cout << "stack pop  " << stack.pop() << endl;
    cout << "stack pop  " << stack.pop() << endl;
    cout << "stack pop  " << stack.pop() << endl;
    cout << "size==="<<stack.size()<<endl;
    cout << "stack pop  " << stack.pop() << endl;
    cout << "stack peek  " << stack.peek() << endl;
    stack.push(110.1);
    stack.push(120.2);
    stack.push(130.3);
    stack.push(140.4);
    stack.push(150.5);
    stack.push(160.6);
    cout << "size==="<<stack.size()<<endl;
    cout << "stack peek  " << stack.peek() << endl;
    cout << "stack pop  " << stack.pop() << endl;
    cout << "stack pop  " << stack.pop() << endl;
    cout << "stack pop  " << stack.pop() << endl;
    cout << "stack peek  " << stack.peek() << endl;   //peek
    cout << "stack pop  " << stack.pop() << endl;
    cout << "stack pop  " << stack.pop() << endl;
    cout << "stack pop  " << stack.pop() << endl;
    cout << "size==="<<stack.size()<<endl;
    cout << "stack peek  " << stack.peek() << endl;   //peek
    cout << "stack pop  " << stack.pop() << endl;    
    system("pause");
    return 0;
}


================================================
FILE: c-cpp/08_stack/StackBasedOnLinkedList/StackBasedOnLinkedList.h
================================================
// 类模板的声明,关键字 class 也可以更换成 typename
template<class T> class LinkedListStack
{
public:
    LinkedListStack();
    ~LinkedListStack();

    void push(const T & data);     //入栈
    T peek();                    //返回栈顶元素,即出栈,不删除栈顶元素
    T pop();                      //出栈,删除栈顶元素
    int size() const;             //返回栈的大小
private:
    int count;                   //存放栈的大小,因为是单链表所以这里不规定栈的最大可承载量
    struct LinkedNode
    {
        T data;
        LinkedNode * next;
    };
    LinkedNode * head;    // 单链表的头指针,不带头节点
};


================================================
FILE: c-cpp/08_stack/arrayStack/arrayStack.c
================================================
/*************************************************************************
 > File Name: arrayStack.c
 > Author:  jinshaohui
 > Mail:    jinshaohui789@163.com
 > Time:    18-10-12
 > Desc:   数组实现顺序栈 
 ************************************************************************/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include"./arrayStack.h"

/*创建并初始化顺序栈*/
stArrayStack * arrayStack_create(int size)
{
	stArrayStack *parrStack = NULL;

	parrStack = (stArrayStack *)malloc(sizeof(stArrayStack));
	if (parrStack == NULL)
	{
		return NULL;
	}
	
	parrStack->size = size;
	parrStack->pos = -1;
	parrStack->array = (int *)malloc(sizeof(int)*size);
	if(parrStack->array == NULL)
	{
		free(parrStack);
		return NULL;
	}

	return parrStack;
}
/*销毁顺序栈*/
void arrayStack_destory(stArrayStack * parrStack)
{
	if(parrStack == NULL)
	{
		return;
	}

	if (parrStack->array != NULL)
	{
		free(parrStack->array);
	}

	free(parrStack);
	return;
}
/*出栈*/
int arrayStack_pop(stArrayStack *parrStack)
{
	int data = 0;

	if(arrayStack_is_empty(parrStack))
	{
		return -1;
	}
    data = parrStack->array[parrStack->pos];
	parrStack->pos--;

	return data;
}
/*入栈*/
int arrayStack_push(stArrayStack *parrStack,int data)
{
	if(arrayStack_is_full(parrStack))
	{
		return -1;
	}

    parrStack->pos++;
	parrStack->array[parrStack->pos] = data;

	return 0;
}

int arrayStack_push_new(stArrayStack*parrStack,int data)
{
	int *ptmp = NULL;

	/*如果栈不满,直接插入*/
	if(!arrayStack_is_full(parrStack))
	{
		return arrayStack_push(parrStack,data);
	}

	/*如果栈已经满,申请内存*/
    ptmp = (int *)malloc(2*parrStack->size*sizeof(int));
	if (ptmp == NULL)
	{
		return -1;
	}

	memcpy(ptmp,parrStack->array,parrStack->size*sizeof(int));

	free(parrStack->array);

    parrStack->array = ptmp;
	parrStack->size = 2*parrStack->size;
	parrStack->pos++;
    parrStack->array[parrStack->pos] = data;

	return ;
}

void arrayStack_dump(stArrayStack *parrStack)
{
	int i = 0;

	if (arrayStack_is_empty(parrStack))
	{
		printf("\r\n arrayStack is empty.");
		return;
	}
	printf("\r\narrayStack size = %d,pos= %d,",
			parrStack->size,parrStack->pos);
	for(i = 0; i <= parrStack->pos; i++)
	{
		printf("\r\narry[%d] = %d",i,parrStack->array[i]);
	}
}

int main()
{
	int i = 0;
	int ret = 0;
	stArrayStack * parrStack = NULL;

	printf("\r\n create size = 4 arrayStack.");

	parrStack = arrayStack_create(4);
	if (parrStack == NULL)
	{
	    printf("\r\n create size = 4 arrayStack faided.");
		return 0;
	}

	for (i = 0; i < 5; i++)
	{
		ret = arrayStack_push(parrStack,i);
		if(ret != 0)
		{
	        printf("\r\n push size = %d arrayStack faided.",i);

		}
	}
	arrayStack_dump(parrStack);
		
	ret = arrayStack_push_new(parrStack,4);
	if(ret != 0)
	{
	        printf("\r\n push size = %d arrayStack faided.",4);
    }
	arrayStack_dump(parrStack);

	arrayStack_destory(parrStack);
    
	return;
}


================================================
FILE: c-cpp/08_stack/arrayStack/arrayStack.h
================================================
/*************************************************************************
 > File Name: arrayStack.h
 > Author:  jinshaohui
 > Mail:    jinshaohui789@163.com
 > Time:    18-10-12
 > Desc:    
 ************************************************************************/

#ifndef ARRAY_STACJ_H
#define ARRAY_STACJ_H

typedef struct _array_stack
{
	int size;/*栈的大小*/
	int pos;/*当前存储元素的个数,即栈顶元素下表*/
	int *array;/*数据存储区*/
}stArrayStack;

#define arrayStack_size(arrayStack) (arrayStack->size)
#define arrayStack_is_empty(arrayStack) (arrayStack->pos == -1)
#define arrayStack_is_full(arrayStack)  (arrayStack->pos == (arrayStack->size-1))

#endif


================================================
FILE: c-cpp/08_stack/linkList/linklist_stack.c
================================================
/*************************************************************************
 > File Name: linklist_stack.c
 > Author:  jinshaohui
 > Mail:    jinshaohui789@163.com
 > Time:    18-10-12
 > Desc:    
 ************************************************************************/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include "./linklist_stack.h"

linklist_stack * stack_create()
{
	linklist_stack * stack = NULL;

	stack = (linklist_stack *)malloc(sizeof(linklist_stack));
	if (stack == NULL)
	{
		return NULL;
	}

	stack->next = NULL;

	return stack;
}

void stack_destory(linklist_stack* stack)
{
	linklist_stack * ptmp = NULL;

	while(!stack_is_empty(stack))
	{
		ptmp = stack->next;
		stack->next = stack->next->next;

		free(ptmp);
	}

	free(stack);

	return;
}

int stack_push(linklist_stack *stack,int data)
{
	linklist_stack * ptmp = NULL;

	ptmp = (linklist_stack *)malloc(sizeof(linklist_stack));
	if (ptmp == NULL)
	{
		return -1;
	}

	ptmp->data = data;
	ptmp->next = stack->next;
	stack->next = ptmp;

	return 0;
}

int stack_pop(linklist_stack*stack,int *data)
{
	linklist_stack *ptmp = NULL;
	if (data == NULL)
	{
		return -1;
	}
	if(stack_is_empty(stack))
	{
		return -1;		
	}
	*data = stack->next->data;
    ptmp = stack->next;
	stack->next = ptmp->next;
	free(ptmp);

    return 0;
}


void stack_dump(linklist_stack *stack)
{
	linklist_stack * ptmp = stack->next;
	
	while(ptmp != NULL)
	{
		printf("\r\n data = %d",ptmp->data);
		ptmp = ptmp->next;
	}
	return;
}

int main()
{
	int i = 0;
	int ret = 0;
	int data = 0;
	linklist_stack * stack = NULL;

    stack = stack_create();
	if (stack == NULL)
	{
		printf("\r\n stack create falied.");
        return 0;			
	}
    
	for (i = 0; i < 4; i++)
	{
		ret = stack_push(stack,i);
		if(ret != 0)
		{
		    printf("\r\n stack push %d falied.",i);
		}
	}

    stack_dump(stack);

	for (i = 0; i < 5; i++)
	{
		ret = stack_pop(stack,&data);
		if(ret != 0)
		{
		    printf("\r\n stack pop%d falied.", i);
		}
		else
		{
		    printf("\r\n data = %d,",data);
		}
	}

	stack_destory(stack);

	return 0;

}


================================================
FILE: c-cpp/08_stack/linkList/linklist_stack.h
================================================
/*************************************************************************
 > File Name: linklist_stack.h
 > Author:  jinshaohui
 > Mail:    jinshaohui789@163.com
 > Time:    18-10-12
 > Desc:    
 ************************************************************************/

#ifndef STACK_LINK_LIST_H
#define STACK_LINK_LIST_H

typedef struct _linkliststack
{
	int data;
	struct _linkliststack *next;
}linklist_stack;


#define stack_is_empty(liststack) (liststack->next == NULL)

#endif



================================================
FILE: c-cpp/08_stack/linked_list.h
================================================
/**
 * C++ 版本单链表结点
 *
 * Author: Liam Huang (Liam0205)
 */

#ifndef STACK_LINKED_LIST_H_
#define STACK_LINKED_LIST_H_

#include <memory>

template <typename T>
struct Node {
    using ptr_t = std::shared_ptr<Node<T>>;
    T     data;
    ptr_t next;

    Node(T data_) : data(data_), next(nullptr) {}
    Node() : next(nullptr) {}
};

#endif


================================================
FILE: c-cpp/08_stack/stack_based_on_linked_list.hpp
================================================
/**
 * 基于链表实现的栈。
 *
 * Author: Liam Huang (Liam0205)
 */

#ifndef STACK_STACK_BASED_ON_LINKED_LIST_HPP_
#define STACK_STACK_BASED_ON_LINKED_LIST_HPP_

#include <memory>
#include "linked_list.h"

template <typename T>
class Stack {
  public:
    using value_type = T;
    using node_type  = typename Node<value_type>::ptr_t;

  private:
    node_type top_   = nullptr;

  public:
    bool empty(void) const {
        return nullptr == top_;
    }
    void push(const value_type& value) {
        auto node = std::make_shared<node_type>(value);
        if (this->empty()) {
            top_ = node;
        } else {
            node->next = top_;
            top_ = node;
        }
    }
    value_type top(void) const {
        if (not this->empty()) {
            return top_->data;
        } else {
            throw "Fetch data from empty stack!";
        }
    }
    void pop(void) {
        if (not this->empty()) {
            top_ = top_->next;
            return;
        } else {
            throw "Pop from empty stack!";
        }
    }
};

#endif


================================================
FILE: c-cpp/09_queue/.gitkeep
================================================


================================================
FILE: c-cpp/09_queue/array_queue/array_queue.c
================================================
/*************************************************************************
 > File Name: array_queue.c
 > Author:  jinshaohui
 > Mail:    jinshaohui789@163.com
 > Time:    18-10-12
 > Desc:    
 ************************************************************************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include"./array_queue.h"


array_queue * array_queue_create(int size)
{
	array_queue * queue = NULL;

	queue = (array_queue*)malloc(sizeof(array_queue));
	if (queue == NULL)
	{
		return NULL;
	}
	queue->array = (int *)malloc(sizeof(int)*size);
	if (queue->array == NULL)
	{
        free(queue);
		return NULL;
	}
	queue->size  = size;
	queue->num   = 0;
	queue->head  = 0;
	queue->tail  = 0;

	return queue;
}

void array_queue_destory(array_queue *queue)
{
    if (queue == NULL)
	{
		return;
	}

	if (queue->array != NULL)
	{
		free(queue->array);
	}

	free(queue);
	return;
}

/*入队列 */
int array_queue_enqueue(array_queue *queue,int data)
{
	/*队列为空,或者队列满时,返回-1*/
	if ((queue == NULL) || (array_queue_is_full(queue)))
	{
		return -1;
	}

	queue->num++;
	queue->array[queue->tail] = data;
	queue->tail = (queue->tail + 1) % queue->size;

	return 0;
}

/*出队列*/
int array_queue_dequeue(array_queue * queue,int *data)
{
	/*队列为空,数据存储为空,队列为空时返回-1*/
	if ((queue == NULL) || (data == NULL) || (array_queue_is_empty(queue)))
	{
		return -1;
	}
    *data = queue->array[queue->head];
	queue->num--;
	queue->head = (queue->head + 1) % queue->size;

    return 0;
}

void array_queue_dump(array_queue *queue)
{
	int i = 0;
	int pos = 0;

	if ((queue == NULL) || (array_queue_is_empty(queue)))
	{
		printf("\r\n queue is empty");
		return;
	}

	printf("\r\n size:%d,num:%d,head:%d,tali:%d",
			queue->size,queue->num,queue->head,queue->tail);
	for (i = 0; i < queue->num; i ++)
	{
		pos = (queue->head + i) %queue->size;
		printf("\r\n array[%d] = %d",pos,queue->array[pos]);
	}
    return;
}

int main()
{
	int i = 0;
	int ret = 0;
	int data = 0;
	array_queue * queue = NULL;

	queue = array_queue_create(4);
	if (queue == NULL)
	{
		printf("\r\n queue is create failed.");
		return 0;
	}
	/*队列时空时,出队返回错误*/
	ret = array_queue_dequeue(queue, &data);
	if (ret != 0)
	{
		    printf("\r\n queue %d dequeue failed.",ret);
	}

	/*队列大小是4,入队5个,最后一个报错*/
	for (i = 0; i < 5; i++)
	{
		ret = array_queue_enqueue(queue,i);
		if (ret != 0)
		{
		    printf("\r\n queue %d enqueue failed.",i);

		}
	}

	array_queue_dump(queue);
    
	ret = array_queue_dequeue(queue, &data);
	if (ret != 0)
	{
		    printf("\r\n queue %d dequeue failed.",i);
	}
	printf("\r\n queue %d dequue.",data);
	array_queue_dump(queue);
	data = 5;
	printf("\r\n queue %d enqueue.",data);
	ret = array_queue_enqueue(queue,data);
	if (ret != 0)
	{
		printf("\r\n queue %d enqueue failed.",data);
    }
	array_queue_dump(queue);
    
	array_queue_destory(queue);
	return 0;

}



================================================
FILE: c-cpp/09_queue/array_queue/array_queue.h
================================================
/*************************************************************************
 > File Name: array_queue.h
 > Author:  jinshaohui
 > Mail:    jinshaohui789@163.com
 > Time:    18-10-12
 > Desc:    
 ************************************************************************/
#ifndef ARRAY_QUEUE_H
#define ARRAY_QUEUE_H

typedef struct _array_queue
{
	int size;/*队列的大小*/
	int num; /*当前存储数据的大小*/
	int head;/*队列的头*/
	int tail;/*队列的尾*/
	int *array;/*数据存储区*/
}array_queue;

#define array_queue_is_empty(array_queue) (array_queue->num == 0)
#define array_queue_is_full(array_queue)  ((array_queue->num) == (array_queue->size))

#endif



================================================
FILE: c-cpp/09_queue/array_queue.hpp
================================================
/**
 * Created by Liam Huang (Liam0205) on 2018/10/10.
 */

#ifndef QUEUE_ARRAY_QUEUE_HPP_
#define QUEUE_ARRAY_QUEUE_HPP_

template <typename T>
class ArrayQueue {
  private:
    T*     items_    = nullptr;
    size_t capacity_ = 0;
    size_t head_     = 0;
    size_t tail_     = 0;

  public:
    ArrayQueue() = delete;
    ArrayQueue(const size_t capacity) : capacity_(capacity) {
        items_ = new T[capacity_];
    }
    ~ArrayQueue() {
        if (nullptr != items_) {
            delete[] items_;
            items_ = nullptr;
        }
    }
    ArrayQueue(const ArrayQueue& other) : capacity_(other.capacity_) {
        items_ = new T[capacity_];
        for (size_t i = other.head_; i != other.tail_; ++i) {
            enqueue(other.items_[i]);
        }
    }
    ArrayQueue& operator=(const ArrayQueue& rhs) {
        delete[] items_;
        head_     = 0;
        tail_     = 0;
        capacity_ = rhs.capacity_;
        items_    = new T[capacity_];
        for (size_t i = rhs.head_; i != rhs.tail_; ++i) {
            enqueue(rhs.items_[i]);
        }
        return *this;
    }
    ArrayQueue(ArrayQueue&& other) : items_(other.items_),
                                     capacity_(other.capacity_),
                                     head_(other.head_),
                                     tail_(other.tail_) {
        other.items_    = nullptr;
        other.capacity_ = 0;
        other.head_     = 0;
        other.tail_     = 0;
    }
    ArrayQueue& operator=(ArrayQueue&& rhs) {
        delete[] items_;
        items_        = rhs.items_;
        capacity_     = rhs.capacity_;
        head_         = rhs.head_;
        tail_         = rhs.tail_;
        rhs.items_    = nullptr;
        rhs.capacity_ = 0;
        rhs.head_     = 0;
        rhs.tail_     = 0;
        return *this;
    }

  public:
    void enqueue(T item) {
        if (capacity_ == tail_) {
            throw "Push data into a full queue!";
        }
        items_[tail_++] = item;
    }
    T head() const {
        if (head_ != tail_) {
            return items_[head_];
        } else {
            throw "Fetch data from an empty queue!";
        }
    }
    void dequeue() {
        if (head_ != tail_) {
            ++head_;
        } else {
            throw "Pop data from an empty queue!";
        }
    }

  public:
    template <typename UnaryFunc>
    void traverse(UnaryFunc do_traverse) {
        for (size_t i = head_; i != tail_; ++i) {
            do_traverse(items_[i]);
        }
    }
};

#endif  // QUEUE_ARRAY_QUEUE_HPP_


================================================
FILE: c-cpp/09_queue/array_queue_test.cc
================================================
#include <iostream>
#include "array_queue.hpp"

int main() {
    auto do_traverse = [&](auto item){ std::cout << item << ' '; };

    ArrayQueue<int> array_queue_1(3);
    array_queue_1.enqueue(1);
    array_queue_1.enqueue(2);
    array_queue_1.enqueue(3);
    // array_queue_1.enqueue(4);  // throw
    array_queue_1.traverse(do_traverse);
    std::cout << std::endl;

    ArrayQueue<int> array_queue_2(array_queue_1);  // copy constructor
    array_queue_2.traverse(do_traverse);
    std::cout << std::endl;

    ArrayQueue<int> array_queue_3(std::move(array_queue_2));  // move constructor
    array_queue_3.traverse(do_traverse);
    std::cout << std::endl;
    array_queue_2.traverse(do_traverse);
    std::cout << std::endl;

    std::cout << array_queue_3.head() << std::endl;
    array_queue_3.dequeue();
    std::cout << array_queue_3.head() << std::endl;
    array_queue_3.dequeue();
    std::cout << array_queue_3.head() << std::endl;
    array_queue_3.dequeue();
    // std::cout << array_queue_3.head() << std::endl;  // throw
    // array_queue_3.dequeue();  // throw

    ArrayQueue<int> array_queue_4(1);
    array_queue_4 = array_queue_1;  // copy assignment
    array_queue_4.traverse(do_traverse);
    std::cout << std::endl;

    ArrayQueue<int> array_queue_5(100);
    array_queue_5 = std::move(array_queue_4);  // move assignment
    array_queue_5.traverse(do_traverse);
    std::cout << std::endl;
    array_queue_4.traverse(do_traverse);
    std::cout << std::endl;

    std::cout << array_queue_5.head() << std::endl;
    array_queue_5.dequeue();
    std::cout << array_queue_5.head() << std::endl;
    array_queue_5.dequeue();
    std::cout << array_queue_5.head() << std::endl;
    array_queue_5.dequeue();
    // std::cout << array_queue_5.head() << std::endl;  // throw
    // array_queue_5.dequeue();  // throw

    return 0;
}


================================================
FILE: c-cpp/09_queue/block_queue.hpp
================================================
/**
 * Created by Liam Huang (Liam0205) on 2018/10/11.
 */

#ifndef QUEUE_BLOCK_QUEUE_HPP_
#define QUEUE_BLOCK_QUEUE_HPP_

#include <queue>
#include <mutex>
#include <condition_variable>

template <typename T>
class BlockQueue {
  public:
    using value_type      = T;
    using container_type  = std::queue<value_type>;
    using size_type       = typename container_type::size_type;

  private:
    size_type capacity_ = 0;
    container_type container_;
    mutable std::mutex mutex_;
    mutable std::condition_variable not_empty_;
    mutable std::condition_variable not_full_;

  public:
    BlockQueue() = delete;
    BlockQueue(const size_type capacity) : capacity_(capacity) {}
    BlockQueue(const BlockQueue&) = default;
    BlockQueue(BlockQueue&&) = default;
    BlockQueue& operator=(const BlockQueue&) = default;
    BlockQueue& operator=(BlockQueue&&) = default;

  private:
    bool empty() const { return container_.empty(); }
    bool full() const { return not(container_.size() < capacity_); }

  public:
    void put(const value_type& item) {
        std::unqiue_lock<std::mutex> lock(mutex_);
        while (full()) {
            not_full_.wait(lock);
        }
        container_.push(item);
        not_empty_.notify_one();
    }
    void take(value_type& out) {
        std::unique_lock<std::mutex> lock(mutex_);
        while (empty()) {
            not_empty_.wait(lock);
        }
        out = container_.front();
        container_.pop();
        not_full_.notify_one();
    }
    template <typename Duration>
    bool put_for(const value_type& item, const Duration& d) {
        std::unqiue_lock<std::mutex> lock(mutex_);
        if (not_full_.wait_for(lock, d, [&](){ return not full(); })) {
            container_.push(item);
            not_empty_.notify_one();
            return true;
        } else {
            return false;
        }
    }
    template <typename Duration>
    bool take_for(const Duration& d, value_type& out) {
        std::unique_lock<std::mutex> lock(mutex_);
        if (not_empty_.wait_for(lock, d, [&](){ return not empty(); })) {
            out = container_.front();
            container_.pop();
            not_full_.notify_one();
            return true;
        } else {
            return false;
        }
    }
};

#endif  // QUEUE_BLOCK_QUEUE_HPP_



================================================
FILE: c-cpp/09_queue/circular_queue.hpp
================================================
/**
 * Created by Liam Huang (Liam0205) on 2018/10/10.
 */

#ifndef QUEUE_CIRCULAR_QUEUE_HPP_
#define QUEUE_CIRCULAR_QUEUE_HPP_

template <typename T>
class CircularQueue {
  private:
    T*     items_    = nullptr;
    size_t capacity_ = 0;
    size_t head_     = 0;
    size_t tail_     = 0;

  public:
    CircularQueue() = delete;
    CircularQueue(const size_t capacity) : capacity_(capacity) {
        items_ = new T[capacity_];
    }
    ~CircularQueue() {
        if (nullptr != items_) {
            delete[] items_;
            items_ = nullptr;
        }
    }
    CircularQueue(const CircularQueue& other) : capacity_(other.capacity_) {
        items_ = new T[capacity_];
        for (size_t i = other.head_; i != other.tail_; ++i) {
            enqueue(other.items_[i]);
        }
    }
    CircularQueue& operator=(const CircularQueue& rhs) {
        delete[] items_;
        head_     = 0;
        tail_     = 0;
        capacity_ = rhs.capacity_;
        items_    = new T[capacity_];
        for (size_t i = rhs.head_; i != rhs.tail_; ++i) {
            enqueue(rhs.items_[i]);
        }
        return *this;
    }
    CircularQueue(CircularQueue&& other) : items_(other.items_),
                                     capacity_(other.capacity_),
                                     head_(other.head_),
                                     tail_(other.tail_) {
        other.items_    = nullptr;
        other.capacity_ = 0;
        other.head_     = 0;
        other.tail_     = 0;
    }
    CircularQueue& operator=(CircularQueue&& rhs) {
        delete[] items_;
        items_        = rhs.items_;
        capacity_     = rhs.capacity_;
        head_         = rhs.head_;
        tail_         = rhs.tail_;
        rhs.items_    = nullptr;
        rhs.capacity_ = 0;
        rhs.head_     = 0;
        rhs.tail_     = 0;
        return *this;
    }

  public:
    void enqueue(T item) {
        if ((tail_ + 1) % capacity_ == head_) {
            throw "Push data into a full queue!";
        }
        items_[tail_] = item;
        tail_ = (tail_ + 1) % capacity_;
    }
    T head() const {
        if (head_ != tail_) {
            return items_[head_];
        } else {
            throw "Fetch data from an empty queue!";
        }
    }
    void dequeue() {
        if (head_ != tail_) {
            head_ = (head_ + 1) % capacity_;
        } else {
            throw "Pop data from an empty queue!";
        }
    }

  public:
    template <typename UnaryFunc>
    void traverse(UnaryFunc do_traverse) {
        if (0 == capacity_) return;
        for (size_t i = head_; i % capacity_ != tail_; ++i) {
            do_traverse(items_[i % capacity_]);
        }
    }
};

#endif  // QUEUE_CIRCULAR_QUEUE_HPP_


================================================
FILE: c-cpp/09_queue/circular_queue_test.cc
================================================
#include <iostream>
#include "circular_queue.hpp"

int main() {
    auto do_traverse = [&](auto item){ std::cout << item << ' '; };

    CircularQueue<int> circular_queue_1(4);
    circular_queue_1.enqueue(1);
    circular_queue_1.enqueue(2);
    circular_queue_1.enqueue(3);
    // circular_queue_1.enqueue(4);  // throw
    circular_queue_1.traverse(do_traverse);
    std::cout << std::endl;

    CircularQueue<int> circular_queue_2(circular_queue_1);  // copy constructor
    circular_queue_2.traverse(do_traverse);
    std::cout << std::endl;

    CircularQueue<int> circular_queue_3(std::move(circular_queue_2));  // move constructor
    circular_queue_3.traverse(do_traverse);
    std::cout << std::endl;
    circular_queue_2.traverse(do_traverse);
    std::cout << std::endl;

    std::cout << circular_queue_3.head() << std::endl;
    circular_queue_3.dequeue();
    std::cout << circular_queue_3.head() << std::endl;
    circular_queue_3.dequeue();
    std::cout << circular_queue_3.head() << std::endl;
    circular_queue_3.dequeue();
    // std::cout << circular_queue_3.head() << std::endl;  // throw
    // circular_queue_3.dequeue();  // throw

    CircularQueue<int> circular_queue_4(1);
    circular_queue_4 = circular_queue_1;  // copy assignment
    circular_queue_4.traverse(do_traverse);
    std::cout << std::endl;

    CircularQueue<int> circular_queue_5(100);
    circular_queue_5 = std::move(circular_queue_4);  // move assignment
    circular_queue_5.traverse(do_traverse);
    std::cout << std::endl;
    circular_queue_4.traverse(do_traverse);
    std::cout << std::endl;

    std::cout << circular_queue_5.head() << std::endl;
    circular_queue_5.dequeue();
    std::cout << circular_queue_5.head() << std::endl;
    circular_queue_5.dequeue();
    std::cout << circular_queue_5.head() << std::endl;
    circular_queue_5.dequeue();
    // std::cout << circular_queue_5.head() << std::endl;  // throw
    // circular_queue_5.dequeue();  // throw

    for (size_t i = 0; i != 4; ++i) {
        circular_queue_1.dequeue();
        circular_queue_1.enqueue(i + 4);
        circular_queue_1.traverse(do_traverse);
        std::cout << std::endl;
    }
    return 0;
}


================================================
FILE: c-cpp/09_queue/concurrency_queue.hpp
================================================
/**
 * Created by Liam Huang (Liam0205) on 2018/10/11.
 */

#ifndef QUEUE_CONCURRENCY_QUEUE_HPP_
#define QUEUE_CONCURRENCY_QUEUE_HPP_

#include <queue>
#include <mutex>
#include <condition_variable>
#include <memory>

template <typename T>
class ConcurrencyQueue {
  public:
    using value_type      = T;
    using container_type  = std::queue<value_type>;
    using size_type       = typename container_type::size_type;

  private:
    container_type container_;
    mutable std::mutex mutex_;
    std::condition_variable container_cond_;

  public:
    ConcurrencyQueue() = default;
    ConcurrencyQueue(const ConcurrencyQueue&) = default;
    ConcurrencyQueue(ConcurrencyQueue&&) = default;
    ConcurrencyQueue& operator=(const ConcurrencyQueue&) = default;
    ConcurrencyQueue& operator=(ConcurrencyQueue&&) = default;

  private:
    bool empty_() const { return container_.empty(); }

  public:
    bool empty() const {
        std::lock_guard<std::mutex> lg(mutex_);
        return container_.empty();
    }
    void push(value_type item) {
        std::lock_guard<std::mutex> lg(mutex_);
        container_.push(std::move(item));
        container_cond_.notify_one();
    }
    void wait_and_pop(value_type& out) {
        std::unique_lock<std::mutex> lk(mutex_);
        while (empty_()) {
            container_cond_.wait(lk)
        }
        out = std::move(container_.front());
        container_.pop();
    }
    std::shared_ptr<value_type> wait_and_pop() {
        std::unique_lock<std::mutex> lk(mutex_);
        while (empty_()) {
            container_cond_.wait(lk)
        }
        auto res = std::make_shared<value_type>(std::move(container_.front()));
        container_.pop();
        return res;
    }
    bool try_pop(value_type& out) {
        std::lock_guard<std::mutex> lg(mutex_);
        if (empty_()) {
            return false;
        } else {
            out = std::move(container_.front());
            container_.pop();
            return true;
        }
    }
    std::shared_ptr<value_type> try_pop() {
        std::lock_guard<std::mutex> lg(mutex_);
        if (empty_()) {
            return nullptr;
        } else {
            auto res = std::make_shared<value_type>(std::move(container_.front()));
            container_.pop();
            return res;
        }
    }
};

#endif  // QUEUE_CONCURRENCY_QUEUE_HPP_



================================================
FILE: c-cpp/09_queue/dynamic_array_queue.hpp
================================================
/**
 * Created by Liam Huang (Liam0205) on 2018/10/10.
 */

#ifndef QUEUE_DYNAMIC_ARRAY_QUEUE_HPP_
#define QUEUE_DYNAMIC_ARRAY_QUEUE_HPP_

template <typename T>
class DynamicArrayQueue {
  private:
    T*     items_    = nullptr;
    size_t capacity_ = 0;
    size_t head_     = 0;
    size_t tail_     = 0;

  public:
    DynamicArrayQueue() = delete;
    DynamicArrayQueue(const size_t capacity) : capacity_(capacity) {
        items_ = new T[capacity_];
    }
    ~DynamicArrayQueue() {
        if (nullptr != items_) {
            delete[] items_;
            items_ = nullptr;
        }
    }
    DynamicArrayQueue(const DynamicArrayQueue& other) : capacity_(other.capacity_) {
        items_ = new T[capacity_];
        for (size_t i = other.head_; i != other.tail_; ++i) {
            enqueue(other.items_[i]);
        }
    }
    DynamicArrayQueue& operator=(const DynamicArrayQueue& rhs) {
        delete[] items_;
        head_     = 0;
        tail_     = 0;
        capacity_ = rhs.capacity_;
        items_    = new T[capacity_];
        for (size_t i = rhs.head_; i != rhs.tail_; ++i) {
            enqueue(rhs.items_[i]);
        }
        return *this;
    }
    DynamicArrayQueue(DynamicArrayQueue&& other) : items_(other.items_),
                                     capacity_(other.capacity_),
                                     head_(other.head_),
                                     tail_(other.tail_) {
        other.items_    = nullptr;
        other.capacity_ = 0;
        other.head_     = 0;
        other.tail_     = 0;
    }
    DynamicArrayQueue& operator=(DynamicArrayQueue&& rhs) {
        delete[] items_;
        items_        = rhs.items_;
        capacity_     = rhs.capacity_;
        head_         = rhs.head_;
        tail_         = rhs.tail_;
        rhs.items_    = nullptr;
        rhs.capacity_ = 0;
        rhs.head_     = 0;
        rhs.tail_     = 0;
        return *this;
    }

  public:
    void enqueue(T item) {
        if (capacity_ == tail_ - head_) {
            throw "Push data into a full queue!";
        }
        if (capacity_ == tail_) {
            // item transport
            for (size_t i = head_; i != tail_; ++i) {
                items_[i - head_] = items_[i];
            }
            tail_ = tail_ - head_;
            head_ = 0;
        }
        items_[tail_++] = item;
    }
    T head() const {
        if (head_ != tail_) {
            return items_[head_];
        } else {
            throw "Fetch data from an empty queue!";
        }
    }
    void dequeue() {
        if (head_ != tail_) {
            ++head_;
        } else {
            throw "Pop data from an empty queue!";
        }
    }

  public:
    template <typename UnaryFunc>
    void traverse(UnaryFunc do_traverse) {
        for (size_t i = head_; i != tail_; ++i) {
            do_traverse(items_[i]);
        }
    }
};

#endif  // QUEUE_DYNAMIC_ARRAY_QUEUE_HPP_


================================================
FILE: c-cpp/09_queue/dynamic_array_queue_test.cc
================================================
#include <iostream>
#include "dynamic_array_queue.hpp"

int main() {
    auto do_traverse = [&](auto item){ std::cout << item << ' '; };

    DynamicArrayQueue<int> dynamic_array_queue_1(3);
    dynamic_array_queue_1.enqueue(1);
    dynamic_array_queue_1.enqueue(2);
    dynamic_array_queue_1.enqueue(3);
    // dynamic_array_queue_1.enqueue(4);  // throw
    dynamic_array_queue_1.traverse(do_traverse);
    std::cout << std::endl;

    DynamicArrayQueue<int> dynamic_array_queue_2(dynamic_array_queue_1);  // copy constructor
    dynamic_array_queue_2.traverse(do_traverse);
    std::cout << std::endl;

    DynamicArrayQueue<int> dynamic_array_queue_3(std::move(dynamic_array_queue_2));  // move constructor
    dynamic_array_queue_3.traverse(do_traverse);
    std::cout << std::endl;
    dynamic_array_queue_2.traverse(do_traverse);
    std::cout << std::endl;

    std::cout << dynamic_array_queue_3.head() << std::endl;
    dynamic_array_queue_3.dequeue();
    std::cout << dynamic_array_queue_3.head() << std::endl;
    dynamic_array_queue_3.dequeue();
    std::cout << dynamic_array_queue_3.head() << std::endl;
    dynamic_array_queue_3.dequeue();
    // std::cout << dynamic_array_queue_3.head() << std::endl;  // throw
    // dynamic_array_queue_3.dequeue();  // throw

    DynamicArrayQueue<int> dynamic_array_queue_4(1);
    dynamic_array_queue_4 = dynamic_array_queue_1;  // copy assignment
    dynamic_array_queue_4.traverse(do_traverse);
    std::cout << std::endl;

    DynamicArrayQueue<int> dynamic_array_queue_5(100);
    dynamic_array_queue_5 = std::move(dynamic_array_queue_4);  // move assignment
    dynamic_array_queue_5.traverse(do_traverse);
    std::cout << std::endl;
    dynamic_array_queue_4.traverse(do_traverse);
    std::cout << std::endl;

    std::cout << dynamic_array_queue_5.head() << std::endl;
    dynamic_array_queue_5.dequeue();
    std::cout << dynamic_array_queue_5.head() << std::endl;
    dynamic_array_queue_5.dequeue();
    std::cout << dynamic_array_queue_5.head() << std::endl;
    dynamic_array_queue_5.dequeue();
    // std::cout << dynamic_array_queue_5.head() << std::endl;  // throw
    // dynamic_array_queue_5.dequeue();  // throw

    for (size_t i = 0; i != 3; ++i) {
        dynamic_array_queue_1.dequeue();
        dynamic_array_queue_1.enqueue(i + 4);
        dynamic_array_queue_1.traverse(do_traverse);
        std::cout << std::endl;
    }
    return 0;
}


================================================
FILE: c-cpp/09_queue/linked_queue.hpp
================================================
/**
 * Created by Liam Huang (Liam0205) on 2018/10/10.
 */

#ifndef QUEUE_LINKED_QUEUE_HPP_
#define QUEUE_LINKED_QUEUE_HPP_

#include <memory>

template <typename T>
struct Node {
    using ptr_t = std::shared_ptr<Node<T>>;
    T     data;
    ptr_t next;

    Node(T data_) : data(data_), next(nullptr) {}
    Node() : next(nullptr) {}
};

template <typename T>
class LinkedQueue {
  public:
    using node_type  = Node<T>;
    using node_ptr_t = typename node_type::ptr_t;

  private:
    node_ptr_t head_        = nullptr;
    node_ptr_t before_tail_ = nullptr;

  public:
    LinkedQueue()  = default;
    ~LinkedQueue() = default;
    LinkedQueue(const LinkedQueue& other) = default;
    LinkedQueue& operator=(const LinkedQueue& rhs) = default;
    LinkedQueue(LinkedQueue&& other) = default;
    LinkedQueue& operator=(LinkedQueue&& rhs) = default;

  public:
    void enqueue(T item) {
        if (nullptr == head_) {
            head_ = std::make_shared<node_type>(item);
            before_tail_ = head_;
        } else {
            before_tail_->next = std::make_shared<node_type>(item);
            before_tail_ = before_tail_->next;
        }
    }
    T head() const {
        if (nullptr != head_) {
            return head_->data;
        } else {
            throw "Fetch data from an empty queue!";
        }
    }
    void dequeue() {
        if (nullptr != head_) {
            head_ = head_->next;
            if (nullptr == head_) {
                before_tail_ = nullptr;
            }
        } else {
            throw "Pop data from an empty queue!";
        }
    }

  public:
    template <typename UnaryFunc>
    void traverse(UnaryFunc do_traverse) {
        for (node_ptr_t work = head_; nullptr != work; work = work->next) {
            do_traverse(work->data);
        }
    }
};

#endif  // QUEUE_LINKED_QUEUE_HPP_


================================================
FILE: c-cpp/09_queue/linked_queue_test.cc
================================================
#include <iostream>
#include "linked_queue.hpp"

int main() {
    auto do_traverse = [&](auto item){ std::cout << item << ' '; };

    LinkedQueue<int> linked_queue_1;
    linked_queue_1.enqueue(1);
    linked_queue_1.enqueue(2);
    linked_queue_1.enqueue(3);
    linked_queue_1.traverse(do_traverse);
    std::cout << std::endl;

    LinkedQueue<int> linked_queue_2(linked_queue_1);  // copy constructor
    linked_queue_2.traverse(do_traverse);
    std::cout << std::endl;

    LinkedQueue<int> linked_queue_3(std::move(linked_queue_2));  // move constructor
    linked_queue_3.traverse(do_traverse);
    std::cout << std::endl;
    linked_queue_2.traverse(do_traverse);
    std::cout << std::endl;

    std::cout << linked_queue_3.head() << std::endl;
    linked_queue_3.dequeue();
    std::cout << linked_queue_3.head() << std::endl;
    linked_queue_3.dequeue();
    std::cout << linked_queue_3.head() << std::endl;
    linked_queue_3.dequeue();
    // std::cout << linked_queue_3.head() << std::endl;  // throw
    // linked_queue_3.dequeue();  // throw

    LinkedQueue<int> linked_queue_4;
    linked_queue_4 = linked_queue_1;  // copy assignment
    linked_queue_4.traverse(do_traverse);
    std::cout << std::endl;

    LinkedQueue<int> linked_queue_5;
    linked_queue_5 = std::move(linked_queue_4);  // move assignment
    linked_queue_5.traverse(do_traverse);
    std::cout << std::endl;
    linked_queue_4.traverse(do_traverse);
    std::cout << std::endl;

    std::cout << linked_queue_5.head() << std::endl;
    linked_queue_5.dequeue();
    std::cout << linked_queue_5.head() << std::endl;
    linked_queue_5.dequeue();
    std::cout << linked_queue_5.head() << std::endl;
    linked_queue_5.dequeue();
    // std::cout << linked_queue_5.head() << std::endl;  // throw
    // linked_queue_5.dequeue();  // throw

    return 0;
}


================================================
FILE: c-cpp/09_queue/list_queue/list_queue.c
================================================
/*************************************************************************
 > File Name: list_queue.c
 > Author:  jinshaohui
 > Mail:    jinshaohui789@163.com
 > Time:    18-10-13
 > Desc:    
 ************************************************************************/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include"./list_queue.h"

/*创建队列头*/
list_queue *list_queue_create()
{
	list_queue * queue = NULL;

	queue = (list_queue *)malloc(sizeof(list_queue));
	if(queue == NULL)
	{
		return NULL;
	}

	queue->num  = 0;
	queue->head = NULL;
	queue->tail = NULL;

	return queue;
}
void list_queue_destroy(list_queue*queue)
{
	int i = 0;
	int data = 0;

	if ((queue == NULL) || (list_queue_is_empty(queue)))
	{
		return ;
	}

	while(!list_queue_is_empty(queue))
	{
		(void)list_queue_dequeue(queue,&data);
	}

    free(queue);
	return;
}
int list_queue_enqueue(list_queue *queue,int data)
{
	queue_node *ptmp = NULL;

	if(queue == NULL)
	{
		return -1;
	}

	ptmp = (queue_node *)malloc(sizeof(queue_node));
	if (ptmp == NULL)
	{
		return -1;
	}

	ptmp->data = data;
	ptmp->next = NULL;
	if (queue->head == NULL)
	{
		queue->head = ptmp;
	}
	else
	{
	    queue->tail->next = ptmp;

	}
	queue->tail = ptmp;
	queue->num++;

	return 0;
}

/*出队*/
int list_queue_dequeue(list_queue *queue,int *data)
{
	queue_node * ptmp = NULL;

	if ((queue == NULL) || (data == NULL) || list_queue_is_empty(queue))
	{
		return -1;
	}

	*data = queue->head->data;
    ptmp = queue->head;
	queue->head = queue->head->next;
	queue->num--;

	if (queue->head == NULL)
	{
		queue->tail = NULL;
	}

	
	free(ptmp);
	return 0;
}
void list_queue_dump(list_queue*queue)
{
	int i = 0;
	queue_node *ptmp = NULL;

	if ((queue == NULL) || (list_queue_is_empty(queue)))
	{
		return;
	}

	ptmp = queue->head;

    printf("\r\n----dump queue num = %d--------",queue->num);
	while(ptmp != NULL)
	{
		printf("\r\nnode[%d] = %d",i,ptmp->data);
		i++;
		ptmp = ptmp->next;
	}
	printf("\r\n---------------------------------\r\n");
    
	return;
}

int main()
{
	int i = 0;
	int data = 0;
	int ret = 0;
	list_queue * queue;

	queue = list_queue_create();
	if (queue == NULL)
	{
		printf("\r\nlist queue create falied..");
		return 0;
	}

	for (i = 0; i < 5; i++)
	{
		(void)list_queue_enqueue(queue,i);
	}
	list_queue_dump(queue);

    ret = list_queue_dequeue(queue,&data);
	if(ret != 0)
	{
		printf("\r\nlist queue dequeue %d falied.",data);
	}
	printf("\r\nlist queue dequeue %d",data);
	list_queue_dump(queue);


    ret = list_queue_dequeue(queue,&data);
	if(ret != 0)
	{
		printf("\r\nlist queue dequeue %d failed.",data);
	}
    printf("\r\nlist queue dequeue %d",data);
	list_queue_dump(queue);

	printf("\r\nlist queue enqueue %d",data);
	(void)list_queue_enqueue(queue,data);
	list_queue_dump(queue);

    list_queue_destroy(queue);
	return 0;
}


================================================
FILE: c-cpp/09_queue/list_queue/list_queue.h
================================================
/*************************************************************************
 > File Name: list_queue.h
 > Author:  jinshaohui
 > Mail:    jinshaohui789@163.com
 > Time:    18-10-13
 > Desc:    
 ************************************************************************/

#ifndef LINK_LIST_QUEUE_H
#define LINK_LIST_QUEUE_H

typedef struct _list_queue_node
{
	int data;
	struct _list_queue_node *next;
}queue_node;

typedef struct _list_queue
{
	int num;
	queue_node *head;
	queue_node *tail;
}list_queue;

#define list_queue_is_empty(queue) ((queue->num) == 0)

#endif


================================================
FILE: c-cpp/09_queue/lock_free_queue.hpp
================================================
/**
 * Created by Liam Huang (Liam0205) on 2018/10/11.
 */

#ifndef QUEUE_LOCK_FREE_QUEUE_HPP_
#define QUEUE_LOCK_FREE_QUEUE_HPP_

#include <memory>
#include <atomic>

template <typename T>
class LockFreeQueue {
  public:
    using value_type      = T;

  private:
    struct node {
        std::shared<value_type> data = nullptr;
        node* next                   = nullptr;
    };
    std::atomic<node*> head = nullptr;
    std::atomic<node*> tail = nullptr;

  public:
    LockFreeQueue() head(new node), tail(head.load()) {}
    LockFreeQueue(const LockFreeQueue&) = delete;
    LockFreeQueue(LockFreeQueue&& other) : head(other.head.load()), tail(other.tail.load()) {
        other.head.store(nullptr);
        other.tail.store(nullptr);
    }
    LockFreeQueue& operator=(const LockFreeQueue&) = delete;
    LockFreeQueue& operator=(LockFreeQueue&& rhs) {
        while (node* const old_head = head.load()) {
            head.store(old_head->next);
            delete old_head;
        }
        head.store(rhs.head.load());
        tail.store(rhs.tail.load());
        rhs.head.store(nullptr);
        rhs.tail.store(nullptr);
    }
    ~LockFreeQueue() {
        while (node* const old_head = head.load()) {
            head.store(old_head->next);
            delete old_head;
        }
    }

  private:
    node* pop_head() {
        node* const res = head.load();
        if (res == tail.load()) {
            return nullptr;
        }
        head.store(res->next);
        return res;
    }

  public:
    bool empty() const {
        return head.load() == tail.load();
    }
    std::shared_ptr<value_type> pop() {
        node* old_head = pop_head();
        if (nullptr == old_head) {
            return nullptr;
        } else {
            auto res = old_head->data;
            delete old_head;
            return res;
        }
    }
    void push(value_type new_value) {
        auto new_data = std::make_shared<value_type>(new_value);
        node* p = new node;
        node* old_tail = tail.load();
        old_tail->data.swap(new_data);
        old_tail->next = p;
        tail_.store(p);
    }
};

#endif  // QUEUE_LOCK_FREE_QUEUE_HPP_



================================================
FILE: c-cpp/09_queue/ring_queue.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

struct ring_queue {
	int cap;
	int head, tail;
	int *_q;
};

int alloc_queue(struct ring_queue* queue, int cap)
{
	if (!queue || cap < 0)
		return -1;
	if (queue->_q)
		return -1;

	queue->_q = (int *)malloc(cap * sizeof(int));
	if (!queue->_q)
		return -1;

	queue->head = queue->tail = 0;
	queue->cap = cap;
	return 0;
}

void free_queue(struct ring_queue *queue)
{
	queue->cap = 0;
	queue->head = queue->tail = 0;
	free(queue->_q);
}

int _valid_index(int curr, int step, int cap)
{
	return (curr + step) % cap;
}

int _next(int curr, int cap)
{
	return _valid_index(curr, 1, cap);
}

bool is_empty(struct ring_queue *queue)
{
	return (queue->head == queue->tail);
}

bool is_full(struct ring_queue *queue)
{
	int next_tail = _next(queue->tail, queue->cap);
	return (next_tail == queue->head);
}

int enqueue(struct ring_queue* queue, int elem)
{
	if (is_full(queue))
		return -1;

	queue->_q[queue->tail] = elem;
	queue->tail = _next(queue->tail, queue->cap);
	return 0;
}

int dequeue(struct ring_queue* queue, int *elem)
{
	if (is_empty(queue))
		return -1;

	if (elem)
		*elem = queue->_q[queue->head];
	queue->head = _next(queue->head, queue->cap);
	return 0;
}

int size(struct ring_queue* queue)
{
	int size = queue->tail - queue->head;

	if (size < 0)
		size += queue->cap;
	return size;
}

void dump(struct ring_queue* queue)
{
	int i, idx;

	printf("Queue has %d elements with %d capacity\n",
		size(queue), queue->cap);
	for (i = 0; i < size(queue); i++) {
		idx = _valid_index(queue->head, i, queue->cap);
		printf("[%02d]: %08d\n", idx, queue->_q[idx]);
	}
}

int main()
{
	struct ring_queue queue = {0, 0, 0, NULL};
	int i;

	if (alloc_queue(&queue, 8)) {
		printf("Failed to allocate a queue\n");
		return -1;
	}

	printf("A new queue is %s\n", is_empty(&queue)?"empty":"not empty");

	enqueue(&queue, 1);
	printf("After enqueue 1 element, queue is %s\n", is_empty(&queue)?"empty":"not empty");
	dequeue(&queue, NULL);
	printf("After dequeue 1 element, queue is %s\n", is_empty(&queue)?"empty":"not empty");

	for (i = 0; i < 7; i++)
		enqueue(&queue, i);
	printf("After enqueue 7 element, queue is %s\n", is_full(&queue)?"full":"not full");

	for (i = 0; i < 4; i++) {
		dequeue(&queue, NULL);
		enqueue(&queue, i);
	}
	printf("After enqueue/dequeue 4 element, queue is %s\n",
			is_full(&queue)?"full":"not full");
	printf("Head is %d, Tail is %d\n", queue.head, queue.tail);

	dump(&queue);
	free_queue(&queue);
	return 0;
}


================================================
FILE: c-cpp/10_recursive/.gitkeep
================================================


================================================
FILE: c-cpp/10_recursive/one_two_step.c
================================================
/*************************************************************************
 > File Name: one_two_step.c
 > Author:  jinshaohui
 > Mail:    jinshaohui789@163.com
 > Time:    18-10-19
 > Desc:    
 ************************************************************************/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

/*爬楼梯的问题,解决重复计算,采用数据保存方法*/

int helper(int n ,int *vlaue)
{

    if(vlaue[n] != 0)
	{
		return vlaue[n];
	}

    vlaue[n] = helper(n - 1,vlaue) + helper(n - 2,vlaue);

	return vlaue[n];
}

int climbStaris(int n)
{
	int *vlaue = NULL;
	int res = 0;

	vlaue = (int *)malloc(sizeof(int)*(n+1));
	if(vlaue == NULL)
	{
		return -1;
	}

	memset(vlaue,0,sizeof(int)*(n + 1));
    vlaue[0] = 0;
	vlaue[1] = 1;
	vlaue[2] = 2;
    res = helper(n,vlaue);
	free(vlaue);

	return res;
}

int main()
{

	printf("\r\nnum%d ,%d",5,climbStaris(5));
	printf("\r\nnum%d ,%d",6,climbStaris(6));
	printf("\r\nnum%d ,%d",7,climbStaris(7));
	return 0;
}




================================================
FILE: c-cpp/10_recursive/one_two_step.cc
================================================
#include <iostream>
#include <unordered_map>

class SolutionOFOneTwoStep {
  private:
    static std::unordered_map<size_t, size_t> result_;

  public:
    enum class POLICY {
        RECURSIVE,
        NONRECURSIVE
    };

  private:
    size_t recursive(size_t steps) {
        auto iter = result_.find(steps);
        if (result_.end() != iter) {  // found.
            return iter->second;
        } else {
            size_t res = operator()(steps - 1) + operator()(steps - 2);
            result_.insert({steps, res});
            return res;
        }
    }
    size_t nonrecursive(size_t steps) {
        auto iter = result_.find(steps);
        if (result_.end() != iter) {  // found.
            return iter->second;
        } else {
            size_t start;
            for (start = steps; start != 2 and result_.end() == result_.find(start); --start) {}
            for (size_t i = start; i != steps; ++i) {
                result_.insert({i + 1, result_[i - 1] + result_[i]});
            }
            return result_[steps];
        }
    }

  public:
    size_t operator()(size_t steps, const POLICY policy = POLICY::RECURSIVE) {
        if (policy == POLICY::RECURSIVE) {
            return recursive(steps);
        } else if (policy == POLICY::NONRECURSIVE) {
            return nonrecursive(steps);
        }
    }
    static void debug() {
        for (auto kv : result_) {
            std::cout << kv.first << ' ' << kv.second << std::endl;
        }
        std::cout << std::endl;
    }
};

std::unordered_map<size_t, size_t> SolutionOFOneTwoStep::result_ = {{1, 1}, {2, 2}};

int main() {
    SolutionOFOneTwoStep::debug();

    std::cout << SolutionOFOneTwoStep()(5, SolutionOFOneTwoStep::POLICY::RECURSIVE) << std::endl;
    SolutionOFOneTwoStep::debug();

    std::cout << SolutionOFOneTwoStep()(10, SolutionOFOneTwoStep::POLICY::NONRECURSIVE) << std::endl;
    SolutionOFOneTwoStep::debug();

    std::cout << SolutionOFOneTwoStep()(20, SolutionOFOneTwoStep::POLICY::RECURSIVE) << std::endl;
    SolutionOFOneTwoStep::debug();

    return 0;
}



================================================
FILE: c-cpp/11_sorts/.gitkeep
================================================


================================================
FILE: c-cpp/11_sorts/sorts.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

struct array {
	int size;
	int used;
	int *arr;
};

void dump(struct array *array)
{
	int idx;
	
	for (idx = 0; idx < array->used; idx++)
		printf("[%02d]: %08d\n", idx, array->arr[idx]);
}

void alloc(struct array *array)
{
	array->arr = (int *)malloc(array->size * sizeof(int));
}

void bubble_sort(struct array *array)
{
	int i, j;

	if (array->used <= 1)
		return;

	for (i = 0; i < array->used; i++) {
		bool has_swap = false;
		for (j = 0; j < array->used - i - 1; j++) {
			if (array->arr[j] > array->arr[j+1]) {
				int tmp;
				tmp = array->arr[j];
				array->arr[j] = array->arr[j+1];
				array->arr[j+1] = tmp;
				has_swap = true;
			}

		}
		if (!has_swap)
			break;
	}
}

void bubble_sort_test()
{
	int idx;
	struct array ten_int = {10, 0, NULL};

	alloc(&ten_int);
	for (idx = 0; idx < 10; idx++)
		ten_int.arr[idx] = 30 - idx;
	ten_int.used = 10;
	dump(&ten_int);
	bubble_sort(&ten_int);
	dump(&ten_int);
}

void insertion_sort(struct array *array)
{
	int i, j;

	if (array->used <= 1)
		return;

	for (i = 1; i < array->used; i++) {
		int val = array->arr[i];

		for (j = i - 1; j >= 0; j--) {
			if (val < array->arr[j])
				array->arr[j+1] = array->arr[j]; 
			else
				break;
		}
		array->arr[j+1] = val;
	}
}

void insertion_sort_test()
{
	int idx;
	struct array ten_int = {10, 0, NULL};

	alloc(&ten_int);
	for (idx = 0; idx < 10; idx++)
		ten_int.arr[idx] = 30 - idx;
	ten_int.used = 10;
	dump(&ten_int);
	insertion_sort(&ten_int);
	dump(&ten_int);
}

void selection_sort(struct array *array)
{
	int i, j;

	if (array->used <= 1)
		return;

	for (i = 0; i < array->used - 1; i++) {
		int tmp, idx = i;

		for (j = i + 1; j < array->used; j++)
			if (array->arr[j] < array->arr[idx])
				idx = j;

		if (idx == i)
			continue;

		tmp = array->arr[i];
		array->arr[i] = array->arr[idx];
		array->arr[idx] = tmp;
	}
}

void selection_sort_test()
{
	int idx;
	struct array ten_int = {10, 0, NULL};

	alloc(&ten_int);
	for (idx = 0; idx < 10; idx++)
		ten_int.arr[idx] = 30 - idx;
	ten_int.used = 10;
	dump(&ten_int);
	selection_sort(&ten_int);
	dump(&ten_int);
}

int main()
{
	//bubble_sort_test();
	//selection_sort_test();
	insertion_sort_test();
	return 0;
}


================================================
FILE: c-cpp/11_sorts/sorts.cpp
================================================
// C program for implementation of selection sort 
#include <stdio.h> 

void swap(int *xp, int *yp) 
{ 
	int temp = *xp; 
	*xp = *yp; 
	*yp = temp; 
} 

void selectionSort(int arr[], int n) 
{ 
	int i, j, min_idx; 

	// One by one move boundary of unsorted subarray 
	for (i = 0; i < n-1; i++) 
	{ 
		// Find the minimum element in unsorted array 
		min_idx = i; 
		for (j = i+1; j < n; j++) 
		if (arr[j] < arr[min_idx]) 
			min_idx = j; 

		// Swap the found minimum element with the first element 
		swap(&arr[min_idx], &arr[i]); 
	} 
} 

/* Function to print an array */
void printArray(int arr[], int size) 
{ 
	int i; 
	for (i=0; i < size; i++) 
		printf("%d ", arr[i]); 
	printf("\n"); 
} 

// Driver program to test above functions 
int main() 
{ 
	int arr[] = {64, 25, 12, 22, 11}; 
	int n = sizeof(arr)/sizeof(arr[0]); 
	selectionSort(arr, n); 
	printf("Sorted array: \n"); 
	printArray(arr, n); 
	return 0; 
} 


================================================
FILE: c-cpp/11_sorts/sorts.hpp
================================================
/**
 * Created by Liam Huang (Liam0205) on 2018/10/16.
 */

#ifndef SORTS_SORTS_HPP_
#define SORTS_SORTS_HPP_

#include <iterator>
#include <functional>

template <typename BidirIt,
          typename BinaryPred = std::less<typename std::iterator_traits<BidirIt>::value_type>>
void bubble_sort(BidirIt first, BidirIt last, BinaryPred comp = BinaryPred()) {
    if (std::distance(first, last) <= 1) { return; }
    bool flag = true;
    for (auto it = first; flag and it != last; ++it) {
        flag = false;
        for (auto itt = first; itt != last - std::distance(first, it) - 1; ++itt) {
            if (comp(*(itt + 1), *itt)) {
                std::swap(*itt, *(itt + 1));
                flag = true;
            }
        }
    }
}

template <typename BidirIt,
          typename BinaryPred = std::less<typename std::iterator_traits<BidirIt>::value_type>>
void insertion_sort(BidirIt first, BidirIt last, BinaryPred comp = BinaryPred()) {
    if (std::distance(first, last) <= 1) { return; }
    for (auto it = first + 1; it != last; ++it) {
        const auto target = *it;
        auto       itt    = it;
        for (; std::distance(first, itt) > 0 and comp(target, *(itt - 1)); --itt) {
            *itt = *(itt - 1);
        }
        *itt = target;
    }
}

template <typename BidirIt,
          typename BinaryPred = std::less<typename std::iterator_traits<BidirIt>::value_type>>
void selection_sort(BidirIt first, BidirIt last, BinaryPred comp = BinaryPred()) {
    if (std::distance(first, last) <= 1) { return; }
    for (auto it = first; it != last - 1; ++it) {
        auto tag = it;
        for (auto itt = it + 1; itt != last; ++itt) {
            if (comp(*itt, *tag)) {
                tag = itt;
            }
        }
        if (tag != it) {
            std::swap(*it, *tag);
        }
    }
}

template <typename FrwdIt,
          typename BinaryPred = std::less<typename std::iterator_traits<FrwdIt>::value_type>>
void bubble_down_sort(FrwdIt first, FrwdIt last, BinaryPred comp = BinaryPred()) {
    if (std::distance(first, last) <= 1) { return; }
    for (auto it = first; it != last; ++it) {
        for (auto itt = it + 1; itt != last; ++itt) {
            if (comp(*itt, *it)) {
                std::swap(*it, *itt);
            }
        }
    }
}

template <typename BidirIt,
          typename BinaryPred = std::less<typename std::iterator_traits<BidirIt>::value_type>>
void shell_sort(BidirIt first, BidirIt last, BinaryPred comp = BinaryPred()) {
    const size_t len = std::distance(first, last);
    if (len <= 1) { return; }
    for (size_t step = len / 2; step >= 1; step /= 2) {
        for (auto it = first + step; it != last; ++it) {
            auto target = *it;
            auto itt    = it - step;
            for (; std::distance(first, itt) >= 0 and comp(target, *itt); itt -= step) {
                *(itt + step) = *itt;
            }
            *(itt + step) = target;
        }
    }
}

#endif  // SORTS_SORTS_HPP_



================================================
FILE: c-cpp/11_sorts/sorts_jinshaohui.c
================================================
/*************************************************************************
 > File Name: sorts_jinshaohui.c
 > Author:  jinshaohui
 > Mail:    jinshaohui789@163.com
 > Time:    18-10-19
 > Desc:    
 ************************************************************************/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define SWAP(a,b) \
do{\
	(a) ^= (b);\
	(b) ^= (a);\
	(a) ^= (b);\
}while(0)

/*冒泡排序*/
void bubble_sort(int a[],int size)
{
	int i = 0;
	int j = 0;
	int swap_flg = 0;

	if (size < 1)
	{
		return;
	}

	for (i = size - 1; i > 0; i--)/*排序的趟数*/
	{
		swap_flg = 0;/*每次设置交换标识为0*/
		for (j = 0; j < i; j++)/*本趟排序的遍历元素个数*/
		{
			if (a[j] > a[j + 1])
			{
				SWAP(a[j],a[j+1]);
				swap_flg = 1;
			}
		}
        /*本趟数,无数据交换的话,说明已经有序,直接退出*/
		if (swap_flg == 0)
		{
			break;
		}
	}
	return;
}

/*插入排序*/
void insert_sort(int a[],int size)
{
	int i = 0;
	int j = 0;
	int key = 0;

	for (i = 1; i < size; i ++)/*需要插入的元素个数*/
	{
		key = a[i];/*保存插入的元素数据*/
		j = i - 1;
        /* i 之前的元素都是有序的,找到比key小的插入到他后面,
		 * 比key大的,需要往后挪一个位置*/
		while((j >= 0) && (a[j] > key))
		{
		    a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = key;
	}

    return;
}
/*选择排序*/
void select_sort(int a[],int size)
{
	int i = 0;
	int j = 0;
	int min = 0;

	for (i = 0; i < size - 1; i++) 
	{
		min = i;
        for (j = i + 1; j < size; j++)
		{
			if (a[j] < a[min])
			{
				min = j;
			}
		}

		if (min != i)
		{
			SWAP(a[i],a[min]);
		}
	}
	return;
}

void dump(int a[],int size)
{
	int i = 0;

	printf("\r\n");
	for (i = 0; i < size; i++ )
	{
		printf("%d ",a[i]);
	}
	printf("\r\n");
    return;
}

int main()
{
	int a[10] = {9,11,4,15,16,3,20,44,5,10};

    //bubble_sort(a,sizeof(a)/sizeof(int));
    //insert_sort(a,sizeof(a)/sizeof(int));
    select_sort(a,sizeof(a)/sizeof(int));
    
    dump(a,sizeof(a)/sizeof(int));

	return 0;
}


================================================
FILE: c-cpp/11_sorts/sorts_test.cc
================================================
#include <iostream>
#include <vector>

#include "sorts.hpp"

int main() {
    const std::vector<int> test_data{1, 2, 3, 0};

    std::vector<int> a(test_data.begin(), test_data.end());
    bubble_sort(a.begin(), a.end());
    for (auto i : a) {
        std::cout << i << ' ';
    }
    std::cout << '\n';

    std::vector<int> b(test_data.begin(), test_data.end());
    insertion_sort(b.begin(), b.end());
    for (auto i : b) {
        std::cout << i << ' ';
    }
    std::cout << '\n';

    std::vector<int> c(test_data.begin(), test_data.end());
    selection_sort(c.begin(), c.end());
    for (auto i : c) {
        std::cout << i << ' ';
    }
    std::cout << '\n';

    std::vector<int> d(test_data.begin(), test_data.end());
    bubble_down_sort(d.begin(), d.end());
    for (auto i : d) {
        std::cout << i << ' ';
    }
    std::cout << '\n';

    std::vector<int> e(test_data.begin(), test_data.end());
    shell_sort(e.begin(), e.end());
    for (auto i : e) {
        std::cout << i << ' ';
    }
    std::cout << '\n';

    return 0;
}


================================================
FILE: c-cpp/12_sorts/.gitkeep
================================================


================================================
FILE: c-cpp/12_sorts/merge_sort.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

void dump(int *arr, int size)
{
	int idx;

	for (idx = 0; idx < size; idx++)
		printf("%08d\n", arr[idx]);
}

void __merge(int *arr, int p, int q, int r)
{
	int *tmp;
	int i, j, k;

	tmp = (int*)malloc((r - p + 1) * sizeof(int));

	if (!tmp)
		abort();

	for (i = p, j = q + 1, k = 0; i <= q && j <= r;) {
		if (arr[i] <= arr[j])
			tmp[k++] = arr[i++];
		else
			tmp[k++] = arr[j++];
	}

	if (i == q + 1) {
		for (; j <= r;)
			tmp[k++] = arr[j++];
	} else {
		for (; i <= q;)
			tmp[k++] = arr[i++];
	}

	memcpy(arr + p, tmp, (r - p + 1) * sizeof(int));
	free(tmp);
}

void __merge_sort(int *arr, int p, int r)
{
	int q;

	if (p >= r)
		return;

	q = (p + r) / 2;
	__merge_sort(arr, p, q);
	__merge_sort(arr, q + 1, r);
	__merge(arr, p, q, r);
}

void merge_sort(int *arr, int size)
{
	__merge_sort(arr, 0, size - 1);
}

void merge_verify()
{
	int test[10] = {5, 8, 9, 23, 67, 1, 3, 7, 31, 56};

	__merge(test, 0, 4, 9);

	dump(test, 10);
}

void merge_sort_test()
{
	int test[10] = {5, 8, 9, 23, 67, 1, 3, 7, 31, 56};

	merge_sort(test, 10);

	dump(test, 10);
}

int main()
{
	//merge_verify();
	merge_sort_test();
	return 0;
}


================================================
FILE: c-cpp/12_sorts/merge_sort.hpp
================================================
/**
 * Created by Liam Huang (Liam0205) on 2018/10/17.
 */

#ifndef SORTS_MERGE_SORT_HPP_
#define SORTS_MERGE_SORT_HPP_

#include <functional>
#include <algorithm>
#include <iterator>
#include <vector>

namespace detail {
template <typename InputIt1, typename InputIt2, typename OutputIt,
          typename BinaryPred = std::less<typename std::iterator_traits<InputIt1>::value_type>>
OutputIt merge(InputIt1 first1, InputIt1 last1,
               InputIt2 first2, InputIt2 last2,
               OutputIt d_first,
               BinaryPred comp = BinaryPred()) {
    for (; first1 != last1; ++d_first) {
        if (first2 == last2) {
            return std::copy(first1, last1, d_first);
        }
        if (comp(*first2, *first1)) {
            *d_first = *first2;
            ++first2;
        } else {
            *d_first = *first1;
            ++first1;
        }
    }
    return std::copy(first2, last2, d_first);
}
}  // namespace detail

template <typename FrwdIt,
          typename BinaryPred = std::less<typename std::iterator_traits<FrwdIt>::value_type>>
void merge_sort(FrwdIt first, FrwdIt last, BinaryPred comp = BinaryPred()) {
    const auto len = std::distance(first, last);
    if (len <= 1) { return; }
    auto cut = first + len / 2;
    merge_sort(first, cut, comp);
    merge_sort(cut, last, comp);
    std::vector<typename std::iterator_traits<FrwdIt>::value_type> tmp;
    tmp.reserve(len);
    detail::merge(first, cut, cut, last, std::back_inserter(tmp), comp);
    std::copy(tmp.begin(), tmp.end(), first);
}

template <typename BidirIt,
          typename BinaryPred = std::less<typename std::iterator_traits<BidirIt>::value_type>>
void inplace_merge_sort(BidirIt first, BidirIt last, BinaryPred comp = BinaryPred()) {
    const auto len = std::distance(first, last);
    if (len <= 1) { return; }
    auto cut = first + len / 2;
    inplace_merge_sort(first, cut, comp);
    inplace_merge_sort(cut, last, comp);
    std::inplace_merge(first, cut, last, comp);
}

#endif  // SORTS_MERGE_SORT_HPP_



================================================
FILE: c-cpp/12_sorts/merge_sort_test.cc
================================================
/**
 * Created by Liam Huang (Liam0205) on 2018/10/17.
 */

#include <iostream>
#include <vector>
#include "merge_sort.hpp"

int main() {
    const std::vector<int> test_data{0, -1, 3, 190, -500};

    std::vector<int> a{test_data};
    merge_sort(a.begin(), a.end());
    for (auto i : a) {
        std::cout << i << ' ';
    }
    std::cout << std::endl;

    std::vector<int> b{test_data};
    inplace_merge_sort(b.begin(), b.end());
    for (auto i : b) {
        std::cout << i << ' ';
    }
    std::cout << std::endl;

    return 0;
}



================================================
FILE: c-cpp/12_sorts/my12_sorts/merge_sort.c
================================================
/*************************************************************************
 > File Name: merge_sort.c
 > Author:  jinshaohui
 > Mail:    jinshaohui789@163.com
 > Time:    18-10-19
 > Desc:    
 ************************************************************************/
#include<stdio.h>
#include<assert.h>
#include<string.h>
#include<stdlib.h>

#define SORT_MAX  (1000000)

void dump(int a[],int size);
void merge_sentry(int a[],int middle,int left,int right)
{
	int *pleft = NULL;
	int *pright = NULL;
	int i = 0;
	int j = 0;
	int k = 0;
	int left_size = middle - left + 1;
	int right_size = right - middle;

	
	pleft = (int *)malloc(sizeof(int)*(left_size + 1));
	assert(pleft != NULL);
	pright = (int *)malloc(sizeof(int)*(right_size + 1));
	assert(pright != NULL);

	for(i = 0; i < left_size; i ++)
	{
		pleft[i] = a[left + i];
	}
	pleft[left_size] = SORT_MAX;
	for(i = 0; i < right_size; i ++)
	{
		pright[i] = a[middle + 1 + i];
	}
	pright[right_size] = SORT_MAX;

    for (k = left,i = 0,j = 0; k <= right; k++)
	{
		if (pleft[i] <= pright[j])
		{
			a[k] = pleft[i++];
		}
		else
		{
			a[k] = pright[j++];
		}
	}

	free(pleft);
	free(pright);

    return;
}

/*两个有序数组合并*/
void merge(int a[],int middle,int left,int right)
{
    int *tmp = NULL;
	int i = 0;
	int j = 0;
	int k = 0;

	tmp = (int*)malloc((right - left + 1)*sizeof(int));
    assert(tmp != NULL);

	i = left;
	j = middle + 1;

	while(1)
	{
	    if((i > middle) || (j > right))
	    {
			break;
	    }

		if (a[i] > a[j])
		{
			tmp[k++] = a[j++];
		}
		else
		{
			tmp[k++] = a[i++];
		}
	}

	if (i > middle)
	{
		while(j <= right)
		{
			tmp[k++] = a[j++];
		}
	}
	else
	{
		while(i <= middle)
		{
			tmp[k++] = a[i++];
		}
	}

	memcpy((a + left),tmp,(right - left + 1)*sizeof(int));

	free(tmp);

	return  ;
}

void merge_sort(int a[],int left,int right)
{
    int middle = 0;

	if(left >= right)
	{
		return;
	}

	middle = (left + right)/2;

	merge_sort(a,left,middle);
	merge_sort(a,middle + 1,right);

    merge_sentry(a,middle,left,right);

	return;
}

void dump(int a[],int size)
{
	int i = 0;

	if(size == 0)
	{
		return;
	}

	printf("\r\n");
	for (i = 0; i < size; i++ )
	{
		printf("%d ",a[i]);
	}
	printf("\r\n");
    return;
}
int main()
{
    int a[10] = {30,20,10,15,4,8,40,80,20,9};
    
	merge_sort(a,0,9);

	dump(a,10);

	return 0;
}



================================================
FILE: c-cpp/12_sorts/my12_sorts/quick_sort.c
================================================
/*************************************************************************
 > File Name: quick_sort.c
 > Author:  jinshaohui
 > Mail:    jinshaohui789@163.com
 > Time:    18-10-19
 > Desc:    
 ************************************************************************/
#include<stdio.h>
#include<assert.h>
#include<string.h>
#include<stdlib.h>

/* SWAP 使用必须主要,不能是同一个数据进行交换*/
#define SWAP(a,b) \
do{\
	(a) ^= (b);\
	(b) ^= (a);\
	(a) ^= (b);\
}while(0)

int partition2(int a[],int left,int right)
{
   int i = left;
   int j = left;

   for(; j <  right;j++)
   {
	   if (a[j] < a[right])
	   {
		   if(i != j)
		   {
			   SWAP(a[i],a[j]);
		   }
		   i++;
	   }
   }

   if(i != right)
   {
       SWAP(a[i],a[right]);
   }

   return i;
}

int partition(int a[],int left,int right)
{
   int i = left;
   int j = right;
   int key = a[left];

   while(i < j)
   {
	   while((i < j)&& (a[j] >= key))
	   {
		   j--;
	   }
	   if (i < j)
	   {
		   a[i] = a[j];
	   }
	   while((i < j) && a[i] <= key)
	   {
		   i++;
	   }

	   if (i<j)
	   {
		   a[j] = a[i];
	   }
   }
   a[i] = key;

   return i;
}

void quick_sort(int a[],int left,int right)
{
	int q = 0;
	/*递归终止条件*/
	if (left >= right)
	{
		return;
	}

	q = partition2(a,left,right);
	quick_sort(a,left,(q - 1));
	quick_sort(a,(q + 1),right);
	return;
}

void dump(int a[],int size)
{
	int i = 0;

	printf("\r\n");
	for (i = 0; i < size; i++ )
	{
		printf("%d ",a[i]);
	}
	printf("\r\n");
    return;
}

int helper(int a[],int left,int right,int k)
{
	int q = 0;

	q = partition(a,left,right);

	if (q > (k - 1))
	{
		return helper(a,left,q-1,k);
	}
	else if (q < (k - 1))
	{
		return helper(a,q+1,right,k);
	}

	return a[q];
}

/*求无序数组中从小到大第K个元素的数值*/
int findKthlagest(int a[],int size,int k)
{
	return helper(a,0,size-1,k);
}


int main()
{
    int a[10] = {30,20,10,15,4,8,40,80,20,9};
    int k;

	scanf("%d",&k);

	printf("\r\n从小到大排序,第%d个元素数值是%d",k,findKthlagest(a,10,k));

	quick_sort(a,0,9);

	dump(a,10);

	return 0;
}



================================================
FILE: c-cpp/12_sorts/quick_sort.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

void dump(int *arr, int size)
{
	int idx;

	for (idx = 0; idx < size; idx++)
		printf("%08d\n", arr[idx]);
}

void swap(int *a, int *b)
{
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int partition(int *arr, int p, int r)
{
	//int pivot = arr[r];
	int i, j;

	i = j = p;

	for (; j < r; j++) {
		if (arr[j] < arr[r]) {
			if(i != j)
			{
			swap(arr + i, arr + j);

			}
			i++;
		}
	}
	
	swap(arr + i, arr + r);
	return i;
}

void __quick_sort(int *arr, int p, int r)
{
	int q;

	if (p >= r)
		return;

	q = partition(arr, p, r);
	__quick_sort(arr, p, q-1);
	__quick_sort(arr, q+1, r);
}

void quick_sort(int *arr, int size)
{
	__quick_sort(arr, 0, size - 1);
}

void quick_sort_test()
{
	int test[10] = {5, 8, 9, 23, 67, 1, 3, 7, 31, 56};

	quick_sort(test, 10);

	dump(test, 10);
}

int main()
{
	quick_sort_test();
	return 0;
}


================================================
FILE: c-cpp/12_sorts/quick_sort.hpp
================================================
/**
 * Created by Liam Huang (Liam0205) on 2018/10/17.
 */

#ifndef SORTS_QUICK_SORT_HPP_
#define SORTS_QUICK_SORT_HPP_

#include <functional>
#include <iterator>
#include <algorithm>
#include <utility>

namespace detail {
template <typename T, typename Compare = std::less<T>>
const T& median(const T& a, const T& b, const T& c, Compare comp = Compare()) {
    if (comp(a, b) and comp(b, c) or comp(c, b) and comp(b, a)) {
        return b;
    } else if (comp(b, c) and comp(c, a) or comp(a, c) and comp(c, b)) {
        return c;
    } else {
        return a;
    }
}

template <typename Iter,
          typename T = typename std::iterator_traits<Iter>::value_type,
          typename Compare = std::less<T>>
const T& iter_median(Iter a, Iter b, Iter c, Compare comp = Compare()) {
    return median(*a, *b, *c, comp);
}

template <typename BidirIt,
          typename T = typename std::iterator_traits<BidirIt>::value_type,
          typename Compare = std::less<T>>
std::pair<BidirIt, BidirIt> inplace_partition(BidirIt first,
                                              BidirIt last,
                                             const T& pivot,
                                           Compare comp = Compare()) {
    BidirIt last_less, last_greater, first_equal, last_equal;
    for (last_less = first, last_greater = first, first_equal = last;
                                         last_greater != first_equal; ) {
        if (comp(*last_greater, pivot)) {
            std::iter_swap(last_greater++, last_less++);
        } else if (comp(pivot, *last_greater)) {
            ++last_greater;
        } else {  // pivot == *last_greater
            std::iter_swap(last_greater, --first_equal);
        }
    }
    const auto cnt = std::distance(first_equal, last);
    std::swap_ranges(first_equal, last, last_less);
    first_equal    = last_less;
    last_equal     = first_equal + cnt;
    return {first_equal, last_equal};
}
}  // namespace detail

template <typename BidirIt,
          typename T = typename std::iterator_traits<BidirIt>::value_type,
          typename Compare = std::less<T>>
void quick_sort(BidirIt first, BidirIt last, Compare comp = Compare()) {
    for (auto size = std::distance(first, last); size > 1; size = std::distance(first, last)) {
        const T pivot = detail::iter_median(first, last - 1, first + size / 2, comp);
        const auto eq = detail::inplace_partition(first, last, pivot, comp);
        quick_sort(first, eq.first, comp);
        first = eq.second;  // Liam Huang: economize half of recursive calling.
    }
}

#endif  // SORTS_QUICK_SORT_HPP_



================================================
FILE: c-cpp/12_sorts/quick_sort_test.cc
================================================
/**
 * Created by Liam Huang (Liam0205) on 2018/10/17.
 */

#include <iostream>
#include <vector>
#include <algorithm>

#include "quick_sort.hpp"

void test_quick_sort(std::vector<int> test_data) {
    quick_sort(test_data.begin(), test_data.end());
    std::transform(test_data.begin(), test_data.end(),
            std::ostream_iterator<int>(std::cout, " "), [](int i){ return i; });
    std::cout << '\n';
}

int main() {
    test_quick_sort({-3, -1, 1, -2, -3, 0, -3, 100, 1, 1, -100});
    test_quick_sort({1, 1, 1});
    test_quick_sort({1, 0, -1});
    test_quick_sort({1});
    return 0;
}



================================================
FILE: c-cpp/13_sorts/.gitkeep
================================================


================================================
FILE: c-cpp/13_sorts/bucket_sort.hpp
================================================
/**
 * Created by Liam Huang (Liam0205) on 2018/10/26.
 */

#ifndef SORTS_BUCKET_SORT_HPP_
#define SORTS_BUCKET_SORT_HPP_

#include <iterator>
#include <functional>
#include <algorithm>
#include <vector>

template <size_t BucketSize,
          typename IterT,
          typename T = typename std::iterator_traits<IterT>::value_type,
          typename Compare = std::less<T>>
void bucket_sort(IterT first, IterT last, Compare comp = Compare()) {
    const T min = *std::min_element(first, last), max = *std::max_element(first, last);
    const T range = max + 1 - min;
    const size_t bucket_num = (range - 1) / BucketSize + 1;

    std::vector<std::vector<T>> buckets(bucket_num);
    for (auto b : buckets) {
        b.reserve(2 * BucketSize);
    }

    for (IterT i = first; i != last; ++i) {
        size_t idx = (*i - min) / BucketSize;
        buckets[idx].emplace_back(*i);
    }

    IterT dest = first;
    for (auto b : buckets) {
        std::sort(b.begin(), b.end(), comp);
        std::copy(b.begin(), b.end(), dest);
        dest += b.size();
    }

    return;
}

#endif  // SORTS_BUCKET_SORT_HPP_



================================================
FILE: c-cpp/13_sorts/bucket_sort_test.cc
================================================
/**
 * Created by Liam Huang (Liam0205) on 2018/10/26.
 */

#include <iostream>
#include <vector>
#include <functional>

#include "bucket_sort.hpp"

template <size_t BucketSize,
          typename Container,
          typename T = typename Container::value_type,
          typename Compare = std::less<T>>
void test_bucket_sort(Container cont, Compare comp = Compare()) {
    bucket_sort<BucketSize>(cont.begin(), cont.end(), comp);
    std::transform(cont.begin(), cont.end(), std::ostream_iterator<T>(std::cout, " "),
            [](T i){ return i; });
    std::cout << std::endl;
}

int main() {
    std::vector<int> test{3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9};

    test_bucket_sort<2>(test);  // 1 1 2 3 3 4 5 5 5 6 7 8 9 9 9
    test_bucket_sort<3>(test);  // 1 1 2 3 3 4 5 5 5 6 7 8 9 9 9
    test_bucket_sort<4>(test);  // 1 1 2 3 3 4 5 5 5 6 7 8 9 9 9
    test_bucket_sort<5>(test);  // 1 1 2 3 3 4 5 5 5 6 7 8 9 9 9
    test_bucket_sort<6>(test);  // 1 1 2 3 3 4 5 5 5 6 7 8 9 9 9

    return 0;
}



================================================
FILE: c-cpp/13_sorts/counting_sort.hpp
================================================
/**
 * Created by Liam Huang (Liam0205) on 2018/10/26.
 */

#ifndef SORTS_COUNTING_SORT_HPP_
#define SORTS_COUNTING_SORT_HPP_

#include <iterator>
#include <functional>
#include <algorithm>
#include <vector>

template <typename IterT,
          typename T = typename std::iterator_traits<IterT>::value_type>
void counting_sort(IterT first, IterT last) {
    const auto len = std::distance(first, last);
    if (len < 2) { return; }

    const T max = *std::max_element(first, last);
    if (max == 0) { return; }

    std::vector<size_t> counter(max + 1);
    for (IterT i = first; i != last; ++i) {
        ++counter[*i];
    }
    for (size_t i = 1; i != max + 1; ++i) {
        const size_t j = max - i;
        counter[j] += counter[j + 1];  // Liam Huang: count of numbers that is not less than j.
    }

    std::vector<T> temp(len);
    for (IterT i = first; i != last; ++i) {
        temp[len - counter[*i]] = *i;
        --counter[*i];                 // Liam Huang: stable for relative position.
    }
    std::copy(temp.begin(), temp.end(), first);
}

#endif  // SORTS_COUNTING_SORT_HPP_



================================================
FILE: c-cpp/13_sorts/counting_sort_test.cc
================================================
/**
 * Created by Liam Huang (Liam0205) on 2018/10/26.
 */

#include <iostream>
#include <vector>
#include <functional>

#include "counting_sort.hpp"

template <typename Container,
          typename T = typename Container::value_type>
void test_counting_sort(Container cont) {
    counting_sort(cont.begin(), cont.end());
    std::transform(cont.begin(), cont.end(), std::ostream_iterator<T>(std::cout, " "),
            [](T i){ return i; });
    std::cout << std::endl;
}

int main() {
    // Liam Huang: pi for test
    const std::vector<int> test1{3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3};
    const std::vector<int> test2{2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9};
    const std::vector<int> test3{5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9};
    const std::vector<int> test4{3, 7, 5, 1, 0, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4};
    const std::vector<int> test5{5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6};

    test_counting_sort(test1);  // 1 1 2 3 3 3 4 5 5 5 6 7 8 9 9 9
    test_counting_sort(test2);  // 2 2 2 3 3 3 3 4 4 6 6 7 8 8 9
    test_counting_sort(test3);  // 0 1 1 2 3 4 5 6 7 8 8 9 9 9 9
    test_counting_sort(test4);  // 0 0 1 2 3 4 4 4 5 5 7 7 8 9 9
    test_counting_sort(test5);  // 0 0 1 2 2 3 4 5 6 6 6 7 8 8 9

    return 0;
}



================================================
FILE: c-cpp/13_sorts/sort.c
================================================
/*************************************************************************
 > File Name: sort.c
 > Author:  jinshaohui
 > Mail:    jinshaohui789@163.com
 > Time:    18-10-20
 > Desc:    
 ************************************************************************/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<assert.h>

void dump(int a[],int size)
{
	int i = 0;

	printf("\r\n");

	for(i = 0; i <size; i++)
	{
		printf("%d ",a[i]);
	}
	printf("\r\n");
}

/*计数排序,时间复杂度0(n),非原地排序
 *计数排序也是利用桶排序的解决方式
 * 如果数组最大值max比数组大小size大很多不适合;
 * 计数排序要求时非负整数
 * */
void count_sort(int a[],int size)
{
	int i = 0;
	int max = 0;
	int *count = 0;
	int *res = 0;

	/*找到最大数*/
	for (i = 0 ; i< size; i++)
	{
		if (a[i] > max)
		{
			max = a[i];
		}
	}

	count = (int *)malloc(sizeof(int)*(max + 1));
	assert(count != NULL);

	memset(count,0,sizeof(int)*(max + 1));

	/*计数*/
	for (i = 0; i < size;i++)
	{
		count[a[i]]++;
	}
	
	/*依次累加*/
	for(i = 1 ;i <= max; i ++)
	{
		count[i] += count[i-1];
	}

	res = (int *)malloc(sizeof(int)*(size));
	assert(res != NULL);
    /*核心代码,count[a[i] - 1]就是排序好的下标*/
	for (i = size-1;i >= 0; i--)
	{
		res[count[a[i]] -1] = a[i];
		count[a[i]]--;
	}
    
	memcpy(a,res,size*(sizeof(int)));

	free(res);
	free(count);
	return;
}


int count_sort_test()
{
	int a [10]={1,5,6,8,10,9,3,1,2,1};
    printf("\r\n conunt sort test ....");
	count_sort(a,10);
	dump(a,10);

	return 0;
}

#define NUM_OF_POS(a,pval) ((a)/pval)%10
void radix_sort(int a[],int size,int num_count)
{
	int count[10] = {0}; /*计数*/
	int *pres = NULL;
	int i = 0;
	int j = 0;
	int pval = 10;
	int index = 0;
	int break_flg = 0;

	pres = (int *)malloc(sizeof(int)*size);
	assert(pres != NULL);

	for (i = 0; i < num_count; i ++)
	{
		memset(count,0,sizeof(int)*10);

		/*求当前的基数*/
        pval = pow(10,i);

	    /*计数*/
		for (j = 0; j < size; j++)
		{
			index = NUM_OF_POS(a[j],pval);
			count[index]++;
		}

		/*小的优化,可能位数最大的就1,其他的位数差很多*/
		if(count[0] == 9)
		{
			break_flg++;
		}

		if(break_flg >=2)
		{
			printf("\r\n %i",i);
			break;
		}

		/*累加*/
		for(j = 1; j < 10; j ++)
		{
			count[j] += count[j-1];
		}

		/*排序必须从后往前,否则不是稳定排序*/
		for(j = size -1; j >= 0; j--)
		{
			index = NUM_OF_POS(a[j],pval);
            pres[count[index] - 1] = a[j];
			count[index]--;
		}
        /*本轮排序好的,拷贝到a中*/
		memcpy(a,pres,sizeof(int)*size);
	}

	return;
}

void radix_sort_test()
{
	int a[10] = {123,12341,1232134,124,236,128,1112313129,98,9,8989};
    printf("\r\n radix sort test.....");
	radix_sort(a,10,10);
	dump(a,10);
	return;
}

struct barrel {   
    int node[10];   
    int count;/* the num of node */  
};   
int partition(int a[],int left,int right)
{
   int i = left;
   int j = right;
   int key = a[left];

   while(i < j)
   {
	   while((i < j)&& (a[j] >= key))
	   {
		   j--;
	   }
	   if (i < j)
	   {
		   a[i] = a[j];
	   }
	   while((i < j) && a[i] <= key)
	   {
		   i++;
	   }

	   if (i<j)
	   {
		   a[j] = a[i];
	   }
   }
   a[i] = key;

   return i;
}

void quick_sort(int a[],int left,int right)
{
	int q = 0;
	/*递归终止条件*/
	if (left >= right)
	{
		return;
	}

	q = partition(a,left,right);
	quick_sort(a,left,(q - 1));
	quick_sort(a,(q + 1),right);
	return;
}
  
void bucket_sort(int data[], int size)   
{   
    int max, min, num, pos;   
    int i, j, k;   
    struct barrel *pBarrel;   
  
    max = min = data[0];   
    for (i = 1; i < size; i++) {   
        if (data[i] > max) {   
            max = data[i];   
        } else if (data[i] < min) {   
            min = data[i];   
        }   
    }   
    num = (max - min + 1) / 10 + 1;   
    pBarrel = (struct barrel*)malloc(sizeof(struct barrel) * num);   
    memset(pBarrel, 0, sizeof(struct barrel) * num);   
  
    /* put data[i] into barrel which it belong to */  
    for (i = 0; i < size; i++) {   
        k = (data[i] - min + 1) / 10;/* calculate the index of data[i] in barrel */  
        (pBarrel + k)->node[(pBarrel + k)->count] = data[i];   
        (pBarrel + k)->count++;   
    }   
       
    pos = 0;   
    for (i = 0; i < num; i++) {
		if ((pBarrel + i)->count != 0)
		{
            quick_sort((pBarrel+i)->node, 0, ((pBarrel+i)->count)-1);/* sort node in every barrel */  
  
            for (j = 0; j < (pBarrel+i)->count; j++) {   
                data[pos++] = (pBarrel+i)->node[j];   
            }
		}
    }   
    free(pBarrel);   
}

void bucket_sort_test()
{
	int a[] = {78, 17, 39, 26, 72, 94, 21, 12, 23, 91};   
    int size = sizeof(a) / sizeof(int);   
	printf("\r\n bucket sort test ...");
    bucket_sort(a, size); 
	dump(a,size);
	
}

int main()
{
    count_sort_test();

	radix_sort_test();

	bucket_sort_test();
	return 0;
}


================================================
FILE: c-cpp/14_sorts/.gitkeep
================================================


================================================
FILE: c-cpp/14_sorts/analytics_of_std_sort.md
================================================
# C++ STL 中的 std::sort 分析

参见 [Liam Huang 的博客](https://liam.page/)中的 3 篇文章:

* [谈谈基于比较的排序算法的复杂度下界](https://liam.page/2018/08/28/lower-bound-of-comparation-based-sort-algorithm/)
* [谈谈内省式排序算法](https://liam.page/2018/08/29/introspective-sort/)
* [谈谈 STL 中的 std::sort](https://liam.page/2018/09/18/std-sort-in-STL/)



================================================
FILE: c-cpp/14_sorts/counting_sort.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

void dump(int *arr, int size)
{
	int i;

	for (i = 0; i < size; i++)
		printf("%08d\n", arr[i]);
}

// content in arr must be positive integer
void counting_sort(int *arr, int size)
{
	int max, i;
	int *count, *tmp;

	if (size <= 1)
		return;

	max = 0;
	// find the biggest integer
	for (i = 0; i < size; i++) {
		if (max < arr[i])
			max = arr[i];
	}

	// init count to 0
	count = (int*)malloc((max+1) * sizeof(int));
	tmp = (int*)malloc(size * sizeof(int));
	if (!count || !tmp)
		return;
	memset(count, 0, (max + 1) * sizeof(int));

	// counting
	for (i = 0; i < size; i++)
		count[arr[i]]++;
	for (i = 1; i < max + 1; i++)
		count[i] = count[i-1] + count[i];

	// iterate arr and put it to the correct index in tmp
	for (i = 0; i < size; i++){
		int index = count[arr[i]] - 1;
		tmp[index] = arr[i];
		count[arr[i]]--;
	}

	// move back to arr
	memcpy(arr, tmp, size * sizeof(int));
}

void counting_sort_test()
{
	int test_data[10] = {3, 23, 98, 1, 27, 36, 52, 89, 76, 44};

	counting_sort(test_data, 10);
	dump(test_data, 10);
}

int main()
{
	counting_sort_test();
	return 0;
}


================================================
FILE: c-cpp/15_bsearch/.gitkeep
================================================


================================================
FILE: c-cpp/15_bsearch/binary_search.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

typedef int(*bs)(int *arr, int size, int val); 

int binary_search_r(int *arr, int size, int val)
{
	int mid = size / 2;
	int idx;

	if (arr[mid] == val)
		return mid;

	// mid == 0 means size == 1
	// so the only element in array doesn't equal to val
	if (!mid)
		return -1;

	if (arr[mid] < val) {
		idx = binary_search_r(arr + mid + 1, size - mid - 1, val);
		if (idx != -1)
			idx += mid + 1;
	} else {
		idx = binary_search_r(arr, mid, val);
	}

	return idx;
}

int binary_search_i(int *arr, int size, int val)
{
	int low = 0, high = size - 1, mid;

	while (low <= high) {
		mid = (low + high) / 2;
		if (arr[mid] == val)
			return mid;

		if (arr[mid] < val)
			low = mid + 1;
		else
			high = mid - 1;
	}

	return -1;
}

void iteratioin_test(bs binary_search)
{
	int arr[10] = {1, 4, 5, 9, 12, 19, 21, 28, 31, 36};
	int idx;

	idx = binary_search(arr, 10, 12);
	if (idx != -1)
		printf("find 12 at %d\n", idx);
	else
		printf("12 not in arr \n");

	idx = binary_search(arr, 10, 13);
	if (idx != -1)
		printf("find 13 at %d\n", idx);
	else
		printf("13 not in arr \n");

	idx = binary_search(arr, 10, 1);
	if (idx != -1)
		printf("find 1 at %d\n", idx);
	else
		printf("1 not in arr \n");

	idx = binary_search(arr, 10, 36);
	if (idx != -1)
		printf("find 36 at %d\n", idx);
	else
		printf("36 not in arr \n");

	idx = binary_search(arr, 10, 31);
	if (idx != -1)
		printf("find 31 at %d\n", idx);
	else
		printf("31 not in arr \n");

}

int main()
{
	printf("=== Test iteration version:\n");
	iteratioin_test(binary_search_i);

	printf("=== Test recursive version:\n");
	iteratioin_test(binary_search_r);

	return 0;
}


================================================
FILE: c-cpp/15_bsearch/bsearch.hpp
================================================
/**
 * Created by Liam Huang (Liam0205) on 2018/10/24.
 */

#ifndef BSEARCH_BSEARCH_HPP_
#define BSEARCH_BSEARCH_HPP_

#include <iterator>
#include <functional>

// Liam Huang: The algorithm works right with iterators that meet the ForwardIterator requirement,
//             but with a bad time complexity. For better performance, iterators should meet
//             the RandomAccessIterator requirement.
template <typename IterT,
          typename ValueT = typename std::iterator_traits<IterT>::value_type,
          typename Compare = std::less<ValueT>>
IterT bsearch(IterT first,
              IterT last,
             ValueT target,
            Compare comp = Compare()) {
    IterT result = last;
    while (std::distance(first, last) > 0) {
        IterT mid = first + std::distance(first, last) / 2;
        if (comp(*mid, target)) {
            first = mid + 1;
        } else if (comp(target, *mid)) {
            last = mid;
        } else {  // equal
            result = mid;
            break;
        }
    }
    return result;
}

#endif  // BSEARCH_BSEARCH_HPP_



================================================
FILE: c-cpp/15_bsearch/bsearch_c/bsearch.c
================================================
/*************************************************************************
 > File Name: bsearch.c
 > Author:  jinshaohui
 > Mail:    jinshaohui789@163.com
 > Time:    18-10-21
 > Desc:    
 ************************************************************************/
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>


int mybsearch(int a[],int size,int value)
{
	int mid = 0;
	int left = 0;
	int right = size - 1;

	while(left <= right)
	{
		/*防止size数量太大是,(left + right)数据翻转,导致问题*/
		mid = left + ((right - left)>>1);

		if (a[mid] == value)
		{
			return mid;
		}
		else if (a[mid] < value)
		{
			left = mid + 1;
		}
		else
		{
			right = mid - 1;
		}
	}

	return -1;
}

int helper(int a[], int left,int right,int value)
{
	int mid = 0;

	if (left > right)
	{
		return -1;
	}
	/*防止size数量太大是,(left + right)数据翻转,导致问题*/
	mid = left + ((right - left)>>1);
	if (a[mid] == value)
	{
		return mid;
	}
	else if (a[mid] < value)
	{
		return helper(a,mid + 1,right,value);
	}
	else
	{
		return helper(a,left,mid - 1,value);
	}
    return -1;
}
/*递归实现*/
int mybsearch_2(int a[],int size,int value)
{

	return helper(a,0,size-1,value);
}

int main()
{
	int a[10] = {5,6,8,9,10,11,23,42,53,123};
    int data = 0;
	int res = 0;

	printf("\r\n输入一个整数");
	scanf("%d",&data);
    res = mybsearch(a,10,data);
	printf("data[%d] %s 在数据中,下标是%d",data,(res != -1)?"":"不",res);
	
	printf("\r\n输入一个整数");
	scanf("%d",&data);
    res = mybsearch_2(a,10,data);
	printf("data[%d] %s 在数据中,下标是%d",data,(res != -1)?"":"不",res);
	return;
}


================================================
FILE: c-cpp/15_bsearch/bsearch_c/sqrt.c
================================================
/*************************************************************************
 > File Name: sqrt.c
 > Author:  jinshaohui
 > Mail:    jinshaohui789@163.com
 > Time:    18-10-31
 > Desc:    
 ************************************************************************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<assert.h>


/*求解精度设置*/
#define E 0.000001 
double mybsearch(double num)
{
	double start = 1.0;
	double end = num;
    double mid = 0.0;
	while(1)
	{
	    mid = (start + end)/2;
        if(((mid*mid - num) <= E) && ((mid*mid - num) >= -E))
		{
			return mid;
		}

		if ((mid*mid - num) > E)
		{
			end = mid;
		}
		else
		{
			start = mid;
		}
 	}

	return 0;
}
	

int main()
{
	double num = 0.0;

	/*这里需要注意:double的输入方式*/
	scanf("%lf",&num);
	printf("\r\n num %lf的平方根是%lf",num,mybsearch(num));

	return 0;
}



================================================
FILE: c-cpp/15_bsearch/bsearch_test.cc
================================================
/**
 * Created by Liam Huang (Liam0205) on 2018/10/24.
 */

#include <iostream>
#include <vector>

#include "bsearch.hpp"

template <typename VecT, typename T = typename VecT::value_type>
void test_bsearch(const VecT& test, T target) {
    auto it = bsearch(test.begin(), test.end(), target);
    std::cout << std::distance(test.begin(), it) << std::endl;
}

int main() {
    std::vector<int> test{0, 0, 1, 2, 3, 4, 4, 5, 5, 5, 5, 5, 6, 7};  // std::less<int>()

    test_bsearch(test, 8);                        // 14
    test_bsearch(test, -1);                       // 14
    test_bsearch(test, 0);                        // 0, 1
    test_bsearch(test, 4);                        // 5, 6
    test_bsearch(test, 5);                        // 7, 8, 9, 10, 11
    test_bsearch(test, 7);                        // 13

    return 0;
}



================================================
FILE: c-cpp/16_bsearch/.gitkeep
================================================


================================================
FILE: c-cpp/16_bsearch/bsearch.c
================================================
/*************************************************************************
 > File Name: bsearch.c
 > Author:  jinshaohui
 > Mail:    jinshaohui789@163.com
 > Time:    18-10-21
 > Desc:    
 ************************************************************************/
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>

/*二分查找算法的变形问题
 *1、查找第一个等于给定数值的元素
 *2、查找最后一个等于给定数值的元素
 *3、查找第一个大于等于给定数值的元素
 *4、查找第一个小于等于给定数值的元素
 * */


 /*1、查找第一个等于给定数值的元素*/
int mybsearch_1(int a[],int size,int value)
{
	int mid = 0;
	int left = 0;
	int right = size - 1;

	while(left <= right)
	{
		/*防止size数量太大是,(left + right)数据翻转,导致问题*/
		mid = left + ((right - left)>>1);

		if (a[mid] < value)
		{
			left = mid + 1;
		}
		else if (a[mid] > value)
		{
			right = mid - 1;
		}
		else
		{
			if ((mid == 0) || (a[mid - 1] != value))
			{
                return mid;
			}
			else
			{
				right = mid - 1;
			}
		}
	}

	return -1;
}

 /*2、查找最后一个等于给定数值的元素*/
int mybsearch_2(int a[],int size,int value)
{
	int mid = 0;
	int left = 0;
	int right = size - 1;

	while(left <= right)
	{
		/*防止size数量太大是,(left + right)数据翻转,导致问题*/
		mid = left + ((right - left)>>1);

		if (a[mid] < value)
		{
			left = mid + 1;
		}
		else if (a[mid] > value)
		{
			right = mid - 1;
		}
		else
		{
			if ((mid == (size - 1)) || (a[mid + 1] != value))
			{
                return mid;
			}
			else
			{
				left = mid + 1;
			}
		}
	}

	return -1;
}
 /*3、查找第一个大于等于给定数值的元素*/
int mybsearch_3(int a[],int size,int value)
{
	int mid = 0;
	int left = 0;
	int right = size - 1;

	while(left <= right)
	{
		/*防止size数量太大是,(left + right)数据翻转,导致问题*/
		mid = left + ((right - left)>>1);

		if (a[mid] < value)
		{
			left = mid + 1;
		}
		else
		{
			/*a[mid] >= value 当mid==0 或者a[mid-1] > value 说明是第一个大于等于value*/
			if ((mid == 0) || (a[mid - 1] < value))
			{
                return mid;
			}
			else
			{
				right = mid - 1;
			}
		}
	}

	return -1;
}

 /*4、查找第一个小于等于给定数值的元素*/
int mybsearch_4(int a[],int size,int value)
{
	int mid = 0;
	int left = 0;
	int right = size - 1;

	while(left <= right)
	{
		/*防止size数量太大是,(left + right)数据翻转,导致问题*/
		mid = left + ((right - left)>>1);

		if (a[mid] > value)
		{
			right = mid - 1;
		}
		else
		{
			/*a[mid] <= value 时,当前mid == size -1 数组中最大的数值;
			 *                    或者a[mid + 1] 大于vlaue,就是mid就第一个小于等于value*/
			if ((mid == (size - 1)) || (a[mid + 1] > value))
			{
                return mid;
			}
			else
			{
				left = mid + 1;
			}
		}
	}

	return -1;
}
int main()
{
	int a[10] = {5,6,6,9,10,11,11,22,33,33};
    int data = 0;
	int i = 0;
	int res =0;

	printf("\r\n");
    for(i = 0; i < 10 ; i++)
	{
		printf("%d ",a[i]);
	}
	printf("\r\n");
	printf("\r\n输入一个整数");
	scanf("%d",&data);
    res = mybsearch_1(a,10,data);
	printf("第一个等于data[%d],下标是%d",data,res);
	
	printf("\r\n输入一个整数");
	scanf("%d",&data);
    res = mybsearch_2(a,10,data);
	printf("最后一个等于data[%d],下标是%d",data,res);

	printf("\r\n输入一个整数");
	scanf("%d",&data);
    res = mybsearch_2(a,10,data);
	printf("第一个大于等于data[%d],下标是%d",data,res);

	printf("\r\n输入一个整数");
	scanf("%d",&data);
    res = mybsearch_2(a,10,data);
	printf("第一个小等于data[%d],下标是%d",data,res);
	return;
}


================================================
FILE: c-cpp/16_bsearch/bsearch_variant.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>


int binary_search(int *arr, int size, int val)
{
	int low = 0, high = size - 1, mid;

	while (low <= high) {
		mid = (low + high) / 2;
		if (arr[mid] == val)
			return mid;

		if (arr[mid] < val)
			low = mid + 1;
		else
			high = mid - 1;
	}

	return -1;
}

/* 
 * find the first index with *val*
 *
 * This is a little tricky because the calculation of mid is integer based, it
 * will be cast to the lower bound of an integer.
 * 
 * In case the [low, high] range is of size 1 or 2 and arr[mid] >= val, we will
 * have:
 *
 * mid = (low + high) / 2 = low
 * high = mid - 1 = low - 1 < low, which break the loop
 *
 */
int binary_search_first(int *arr, int size, int val)
{
	int low = 0, high = size - 1, mid;

	while (low <= high) {
		mid = (low + high) / 2;
		//printf("[%d-%d] %d\n", low, high, mid);

		if (arr[mid] >= val)
			high = mid - 1;
		else
			low = mid + 1;
	}

	//printf("[%d-%d] %d\n", low, high, mid);
	if (arr[low] == val)
		return low;
	else
		return -1;
}

int binary_search_last(int *arr, int size, int val)
{
	int low = 0, high = size - 1, mid;

	while (low <= high) {
		mid = (low + high) / 2;

		if (arr[mid] <= val)
			low = mid + 1;
		else
			high = mid - 1;
	}

	if (arr[high] == val)
		return high;
	else
		return -1;
}

int binary_search_first_r(int *arr, int size, int val)
{
	int mid = size / 2;
	int idx;

	if (size <= 0)
		return -1;

	// we find *val* at mid, try first half
	if (arr[mid] == val) {
		idx = binary_search_first_r(arr, mid, val);
		return idx != -1 ? idx : mid;
	}

	// mid == 0 means size == 1
	// so the only element in array doesn't equal to val
	if (!mid)
		return -1;

	if (arr[mid] < val) {
		idx = binary_search_first_r(arr + mid + 1, size - mid - 1, val);
		if (idx != -1)
			idx += mid + 1;
	} else {
		idx = binary_search_first_r(arr, mid, val);
	}

	return idx;
}

int binary_search_last_r(int *arr, int size, int val)
{
	int mid = size / 2;
	int idx;

	if (size <= 0)
		return -1;

	// we find *val* at mid, try last half
	if (arr[mid] == val) {
		idx = binary_search_last_r(arr+mid+1, size-mid-1, val);
		if (idx != -1)
			mid += idx + 1;
		return mid;
	}

	// mid == 0 means size == 1
	// so the only element in array doesn't equal to val
	if (!mid)
		return -1;

	if (arr[mid] < val) {
		idx = binary_search_last_r(arr + mid + 1, size - mid - 1, val);
		if (idx != -1)
			idx += mid + 1;
	} else {
		idx = binary_search_last_r(arr, mid, val);
	}

	return idx;
}

int binary_search_first_bigger(int *arr, int size, int val)
{
	int low = 0, high = size - 1, mid;

	while (low <= high) {
		mid = (low + high) / 2;

		if (arr[mid] >= val) {
			if (mid == 0 || arr[mid-1] < val)
				return mid;
			high = mid - 1;
		} else {
			low = mid + 1;
		}
	}

	return -1;
}

int binary_search_first_bigger_r(int *arr, int size, int val)
{
	int mid = size / 2;
	int idx;

	if (size <= 0)
		return -1;

	if (arr[mid] >= val) {
		// find one bigger than val, try first half
		idx = binary_search_first_bigger_r(arr, mid, val);
		if (idx == -1)
			idx = mid;
	} else {
		// the bigger one may sit in second half
		idx = binary_search_first_bigger_r(arr + mid + 1, size - mid - 1, val);
		if (idx != -1)
			idx += mid + 1;
	}

	return idx;
}

int binary_search_last_smaller(int *arr, int size, int val)
{
	int low = 0, high = size - 1, mid;

	while (low <= high) {
		mid = (low + high) / 2;

		if (arr[mid] <= val) {
			if (mid == 0 || arr[mid+1] > val)
				return mid;
			low = mid + 1;
		} else {
			high = mid - 1;
		}
	}

	return -1;
}

int binary_search_last_smaller_r(int *arr, int size, int val)
{
	int mid = size / 2;
	int idx;

	if (size <= 0)
		return -1;

	if (arr[mid] <= val) {
		// find one smaller than val, try second half
		idx = binary_search_last_smaller_r(arr + mid + 1, size - mid - 1, val);
		if (idx != -1)
			idx += mid + 1;
		else
			idx = mid;
	} else {
		// the smaller one may sit in first half
		idx = binary_search_last_smaller_r(arr, mid, val);
	}

	return idx;
}

int main()
{
	int arr[10] = {1, 4, 5, 9, 12, 14, 19, 19, 31, 36};
	int idx;

	printf("Test Array:\n");
	for (idx = 0; idx < 10; idx++)
		printf("%8d", arr[idx]);
	printf("\n");

	idx = binary_search_first(arr, 10, 19);
	if (idx != -1)
		printf("first 19 at %d\n", idx);
	else
		printf("19 not in arr \n");

	idx = binary_search_first_r(arr, 10, 19);
	if (idx != -1)
		printf("first 19 at %d\n", idx);
	else
		printf("19 not in arr \n");

	idx = binary_search_last(arr, 10, 19);
	if (idx != -1)
		printf("last 19 at %d\n", idx);
	else
		printf("19 not in arr \n");

	idx = binary_search_last_r(arr, 10, 19);
	if (idx != -1)
		printf("last 19 at %d\n", idx);
	else
		printf("19 not in arr \n");

	idx = binary_search_first_bigger(arr, 10, 12);
	if (idx != -1)
		printf("first bigger 12 at %d\n", idx);
	else
		printf("12 not in arr \n");

	idx = binary_search_first_bigger_r(arr, 10, 12);
	if (idx != -1)
		printf("first bigger 12 at %d\n", idx);
	else
		printf("12 not in arr \n");

	idx = binary_search_last_smaller(arr, 10, 12);
	if (idx != -1)
		printf("last smaller 12 at %d\n", idx);
	else
		printf("12 not in arr \n");

	idx = binary_search_last_smaller_r(arr, 10, 12);
	if (idx != -1)
		printf("last smaller 12 at %d\n", idx);
	else
		printf("12 not in arr \n");

	return 0;
}


================================================
FILE: c-cpp/16_bsearch/bsearch_varients.hpp
================================================
/**
 * Created by Liam Huang (Liam0205) on 2018/10/26.
 */

#ifndef BSEARCH_BSEARCH_VARIENTS_HPP_
#define BSEARCH_BSEARCH_VARIENTS_HPP_

#include <iterator>
#include <functional>

enum class BsearchPolicy { UNSPECIFIED, FIRST, LAST, FIRST_NOT_LESS, LAST_NOT_GREATER };

// Liam Huang: The algorithm works right with iterators that meet the ForwardIterator requirement,
//             but with a bad time complexity. For better performance, iterators should meet
//             the RandomAccessIterator requirement.
template <typename IterT,
          typename ValueT = typename std::iterator_traits<IterT>::value_type,
          typename Compare>
IterT bsearch(IterT first,
              IterT last,
             ValueT target,
            Compare comp,
      BsearchPolicy policy = BsearchPolicy::UNSPECIFIED) {
    IterT result = last;
    while (std::distance(first, last) > 0) {
        IterT mid = first + std::distance(first, last) / 2;
        if (policy == BsearchPolicy::FIRST_NOT_LESS) {
            if (!comp(*mid, target)) {
                if (mid == first or comp(*(mid - 1), target)) {
                    result = mid;
                    break;
                } else {
                    last = mid;
                }
            } else {
                first = mid + 1;
            }
        } else if (policy == BsearchPolicy::LAST_NOT_GREATER) {
            if (comp(target, *mid)) {
                last = mid;
            } else {
                if (std::distance(mid, last) == 1 or comp(target, *(mid + 1))) {
                    result = mid;
                    break;
                } else {
                    first = mid + 1;
                }
            }
        } else {  // policy == UNSPECIFIED or FIRST or LAST
            if (comp(*mid, target)) {
                first = mid + 1;
            } else if (comp(target, *mid)) {
                last = mid;
            } else {  // equal
                if (policy == BsearchPolicy::FIRST) {
                    if (mid == first or comp(*(mid - 1), *mid)) {
                        result = mid;
                        break;
                    } else {
                        last = mid;
                    }
                } else if (policy == BsearchPolicy::LAST) {
                    if (std::distance(mid, last) == 1 or comp(*mid, *(mid + 1))) {
                        result = mid;
                        break;
                    } else {
                        first = mid + 1;
                    }
                } else {
                    result = mid;
                    break;
                }
            }
        }
    }
    return result;
}

template <typename IterT,
          typename ValueT = typename std::iterator_traits<IterT>::value_type,
          typename Compare = std::less<ValueT>>
IterT bsearch(IterT first,
              IterT last,
             ValueT target,
      BsearchPolicy policy = BsearchPolicy::UNSPECIFIED) {
	return bsearch(first, last, target, Compare(), policy);
}

#endif  // BSEARCH_BSEARCH_VARIENTS_HPP_



================================================
FILE: c-cpp/16_bsearch/bsearch_varients_test.cc
================================================
/**
 * Created by Liam Huang (Liam0205) on 2018/10/26.
 */

#include <iostream>
#include <vector>

#include "bsearch_varients.hpp"

template <typename VecT, typename T = typename VecT::value_type>
void test_bsearch(const VecT& test,
                            T target,
                BsearchPolicy policy = BsearchPolicy::UNSPECIFIED) {
    auto it = bsearch(test.begin(), test.end(), target, policy);
    std::cout << std::distance(test.begin(), it) << std::endl;
}

int main() {
    std::vector<int> test{0, 0, 1, 2, 3, 4, 4, 5, 5, 5, 5, 5, 6, 8};  // std::less<int>()

    test_bsearch(test, 8);                                   // 14
    test_bsearch(test, -1);                                  // 14
    test_bsearch(test, 0);                                   // 0, 1
    test_bsearch(test, 0, BsearchPolicy::FIRST);             // 0
    test_bsearch(test, 0, BsearchPolicy::LAST);              // 1
    test_bsearch(test, 4);                                   // 5, 6
    test_bsearch(test, 4, BsearchPolicy::FIRST);             // 5
    test_bsearch(test, 4, BsearchPolicy::LAST);              // 6
    test_bsearch(test, 5);                                   // 7, 8, 9, 10, 11
    test_bsearch(test, 5, BsearchPolicy::FIRST);             // 7
    test_bsearch(test, 5, BsearchPolicy::LAST);              // 11
    test_bsearch(test, 7, BsearchPolicy::FIRST_NOT_LESS);    // 13
    test_bsearch(test, 7, BsearchPolicy::LAST_NOT_GREATER);  // 12
    test_bsearch(test, 7, BsearchPolicy::FIRST);             // 14
    test_bsearch(test, 8);                                   // 13
    test_bsearch(test, 8, BsearchPolicy::FIRST);             // 13
    test_bsearch(test, 8, BsearchPolicy::LAST);              // 13

    return 0;
}



================================================
FILE: c-cpp/17_skiplist/.gitkeep
================================================


================================================
FILE: c-cpp/17_skiplist/SkipList.cpp
================================================
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <cstring>
#include <random>
#include <ctime>
using namespace std;

/**
 * һʵַ
 * д洢Ҵ洢Dzظġ
 *
 * C++汾.
 * JAVA汾 ԭ AuthorZHENG
 * 
 * Authorpuhuaqiang
 * 
 *  ṹ:
 * 
 *  K           1           9
 *  K-1         1     5     9
 *  K-2         1  3  5  7  9
 *  ...             ....
 *  0(ԭʼ)  1  2  3  4  5  6  7  8  9
 */

const int MAX_LEVEL = 16;

/**
 * @brief ڵ
*/
class CNode
{
public:
    CNode();
    ~CNode();

    std::string toString();
    /**
     * @brief ȡ
    */
    CNode** GetIdxList();

    /**
     * @brief 
    */
    void SetData(int v);
    /**
     * @brief ȡ
    */
    int GetData();
    /**
    * @brief 
    */
    void SetLevel(int l);
private:
    /**ǰڵֵ*/
    int m_data;
    /** 
     * ǰڵÿȼһڵ.
     * 2 N1 N2
     * 1 N1 N2
     * N1DZڵ, m_lpForwards[x] N2
     * 
     * [0] ԭʼ.
     */
    CNode* m_lpForwards[MAX_LEVEL];
    /**ǰڵڵ*/
    int m_iMaxLevel;
};

/**
 * @brief 
*/
class CSkipList
{
public:
    CSkipList();
    ~CSkipList();
    /**
     * @brief ֵָĽڵ
     * @param v 
    */
    CNode* Find(int v);
    /**
     * @brief ֵָ
     * @param v 
    */
    void Insert(int v);
    /**
     * @brief ɾֵָĽڵ
     * @param v 
    */
    int Delete(int v);
    void PrintAll();
    /**
     * @brief ӡṹ
     * @param l -1ʱӡмĽṹ >=0ʱӡָĽṹ
    */
    void PrintAll(int l);
    /**
     * @brief ڵʱ,õK
     * @return K
    */
    int RandomLevel();

private:
    int levelCount;
    /**
     * 
     * ͷ/(ڵ)
    */
    CNode* m_lpHead;
};

int main()
{
    CSkipList skipList;
    /// ԭʼֵ
    for(int i=1; i< 50; i++){
        if((i%3) == 0){
            skipList.Insert(i);
        }
    }
    for(int i=1; i< 50; i++){
        if((i%3) == 1){
            skipList.Insert(i);
        }
    }
    skipList.PrintAll();
    std::cout<<std::endl;
    /// ӡеȼṹ
    skipList.PrintAll(-1);
    /// 
    std::cout<<std::endl;
    CNode* lpNode = skipList.Find(27);
    if(NULL != lpNode){
        std::cout<<"ֵΪ27Ľڵ,ҵýڵ,ڵֵ:"<<lpNode->GetData()<<std::endl;
    }else{
        std::cout<<"ֵΪ27Ľڵ,δҵýڵ"<<std::endl;
    }
    /// ɾ
    std::cout<<std::endl;
    int ret = skipList.Delete(46);
    if(0 == ret){
        std::cout<<"ֵΪ46Ľڵ,ҵýڵ,ɾɹ"<<std::endl;
    }else{
        std::cout<<"ֵΪ46Ľڵ,ҵýڵ,ɾʧ"<<std::endl;
    }
    std::cout<<std::endl;
    //ӡеȼṹ
    skipList.PrintAll(-1);
    std::cin.ignore();
    return 0;
}

CNode::CNode()
{
    m_data = -1;
    m_iMaxLevel = 0;
    for(int i=0; i<MAX_LEVEL; i++){
        m_lpForwards[i] = NULL;
    }
}
CNode::~CNode()
{

}
CNode** CNode::GetIdxList()
{
    return m_lpForwards;
}

void CNode::SetData(int v)
{
    m_data = v;
}
int CNode::GetData()
{
    return m_data;
}
void CNode::SetLevel(int l)
{
    m_iMaxLevel = l;
}
std::string CNode::toString()
{
    char tmp[32];
    std::string ret;

    ret.append("{ data: ");
    sprintf(tmp, "%d", m_data);
    ret.append(tmp);
    ret.append("; levels: ");
    sprintf(tmp, "%d", m_iMaxLevel);
    ret.append(tmp);
    ret.append(" }");
    return ret;
}

CSkipList::CSkipList()
{
    levelCount = 1;
    m_lpHead = new CNode();
}
CSkipList::~CSkipList()
{

}
CNode* CSkipList::Find(int v)
{
    CNode* lpNode = m_lpHead;
    /**
     *  ʼ.
     * K -> k-1 -> k-2 ...->0
    */
    for(int i=levelCount-1; i>=0; --i){
        /**
         * СvĽڵ(lpNode).
        */
        while((NULL != lpNode->GetIdxList()[i]) && (lpNode->GetIdxList()[i]->GetData() < v)){
            lpNode = lpNode->GetIdxList()[i];
        }
    }
    /**
     * lpNode СvĽڵ, lpNodeһڵ͵ڻvĽڵ
    */
    if((NULL != lpNode->GetIdxList()[0]) && (lpNode->GetIdxList()[0]->GetData() == v)){
        return lpNode->GetIdxList()[0];
    }
    return NULL;
}
void CSkipList::Insert(int v)
{
    /// ½ڵ
    CNode* lpNewNode = new CNode();
    if(NULL == lpNewNode){
        return;
    }

    /**
     * ½ڵֲڵ
     *  3, µĽڵ123ϵ
    */
    int level = RandomLevel();
    lpNewNode->SetData(v);
    lpNewNode->SetLevel(level);

    /**
     * ʱ
     * ҪǵõµĽڵÿϵλ
    */
    CNode *lpUpdateNode[level];
    for(int i=0; i<level; i++){
        /// ÿͷڵ
        lpUpdateNode[i] =m_lpHead;
    }
    CNode* lpFind = m_lpHead;
    for(int i= level-1; i >= 0; --i){
        /**
         * λ
         *   eg.  1  1  7  10
         *    6
         *   lpFind->GetIdxList()[i]->GetData() : ʾڵlpFindڵ1һڵ
         *    "lpFind->GetIdxList()[i]->GetData() < v"ʱ,
         *   ½ڵҪ뵽 lpFindڵĺ, lpFind->GetIdxList()[i] ڵǰ
         *    lpFind1  lpFind->GetIdxList()[i] 7
        */
        while((NULL != lpFind->GetIdxList()[i]) && (lpFind->GetIdxList()[i]->GetData() < v)){
            lpFind = lpFind->GetIdxList()[i];
        }
        /// lpFind ½ڵ iĺһڵ
        lpUpdateNode[i] = lpFind;
    }

    for(int i=0; i<level; ++i){
        /**
         * ָλ
         *   eg  1 1  7  10
         *      6.
         *      lpUpdateNode[i] ڵ1; lpUpdateNode[i]->GetIdxList()[i]ڵ7
         *  
         *  2 6 17֮
        */
        lpNewNode->GetIdxList()[i] = lpUpdateNode[i]->GetIdxList()[i];
        lpUpdateNode[i]->GetIdxList()[i] = lpNewNode;
    }
    if(levelCount < level){
        levelCount = level;
    }
}
int CSkipList::Delete(int v)
{
    int ret = -1;
    CNode *lpUpdateNode[levelCount];
    CNode *lpFind = m_lpHead;
    for(int i=levelCount-1; i>= 0; --i){
        /**
         * СvĽڵ(lpFind).
        */
        while((NULL != lpFind->GetIdxList()[i]) && (lpFind->GetIdxList()[i]->GetData() < v)){
            lpFind = lpFind->GetIdxList()[i];
        }
        lpUpdateNode[i] = lpFind;
    }
    /**
     * lpFind СvĽڵ, lpFindһڵ͵ڻvĽڵ
    */
    if((NULL != lpFind->GetIdxList()[0]) && (lpFind->GetIdxList()[0]->GetData() == v)){
        for(int i=levelCount-1; i>=0; --i){
            if((NULL != lpUpdateNode[i]->GetIdxList()[i]) && (v == lpUpdateNode[i]->GetIdxList()[i]->GetData())){
                lpUpdateNode[i]->GetIdxList()[i] = lpUpdateNode[i]->GetIdxList()[i]->GetIdxList()[i];
                ret = 0;
            }
        }
    }
    return ret;
}
void CSkipList::PrintAll()
{
    CNode* lpNode = m_lpHead;
    while(NULL != lpNode->GetIdxList()[0]){
        std::cout<<lpNode->GetIdxList()[0]->toString().data()<<std::endl;
        lpNode = lpNode->GetIdxList()[0];
    }
}
void CSkipList::PrintAll(int l)
{
    for(int i=MAX_LEVEL-1; i>=0;--i){
        CNode* lpNode = m_lpHead;
        std::cout<<""<<i<<":"<<std::endl;
        if((l < 0) || ((l >= 0) && (l == i))){
            while(NULL != lpNode->GetIdxList()[i]){
                std::cout<<lpNode->GetIdxList()[i]->GetData()<<" ";
                lpNode = lpNode->GetIdxList()[i];
            }
            std::cout<<std::endl;
            if(l >= 0){
                break;
            }
        }
    }
}
int GetRandom()
{
    static int _count = 1;
	std::default_random_engine generator(time(0) + _count);
	std::uniform_int_distribution<int> distribution(1,99999/*0x7FFFFFFF*/);
	int dice_roll = distribution(generator);
    _count += 100;
	return dice_roll;
}
int CSkipList::RandomLevel()
{
    int level = 1;
    for(int i=1; i<MAX_LEVEL; ++i){
        if(1 == (GetRandom()%3)){
            level++;
        }
    }
    return level;
}

================================================
FILE: c-cpp/17_skiplist/skiplist.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <time.h>

// https://www.youtube.com/watch?v=2g9OSRKJuzM&t=17s

#define MAX_LEVEL 15

struct node {
	int val;
	int max_level;
	struct node *forward[MAX_LEVEL];
};

struct skip_list {
	struct node head;
	int max_level;
	int max_level_nodes;
};

void node_init(struct node* node)
{
	memset(node, 0, sizeof(struct node));
}

void skip_list_init(struct skip_list* sl)
{
	node_init(&sl->head);
	sl->max_level = 0;
	sl->max_level_nodes = 0;
}

void random_init()
{
	static bool done = false;

	if (done)
		return;

	srandom(time(NULL));
	done = true;
}

int random_level(void)
{
    int i, level = 1;

    random_init();

    for (i = 1; i < MAX_LEVEL; i++)
	    if (random() % 2 == 1)
		    level++;

    return level;
}

void random_level_test()
{
	printf("random level %d\n", random_level());
	printf("random level %d\n", random_level());
	printf("random level %d\n", random_level());
	printf("random level %d\n", random_level());
	printf("random level %d\n", random_level());
}

void insert(struct skip_list *sl, int val)
{
	int level = random_level();
	struct node *update[MAX_LEVEL];
	struct node *new, *p;
	int i;

	new = (struct node*)malloc(sizeof(
Download .txt
gitextract_2921o4fk/

├── .gitignore
├── DynamicStackBaseArray.java
├── LICENSE
├── README.md
├── StackBaseArray.java
├── c-cpp/
│   ├── .gitignore
│   ├── .gitkeep
│   ├── 05_array/
│   │   ├── .gitkeep
│   │   ├── Array_gp.c
│   │   ├── Array_gp.h
│   │   └── array.c
│   ├── 06_linkedlist/
│   │   ├── .gitkeep
│   │   ├── Dlist/
│   │   │   ├── Dlist.c
│   │   │   └── Dlist.h
│   │   ├── LRUBasedLinkedList.cpp
│   │   ├── list_isPalindrome/
│   │   │   ├── LinkList.cpp
│   │   │   └── LinkList.h
│   │   ├── palindromeList/
│   │   │   ├── LinkedList.hpp
│   │   │   ├── ListNode.hpp
│   │   │   └── palindromeList.cpp
│   │   ├── single_list.c
│   │   └── singlelist_gc/
│   │       ├── singleList.c
│   │       └── singleList.h
│   ├── 07_linkedlist/
│   │   ├── .gitkeep
│   │   ├── LinkedListAlgo.c
│   │   ├── SingleList.cpp
│   │   ├── linked_list.h
│   │   ├── linked_list_algo.hpp
│   │   └── linklist_jinshaohui.c
│   ├── 08_stack/
│   │   ├── StackBasedOnArray/
│   │   │   ├── StackBasedOnArray.cpp
│   │   │   └── StackBasedOnArray.h
│   │   ├── StackBasedOnLinkedList/
│   │   │   ├── StackBasedOnLinkedList.cpp
│   │   │   └── StackBasedOnLinkedList.h
│   │   ├── arrayStack/
│   │   │   ├── arrayStack.c
│   │   │   └── arrayStack.h
│   │   ├── linkList/
│   │   │   ├── linklist_stack.c
│   │   │   └── linklist_stack.h
│   │   ├── linked_list.h
│   │   └── stack_based_on_linked_list.hpp
│   ├── 09_queue/
│   │   ├── .gitkeep
│   │   ├── array_queue/
│   │   │   ├── array_queue.c
│   │   │   └── array_queue.h
│   │   ├── array_queue.hpp
│   │   ├── array_queue_test.cc
│   │   ├── block_queue.hpp
│   │   ├── circular_queue.hpp
│   │   ├── circular_queue_test.cc
│   │   ├── concurrency_queue.hpp
│   │   ├── dynamic_array_queue.hpp
│   │   ├── dynamic_array_queue_test.cc
│   │   ├── linked_queue.hpp
│   │   ├── linked_queue_test.cc
│   │   ├── list_queue/
│   │   │   ├── list_queue.c
│   │   │   └── list_queue.h
│   │   ├── lock_free_queue.hpp
│   │   └── ring_queue.c
│   ├── 10_recursive/
│   │   ├── .gitkeep
│   │   ├── one_two_step.c
│   │   └── one_two_step.cc
│   ├── 11_sorts/
│   │   ├── .gitkeep
│   │   ├── sorts.c
│   │   ├── sorts.cpp
│   │   ├── sorts.hpp
│   │   ├── sorts_jinshaohui.c
│   │   └── sorts_test.cc
│   ├── 12_sorts/
│   │   ├── .gitkeep
│   │   ├── merge_sort.c
│   │   ├── merge_sort.hpp
│   │   ├── merge_sort_test.cc
│   │   ├── my12_sorts/
│   │   │   ├── merge_sort.c
│   │   │   └── quick_sort.c
│   │   ├── quick_sort.c
│   │   ├── quick_sort.hpp
│   │   └── quick_sort_test.cc
│   ├── 13_sorts/
│   │   ├── .gitkeep
│   │   ├── bucket_sort.hpp
│   │   ├── bucket_sort_test.cc
│   │   ├── counting_sort.hpp
│   │   ├── counting_sort_test.cc
│   │   └── sort.c
│   ├── 14_sorts/
│   │   ├── .gitkeep
│   │   ├── analytics_of_std_sort.md
│   │   └── counting_sort.c
│   ├── 15_bsearch/
│   │   ├── .gitkeep
│   │   ├── binary_search.c
│   │   ├── bsearch.hpp
│   │   ├── bsearch_c/
│   │   │   ├── bsearch.c
│   │   │   └── sqrt.c
│   │   └── bsearch_test.cc
│   ├── 16_bsearch/
│   │   ├── .gitkeep
│   │   ├── bsearch.c
│   │   ├── bsearch_variant.c
│   │   ├── bsearch_varients.hpp
│   │   └── bsearch_varients_test.cc
│   ├── 17_skiplist/
│   │   ├── .gitkeep
│   │   ├── SkipList.cpp
│   │   ├── skiplist.c
│   │   ├── skiplist.hpp
│   │   ├── skiplist_c/
│   │   │   ├── skiplist.c
│   │   │   └── skiplist.h
│   │   ├── skiplist_test.cc
│   │   ├── skiplist_tr.hpp
│   │   └── skiplist_tr_test.cc
│   ├── 18_hashtable/
│   │   ├── .gitkeep
│   │   ├── hash_map.cc
│   │   ├── hashtable.c
│   │   └── listhash/
│   │       ├── listhash.c
│   │       └── listhash.h
│   ├── 19_Dlisthash/
│   │   ├── Dlist.h
│   │   ├── LinkedHashMap.c
│   │   └── LinkedHashMap.h
│   ├── 23_binarytree/
│   │   ├── binarytree.c
│   │   └── tree/
│   │       ├── binarytree.c
│   │       ├── list_queue.c
│   │       └── list_queue.h
│   ├── 24_binarysearchtree/
│   │   ├── binary_search_tree.cpp
│   │   ├── binarysearchtree.c
│   │   ├── binarysearchtree.h
│   │   └── bst.c
│   ├── 24_tree/
│   │   ├── Trie.c
│   │   └── binarysearchtree.c
│   ├── 28_heap/
│   │   └── heap.c
│   ├── 30_Graph/
│   │   └── graph.c
│   └── bst.c
├── csharp/
│   ├── 05-array/
│   │   ├── Array.cs
│   │   └── algo05_array.csproj
│   ├── 06-linkedlist/
│   │   ├── LRUWithArray.cs
│   │   ├── LRUWithLinkedList.cs
│   │   ├── LRU缓存实现思路.txt
│   │   ├── SingleLinkedList.cs
│   │   └── algo06_linked_list.csproj
│   ├── 07-linkedlist/
│   │   └── _07_linkedlist/
│   │       ├── SingleLinkedListAlgo.cs
│   │       └── algo07_linkedlist.csproj
│   ├── 08-stack/
│   │   └── algo08_stack/
│   │       ├── ArrayStack.cs
│   │       ├── LinkedStack.cs
│   │       ├── LinkedStackBrowser.cs
│   │       └── algo08_stack.csproj
│   ├── Tests/
│   │   ├── _05_array_tests/
│   │   │   ├── Array.Tests.cs
│   │   │   └── algo05_array_tests.csproj
│   │   ├── _06_linkedlist_tests/
│   │   │   ├── BaseLinkedListTests.cs
│   │   │   ├── LRUWithArray.Tests.cs
│   │   │   ├── LRUWithLinkedList.Tests.cs
│   │   │   ├── SingleLinkedList.Tests.cs
│   │   │   └── algo06_linkedlist_tests.csproj
│   │   ├── _07_linkedlist_tests/
│   │   │   ├── SingleLinkedListAlgo.Tests.cs
│   │   │   └── algo07_linkedlist_tests.csproj
│   │   └── algo08_stack_tests/
│   │       ├── ArrayStack.Tests.cs
│   │       ├── LinkedStack.Tests.cs
│   │       ├── LinkedStackBrowser.Tests.cs
│   │       └── algo08_stack_tests.csproj
│   ├── csharp.sln
│   └── csharp.sln.DotSettings.user
├── f21
├── go/
│   ├── .gitkeep
│   ├── 05_array/
│   │   ├── .gitkeep
│   │   ├── array.go
│   │   └── array_test.go
│   ├── 06_linkedlist/
│   │   ├── .gitkeep
│   │   ├── palindrome-linked-list.go
│   │   ├── palindrome.go
│   │   ├── palindrome_test.go
│   │   ├── singlelinkedlist.go
│   │   └── singlelinkedlist_test.go
│   ├── 07_linkedlist/
│   │   ├── .gitkeep
│   │   ├── main.go
│   │   └── main_test.go
│   ├── 08_stack/
│   │   ├── SimpleBrowser.go
│   │   ├── SimpleBrowser_test.go
│   │   ├── StackBasedOnArray.go
│   │   ├── StackBasedOnArray_test.go
│   │   ├── StackBasedOnLinkedList.go
│   │   ├── StackBasedOnLinkedList_test.go
│   │   └── StatckInterface.go
│   ├── 09_queue/
│   │   ├── CircularQueue.go
│   │   ├── CircularQueue_test.go
│   │   ├── QueueBasedOnArray.go
│   │   ├── QueueBasedOnArray_test.go
│   │   ├── QueueBasedOnLinkedList.go
│   │   └── QueueBasedOnLinkedList_test.go
│   ├── 10_recursion/
│   │   ├── Factorial.go
│   │   ├── Factorial_test.go
│   │   ├── Fibonacci.go
│   │   ├── Fibonacci_test.go
│   │   ├── RangAll.go
│   │   └── RangAll_test.go
│   ├── 11_sorts/
│   │   ├── Sort.go
│   │   └── Sort_test.go
│   ├── 12_sorts/
│   │   ├── MergeSort.go
│   │   ├── MergeSort_test.go
│   │   ├── QuickSort.go
│   │   └── QuickSort_test.go
│   ├── 13_sorts/
│   │   ├── BucketSort.go
│   │   └── BucketSort_test.go
│   ├── 14_sorts/
│   │   ├── CountingSort.go
│   │   └── CountingSort_test.go
│   ├── 15_binarysearch/
│   │   ├── binarysearch.go
│   │   └── binarysearch_test.go
│   ├── 17_skiplist/
│   │   ├── skiplist.go
│   │   └── skiplist_test.go
│   ├── 20_lru/
│   │   ├── lru_cache.go
│   │   └── lru_cache_test.go
│   ├── 23_binarytree/
│   │   ├── binarytree.go
│   │   └── binarytree_test.go
│   ├── 24_tree/
│   │   ├── BinarySearchTree.go
│   │   ├── BinarySearchTree_test.go
│   │   ├── BinaryTree.go
│   │   ├── BinaryTree_test.go
│   │   ├── StackBasedOnArray.go
│   │   └── TreeNode.go
│   ├── 28_heap/
│   │   ├── heap.go
│   │   └── heap_sort.go
│   ├── 29_priority_queue/
│   │   ├── heap.go
│   │   ├── heap_test.go
│   │   ├── priority_queue.go
│   │   ├── priority_queue_test.go
│   │   └── readme.md
│   ├── 31_graph/
│   │   └── graph_search.go
│   ├── 32_string/
│   │   ├── string_bf.go
│   │   └── string_bm.go
│   ├── 34_kmp/
│   │   └── kmp.go
│   ├── 41_dynamic_programming/
│   │   ├── backtracking/
│   │   │   ├── leastcoins.go
│   │   │   └── leastcoins_test.go
│   │   └── dp/
│   │       ├── leastcoins.go
│   │       └── leastcoins_test.go
│   ├── 42_dynamic_programming/
│   │   └── longest_common_substring.go
│   ├── 45_bitmap/
│   │   ├── bitmap.go
│   │   └── bitmap_test.go
│   └── binarysearch2.go
├── java/
│   ├── 05_array/
│   │   ├── .gitkeep
│   │   ├── Array.java
│   │   └── GenericArray.java
│   ├── 06_linkedlist/
│   │   ├── .gitkeep
│   │   ├── LRUBaseLinkedList.java
│   │   ├── LRUBasedArray.java
│   │   └── SinglyLinkedList.java
│   ├── 07_linkedlist/
│   │   ├── .gitkeep
│   │   └── LinkedListAlgo.java
│   ├── 08_stack/
│   │   ├── SampleBrowser.java
│   │   └── StackBasedOnLinkedList.java
│   ├── 09_queue/
│   │   ├── ArrayQueue.java
│   │   ├── CircularQueue.java
│   │   ├── DynamicArrayQueue.java
│   │   └── QueueBasedOnLinkedList.java
│   ├── 11_sorts/
│   │   ├── InsertionSortAdd.java
│   │   ├── Sorts.java
│   │   └── SortsAddOn.java
│   ├── 12_sorts/
│   │   ├── KthSmallest.java
│   │   ├── MergeSort.java
│   │   ├── QuickSort.java
│   │   └── Sorts.java
│   ├── 13_sorts/
│   │   ├── BucketSort.java
│   │   ├── CountingSort.java
│   │   └── RadixSort.java
│   ├── 17_skiplist/
│   │   ├── SkipList.java
│   │   └── SkipList2.java
│   ├── 18_hashtable/
│   │   └── HashTable.java
│   ├── 20_hashtable/
│   │   └── LRUBaseHashTable.java
│   ├── 24_tree/
│   │   └── BinarySearchTree.java
│   ├── 28_sorts/
│   │   └── HeapSort.java
│   ├── 30_graph/
│   │   └── Graph.java
│   ├── 32_BFRK
│   └── 36_ac_automata/
│       └── ACAutoMata.java
├── javascript/
│   ├── .gitkeep
│   ├── 05_array/
│   │   ├── .gitkeep
│   │   └── Array.md
│   ├── 06_linkedlist/
│   │   ├── .gitkeep
│   │   └── SinglyLinkedList.js
│   ├── 07_linkedlist/
│   │   ├── .gitkeep
│   │   └── LinkedListAlgo.js
│   ├── 08_stack/
│   │   ├── SampleBrowser.js
│   │   └── StackBasedOnLinkedList.js
│   ├── 09_queue/
│   │   ├── CircularQueueBasedOnLinkedList.js
│   │   └── QueueBasedOnLinkedList.js
│   ├── 11_sorts/
│   │   └── sort.js
│   ├── 12_sorts/
│   │   ├── KthNum.js
│   │   ├── MergeSort.js
│   │   └── QuickSort.js
│   ├── 13_sorts/
│   │   ├── bucketSort.js
│   │   └── countingSort.js
│   ├── 15_binary/
│   │   └── binaryFind.js
│   ├── 16_binary/
│   │   └── binary-find.js
│   ├── 17_skiplist/
│   │   └── SkipList.js
│   ├── 18_hashmap/
│   │   └── HashTable.html
│   ├── 19_hashTable/
│   │   └── hashtable.js
│   ├── 23_tree/
│   │   └── binary_tree.js
│   ├── 28_heapsort/
│   │   ├── heap-sort.js
│   │   └── heap.js
│   ├── 35_trie/
│   │   └── trie.js
│   ├── 36_ac_automata/
│   │   ├── ac_automata.js
│   │   └── ac_automata_unicode.js
│   ├── 42_dynamic_programming/
│   │   └── levenshtein_distance.js
│   ├── 43_topological_sorting/
│   │   └── dsf.js
│   └── 45_bitmap/
│       └── bitmap.js
├── kotlin/
│   ├── 05_array/
│   │   ├── ArrayKt.kt
│   │   └── DynamicArray.kt
│   ├── 06_linkedlist/
│   │   └── SinglyLinkedList.kt
│   ├── 07_linkedlist/
│   │   └── LinkedListAlgo.kt
│   └── 08_stack/
│       └── StackBasedOnLinkedList.kt
├── notes/
│   ├── .gitkeep
│   ├── 10_recursion/
│   │   └── readme.md
│   ├── 11_sorts/
│   │   └── readme.md
│   ├── 12_sorts/
│   │   ├── .gitkeep
│   │   └── readme.md
│   ├── 13_sorts/
│   │   ├── .gitkeep
│   │   └── readme.md
│   ├── 14_sorts/
│   │   ├── .gitkeep
│   │   └── readme.md
│   ├── 15_bsearch/
│   │   ├── .gitkeep
│   │   └── readme.md
│   ├── 16_bsearch/
│   │   ├── .gitkeep
│   │   └── readme.md
│   ├── 17_skiplist/
│   │   ├── .gitkeep
│   │   └── readme.md
│   ├── 18_hashtable/
│   │   ├── .gitkeep
│   │   └── readme.md
│   ├── 19_hashtable/
│   │   ├── .gitkeep
│   │   └── readme.md
│   └── 20_hashtable/
│       ├── .gitkeep
│       └── readme.md
├── object-c/
│   ├── .gitkeep
│   ├── 05_array/
│   │   ├── .gitkeep
│   │   ├── MyArray.h
│   │   └── MyArray.m
│   ├── 06_linkedlist/
│   │   ├── .gitkeep
│   │   ├── ListNode.h
│   │   ├── ListNode.m
│   │   ├── SinglyLinkedList.h
│   │   ├── SinglyLinkedList.m
│   │   └── SinglyLinkedListTests.m
│   ├── 07_linkedlist/
│   │   └── .gitkeep
│   ├── 08_stack/
│   │   ├── LinkedStack.h
│   │   ├── LinkedStack.m
│   │   ├── LinkedStackTests.m
│   │   ├── ListNode.h
│   │   ├── ListNode.m
│   │   └── stack_practice/
│   │       ├── ArrayStack.h
│   │       ├── ArrayStack.m
│   │       ├── BalancedParentheses.h
│   │       ├── BalancedParentheses.m
│   │       ├── FourOperation.h
│   │       ├── FourOperation.m
│   │       └── main.m
│   ├── 11_Sort/
│   │   ├── Sort.h
│   │   └── Sort.m
│   └── 33_bm_match/
│       ├── BM.h
│       ├── BM.m
│       └── main.m
├── php/
│   ├── .gitignore
│   ├── 05_array/
│   │   ├── .gitkeep
│   │   ├── array.php
│   │   └── array_test.php
│   ├── 06_linkedlist/
│   │   ├── .gitkeep
│   │   ├── SingleLinkedList.php
│   │   ├── SingleLinkedListNode.php
│   │   └── main.php
│   ├── 07_linkedlist/
│   │   ├── .gitkeep
│   │   └── main.php
│   ├── 08_stack/
│   │   ├── .gitkeep
│   │   ├── Compute.php
│   │   ├── StackOnLinkedList.php
│   │   └── main.php
│   ├── 09_queue/
│   │   ├── QueueOnLinkedList.php
│   │   ├── Sequential.php
│   │   └── main.php
│   ├── 10_heap/
│   │   ├── Heap.php
│   │   ├── findmiddle.php
│   │   ├── main.php
│   │   └── topn.php
│   ├── 11_sort/
│   │   └── Sort.php
│   ├── 12_sort/
│   │   ├── mergeSort.php
│   │   └── quicksort.php
│   ├── 13_sort/
│   │   ├── bucketSort.php
│   │   ├── countingSort.php
│   │   └── radixSort.php
│   ├── 15_binary/
│   │   └── binary.php
│   ├── 16_binary/
│   │   └── binary.php
│   ├── 17_skiplist/
│   │   └── skipList.php
│   ├── 24_tree/
│   │   ├── Tree.php
│   │   ├── TreeNode.php
│   │   ├── levelOrder.php
│   │   └── main.php
│   ├── 38_divide_and_conquer/
│   │   └── matrix_production.php
│   ├── 39_backtracking/
│   │   └── queens.php
│   ├── README.md
│   ├── Stack/
│   │   └── Compute.php
│   ├── buildAutoLoad.sh
│   └── composer.json
├── python/
│   ├── .gitkeep
│   ├── 05_array/
│   │   ├── .gitkeep
│   │   └── myarray.py
│   ├── 06_linkedlist/
│   │   ├── .gitkeep
│   │   ├── LRUCache.py
│   │   ├── palindrome.py
│   │   ├── singlyLinkedList.py
│   │   └── singly_linked_list.py
│   ├── 07_linkedlist/
│   │   ├── .gitkeep
│   │   └── linked_list_algo.py
│   ├── 08_stack/
│   │   ├── linked_stack.py
│   │   └── simple_browser.py
│   ├── 09_queue/
│   │   ├── array_queue.py
│   │   ├── circular_queue.py
│   │   ├── dynamic_array_queue.py
│   │   └── linked_queue.py
│   ├── 11_sorts/
│   │   └── sorts.py
│   ├── 12_sorts/
│   │   ├── merge_sort.py
│   │   ├── quick_sort.py
│   │   └── quicksort_twoway.py
│   ├── 14_sorts/
│   │   └── counting_sort.py
│   ├── 15_bsearch/
│   │   ├── bsearch.py
│   │   └── bsearch_recursion.py
│   ├── 16_bsearch/
│   │   └── bsearch_variants.py
│   ├── 17_skiplist/
│   │   ├── skip_list.py
│   │   └── skip_list_comments.py
│   ├── 23_binarytree/
│   │   ├── binary_search_tree.py
│   │   └── binary_tree.py
│   ├── 24_tree/
│   │   └── binary_search_tree.py
│   ├── 26_red_black_tree/
│   │   └── red_black_tree.py
│   ├── 28_binary_heap/
│   │   ├── binary_heap.py
│   │   ├── binary_heap_sort.py
│   │   ├── heap.py
│   │   ├── priority_queue.py
│   │   └── top_k.py
│   ├── 28_heap/
│   │   ├── heap.py
│   │   └── min_heap.py
│   ├── 31_bfs_dfs/
│   │   ├── bfs_dfs.py
│   │   ├── graph.py
│   │   └── graph_application.py
│   ├── 32_bf_rk/
│   │   └── bf_rk.py
│   ├── 33_bm/
│   │   ├── bm.py
│   │   └── bm_.py
│   ├── 34_kmp/
│   │   ├── kmp.py
│   │   └── kmp_.py
│   ├── 35_trie/
│   │   ├── trie.py
│   │   └── trie_.py
│   ├── 36_ac_automata/
│   │   ├── ac_automata.py
│   │   └── ac_automata_.py
│   ├── 38_divide_and_conquer/
│   │   └── merge_sort_counting.py
│   ├── 39_back_track/
│   │   ├── 01_bag.py
│   │   ├── eight_queens.py
│   │   ├── permutations.py
│   │   └── regex.py
│   ├── 39_backtracking/
│   │   └── backtracking.py
│   ├── 40_dynamic_programming/
│   │   ├── 01_bag.py
│   │   ├── knapsack.py
│   │   └── yh_triangle.py
│   ├── 41_dynamic_programming/
│   │   ├── coins_problem.py
│   │   └── min_dist.py
│   ├── 42_dynamic_programming/
│   │   ├── longest_increasing_subsequence.py
│   │   └── min_edit_dist.py
│   ├── 43_topological_sorting/
│   │   └── topological_sorting.py
│   ├── 44_shortest_path/
│   │   ├── dijkstra.py
│   │   └── shortest_path.py
│   ├── 45_bitmap/
│   │   └── bitmap.py
│   └── array.py
├── rust/
│   ├── 05_array/
│   │   └── main.rs
│   ├── 07_linkedlist/
│   │   ├── linked_list_cycle.rs
│   │   ├── merge_two_sorted_lists.rs
│   │   ├── middle_of_the_linked_list.rs
│   │   ├── remove_nth_node_from_end_of_list.rs
│   │   ├── reverse_linked_list.rs
│   │   └── util/
│   │       └── linked_list.rs
│   ├── 08_stack/
│   │   ├── simple_browser.rs
│   │   ├── stack_based_on_array.rs
│   │   └── stack_based_on_linked_list.rs
│   ├── 09_queue/
│   │   ├── array_queue.rs
│   │   ├── circle_queue.rs
│   │   └── linked_list_queue.rs
│   ├── 11_sorts/
│   │   ├── bubble_sort.rs
│   │   ├── insertion_sort.rs
│   │   └── selection_sort.rs
│   ├── 12_sorts/
│   │   ├── kth_largest.rs
│   │   ├── merge_sort.rs
│   │   └── quick_sort.rs
│   ├── 13_sorts/
│   │   ├── bucket_sort.rs
│   │   ├── counting_sort.rs
│   │   ├── radix_sort.rs
│   │   └── sort_string.rs
│   ├── 15_binary_search/
│   │   ├── binary_search.rs
│   │   └── sqrtx.rs
│   ├── 16_binary_search/
│   │   ├── binary_search.rs
│   │   └── search_in_rotated_sorted_array.rs
│   ├── 19_hash_table/
│   │   └── hash_table.rs
│   ├── 23_binary_tree/
│   │   ├── inorder_traversal.rs
│   │   ├── level_order_traversal.rs
│   │   ├── postorder_traversal.rs
│   │   ├── preorder_traversal.rs
│   │   └── util/
│   │       └── tree.rs
│   ├── 24_binary_tree/
│   │   ├── insert_in_binary_tree.rs
│   │   ├── max_depth_in_binary_tree.rs
│   │   ├── search_in_binary_tree.rs
│   │   └── util/
│   │       └── tree.rs
│   ├── 28_heap/
│   │   ├── build_heap.rs
│   │   ├── heap.rs
│   │   └── sort_heap.rs
│   ├── 29_heap/
│   │   ├── get_median.rs
│   │   ├── get_top_k.rs
│   │   └── merge_sorted_array.rs
│   ├── 31_graph/
│   │   └── graph_search.rs
│   ├── 32_string/
│   │   └── bf_rk.rs
│   ├── 33_string/
│   │   └── bm.rs
│   ├── 34_string/
│   │   └── kmp.rs
│   ├── 35_trie/
│   │   └── trie.rs
│   ├── 38_divide_and_conquer/
│   │   └── merge_sort_count.rs
│   ├── 39_back_tracking/
│   │   ├── bag.rs
│   │   ├── bag_exec.rs
│   │   ├── n_queens.rs
│   │   └── regex.rs
│   ├── 40_dynamic_programming/
│   │   ├── bag.rs
│   │   ├── knapsack.rs
│   │   └── triangle.rs
│   ├── 41_dynamic_programming/
│   │   ├── coin_change.rs
│   │   └── min_dis_path.rs
│   └── 42_dynamic_programming/
│       ├── edit_distance.rs
│       └── longest_increasing_subsequence.rs
├── scala/
│   ├── .gitignore
│   ├── build.sbt
│   ├── project/
│   │   └── build.properties
│   └── src/
│       ├── main/
│       │   └── scala/
│       │       ├── ch05_array/
│       │       │   └── ArrayDemo.scala
│       │       ├── ch06_linkedlist/
│       │       │   └── SinglyLinkedList.scala
│       │       ├── ch07_linkedlist/
│       │       │   └── LinkedListAlgo.scala
│       │       ├── ch08_stack/
│       │       │   ├── BrowserDemo.scala
│       │       │   └── StackDemo.scala
│       │       ├── ch09_queue/
│       │       │   ├── ArrayQueue.scala
│       │       │   ├── CircularQueue.scala
│       │       │   ├── DemoQueue.scala
│       │       │   ├── DynamicArrayQueue.scala
│       │       │   └── LinkedListQueue.scala
│       │       ├── ch10_recursive/
│       │       │   └── RecursiveDemo.scala
│       │       ├── ch11_sorts/
│       │       │   └── Sorts.scala
│       │       ├── ch12_sorts/
│       │       │   ├── MergeSort.scala
│       │       │   └── QuickSort.scala
│       │       ├── ch15_bsearch/
│       │       │   ├── BSearch.scala
│       │       │   └── BSearchRecursive.scala
│       │       ├── ch16_bsearch/
│       │       │   └── BSearch.scala
│       │       ├── ch17_skip_list/
│       │       │   └── SkipList.scala
│       │       ├── ch20_linked_hash_map/
│       │       │   └── LRUCache.scala
│       │       ├── ch23_binary_tree/
│       │       │   └── BinaryTree.scala
│       │       ├── ch24_binary_search_tree/
│       │       │   └── BinarySearchTree.scala
│       │       ├── ch28_heap/
│       │       │   └── Heap.scala
│       │       ├── ch29_heap_solutions/
│       │       │   ├── FileMerger.scala
│       │       │   ├── MiddleNumberKeeper.scala
│       │       │   └── TopKItemsKeeper.scala
│       │       ├── ch31_graph/
│       │       │   └── Graph.scala
│       │       ├── ch32_matching/
│       │       │   ├── BruteForce.scala
│       │       │   └── RabinKarp.scala
│       │       ├── ch35_tire_tree/
│       │       │   └── TrieTree.scala
│       │       ├── ch39_back_tracking/
│       │       │   ├── BagWeight.scala
│       │       │   ├── EightQueens.scala
│       │       │   ├── NQueens.scala
│       │       │   └── Sudoku.scala
│       │       └── ch43_topology_sort/
│       │           └── GraphTopology.scala
│       └── test/
│           └── scala/
│               ├── ch05_array/
│               │   └── ArrayDemoSpec.scala
│               ├── ch06_linkedlist/
│               │   ├── NodeTest.scala
│               │   └── SinglyLinkedListTest.scala
│               ├── ch07_linkedlist/
│               │   └── LinkedListAlgoTest.scala
│               ├── ch08_stack/
│               │   ├── BrowserDemoTest.scala
│               │   └── StackDemoTest.scala
│               ├── ch09_queue/
│               │   ├── ArrayQueueTest.scala
│               │   ├── CircularQueueTest.scala
│               │   ├── DemoQueueTest.scala
│               │   ├── DynamicArrayQueueTest.scala
│               │   └── LinkedListQueueTest.scala
│               ├── ch10_recursive/
│               │   └── RecursiveDemoTest.scala
│               ├── ch11_sorts/
│               │   └── SortsTest.scala
│               ├── ch12_sorts/
│               │   ├── MergeSortTest.scala
│               │   └── QuickSortTest.scala
│               ├── ch15_bsearch/
│               │   ├── BSearchRecursiveTest.scala
│               │   └── BSearchTest.scala
│               ├── ch16_bsearch/
│               │   └── BSearchTest.scala
│               ├── ch17_skip_list/
│               │   └── SkipListTest.scala
│               ├── ch20_linked_hash_map/
│               │   └── LRUCacheTest.scala
│               ├── ch23_binary_tree/
│               │   └── BinaryTreeTest.scala
│               ├── ch24_binary_search_tree/
│               │   └── BinarySearchTreeTest.scala
│               ├── ch28_heap/
│               │   └── HeapTest.scala
│               ├── ch29_heap_solutions/
│               │   ├── FileMergerTest.scala
│               │   ├── MiddleNumberKeeperTest.scala
│               │   └── TopKItemsKeeperTest.scala
│               ├── ch31_graph/
│               │   └── GraphTest.scala
│               ├── ch32_matching/
│               │   ├── BruteForceTest.scala
│               │   └── RabinKarpTest.scala
│               ├── ch35_tire_tree/
│               │   └── TrieTreeTest.scala
│               ├── ch39_back_tracking/
│               │   ├── BagWeightTest.scala
│               │   ├── EightQueensTest.scala
│               │   ├── NQueensTest.scala
│               │   └── SudokuTest.scala
│               └── ch43_topology_sort/
│                   └── GraphTopologyTest.scala
├── swift/
│   ├── 05_array/
│   │   └── MyArray.swift
│   ├── 06_linkedlist/
│   │   └── SinglyLinkedList.swift
│   ├── 07_linkedlist/
│   │   └── LinkedListAlgo.swift
│   ├── 08_stack/
│   │   ├── Browser.swift
│   │   ├── BrowserDemo.swift
│   │   ├── Stack.swift
│   │   └── StackBasedOnLinkedList.swift
│   ├── 09_queue/
│   │   ├── ArrayQueue.swift
│   │   ├── CircularQueue.swift
│   │   ├── Queue.swift
│   │   └── QueueBasedOnLinkedList.swift
│   ├── 11_sorts/
│   │   └── Sorts.swift
│   ├── 12_sorts/
│   │   ├── QuickSort.swift
│   │   ├── SortsTests.swift
│   │   └── mergeSort.swift
│   └── 14_sorts/
│       └── CountingSort.swift
└── typescript/
    ├── 06_linkedlist/
    │   ├── LRUCache.ts
    │   ├── LinkedList.ts
    │   ├── List.ts
    │   └── SingleLinkedList.ts
    ├── 07_linkedlist/
    │   └── LinkedListAlog.ts
    ├── 08_stack/
    │   └── StackAndBrowser.ts
    ├── 09_queue/
    │   ├── CircularQueue.ts
    │   ├── README.md
    │   └── SimpleQueue.ts
    ├── 10_recursive/
    │   └── climbStairs.ts
    ├── 11_sorts/
    │   └── simpleSort.ts
    ├── 12_sorts/
    │   ├── KthNum.ts
    │   ├── MergeSort.ts
    │   └── quickSort.ts
    ├── 13_sorts/
    │   ├── BucketSort.ts
    │   └── CountingSort.ts
    ├── 14_binarysearch/
    │   └── BinarySearch.ts
    ├── 15_binarysearch/
    │   └── BinaryFind.ts
    ├── 17_skiplist/
    │   └── SkipList.ts
    └── 24_treesearch/
        └── TreeSearch.ts
Download .txt
SYMBOL INDEX (2401 symbols across 406 files)

FILE: DynamicStackBaseArray.java
  class DynamicStackBaseArray (line 11) | public class DynamicStackBaseArray<T> implements Iterable<T> {
    method DynamicStackBaseArray (line 21) | public DynamicStackBaseArray(int length) {
    method push (line 32) | public void push(T item) {
    method pop (line 46) | public T pop() {
    method resize (line 68) | private void resize(int size) {
    method peek (line 77) | public T peek() {
    method isEmpty (line 86) | public boolean isEmpty() {
    method size (line 95) | public int size() {
    method iterator (line 99) | @Override
    class ArrayIterator (line 105) | class ArrayIterator implements Iterator {
      method hasNext (line 108) | @Override
      method next (line 113) | @Override
    method main (line 119) | public static void main(String[] args) {

FILE: StackBaseArray.java
  class StackBaseArray (line 7) | public class StackBaseArray {
    method StackBaseArray (line 12) | public StackBaseArray(int capactiy) {
    method push (line 23) | public boolean  push(int item) {
    method pop (line 37) | public int  pop(){
    method main (line 47) | public static void main(String[] args){

FILE: c-cpp/05_array/Array_gp.c
  function Array (line 6) | Array* arrayCreate()
  function arrayInit (line 28) | void arrayInit(Array *array, int size, int typeSize)
  function arrayInsert (line 49) | int arrayInsert(Array *array, size_t pos, void *const value)
  function arraySearchValue (line 94) | size_t arraySearchValue(Array *array, void* const value)
  function arrayModify (line 141) | int arrayModify(Array *array, size_t pos, void *const value)
  function arrayLen (line 167) | size_t arrayLen(Array *array)
  function arraySize (line 177) | size_t arraySize(Array *array)
  function arrayEmpty (line 187) | void arrayEmpty(Array *array)
  function arrayDelValue (line 200) | void arrayDelValue(Array *array, void *value)
  function arrayDelIndex (line 250) | void arrayDelIndex(Array *array, size_t pos)

FILE: c-cpp/05_array/Array_gp.h
  type Array (line 7) | typedef struct Array

FILE: c-cpp/05_array/array.c
  type array (line 5) | struct array {
  function dump (line 11) | void dump(struct array *array)
  function alloc (line 19) | void alloc(struct array *array)
  function insert (line 24) | int insert(struct array *array, int elem)
  function delete (line 44) | int delete(struct array *array, int idx)
  function search (line 55) | int search(struct array *array, int elem)
  function main (line 69) | int main()

FILE: c-cpp/06_linkedlist/Dlist/Dlist.c
  function dlist_init (line 14) | void dlist_init(stDlistHead *dlist)		//链表初始化
  function dlist_destory (line 22) | void dlist_destory(stDlistHead *dlist)		//删除链表
  function dlist_insert_head (line 39) | int dlist_insert_head(stDlistHead *dlist,stDlistNode *pNode,int data)		/...
  function stDlistNode (line 70) | stDlistNode * dlist_remove_tail(stDlistHead *dlist)		//删除尾部节点,并返回删除节点
  function dlist_remove_node (line 94) | void dlist_remove_node(stDlistHead * dlist,stDlistNode *pNode) 		//删除指定节点
  function stDlistNode (line 127) | stDlistNode * dlist_search(stDlistHead * dlist,int data) 		//根据值搜索节点,并返回
  function dlist_dump (line 142) | void dlist_dump(stDlistHead *dlist)		//显示链表中的数据
  function Lru_dlist (line 156) | void Lru_dlist(stDlistHead *dlist,int data) 		//LRU(最近最少使用)缓存淘汰算法
  function main (line 176) | int main()

FILE: c-cpp/06_linkedlist/Dlist/Dlist.h
  type stDlistNode (line 10) | typedef struct DlistNode          //双向链表中每一个节点
  type stDlistHead (line 17) | typedef struct Dlisthead          //定义链表总体

FILE: c-cpp/06_linkedlist/LRUBasedLinkedList.cpp
  class SNode (line 4) | class SNode
  class SList (line 11) | class SList
  function main (line 193) | int main(int argc, char const *argv[])

FILE: c-cpp/06_linkedlist/list_isPalindrome/LinkList.cpp
  function CreateListHead (line 3) | void CreateListHead(LinkList *&L,ElemType a[],int n)
  function CreateListTail (line 17) | void CreateListTail(LinkList *&L,ElemType a[],int n)
  function InitList (line 32) | void InitList(LinkList *&L)
  function DestroyList (line 37) | void DestroyList(LinkList *&L)
  function ListEmpty (line 48) | bool ListEmpty(LinkList *L)
  function ListLength (line 52) | int ListLength(LinkList *L)
  function ShowList (line 63) | void ShowList(LinkList *L)
  function GetListElem (line 73) | bool GetListElem(LinkList *L,int i,ElemType &e)
  function LocateElem (line 90) | int LocateElem(LinkList*L,ElemType e)
  function ListInsert (line 105) | bool ListInsert(LinkList *&L,int i,ElemType e)
  function ListDelete (line 127) | bool ListDelete(LinkList *&L,int i,ElemType &e)

FILE: c-cpp/06_linkedlist/list_isPalindrome/LinkList.h
  type ElemType (line 6) | typedef char ElemType;
  type LinkList (line 7) | typedef struct LNode

FILE: c-cpp/06_linkedlist/palindromeList/LinkedList.hpp
  class LinkedList (line 13) | class LinkedList {
  function ListNode (line 59) | ListNode* LinkedList::FindElem(int elemVal) {

FILE: c-cpp/06_linkedlist/palindromeList/ListNode.hpp
  class ListNode (line 10) | class ListNode {

FILE: c-cpp/06_linkedlist/palindromeList/palindromeList.cpp
  function CheckPalindromeList (line 10) | bool CheckPalindromeList(LinkedList *list) {
  function main (line 67) | int main(int argc, char const *argv[]) {

FILE: c-cpp/06_linkedlist/single_list.c
  type single_list (line 4) | struct single_list {
  type single_list_head (line 9) | struct single_list_head {
  function is_empty (line 13) | bool is_empty(struct single_list_head *head)
  function dump (line 18) | void dump(struct single_list_head *head)
  function insert (line 29) | void insert(struct single_list **prev, struct single_list *elem)
  function insert_head (line 38) | void insert_head(struct single_list_head *head, struct single_list *elem)
  type single_list (line 43) | struct single_list
  type single_list (line 43) | struct single_list
  type single_list (line 45) | struct single_list
  type single_list (line 58) | struct single_list
  type single_list_head (line 58) | struct single_list_head
  type single_list (line 63) | struct single_list
  type single_list_head (line 63) | struct single_list_head
  type single_list (line 65) | struct single_list
  function reverse (line 75) | void reverse(struct single_list_head* head)
  function is_cyclic (line 88) | bool is_cyclic(struct single_list_head* head)
  type single_list (line 104) | struct single_list
  type single_list_head (line 104) | struct single_list_head
  type single_list (line 106) | struct single_list
  type single_list (line 107) | struct single_list
  function main (line 122) | int main()

FILE: c-cpp/06_linkedlist/singlelist_gc/singleList.c
  function linkedList (line 5) | linkedList * listCreate()
  function listRelease (line 25) | void listRelease(linkedList *list)
  function listEmpty (line 38) | void listEmpty(linkedList *list)
  function linkedList (line 64) | linkedList * listAddNodeHead(linkedList *list, void * value)
  function linkedList (line 86) | linkedList * listAddNodeTail(linkedList *list, void *value)
  function linkedList (line 125) | linkedList * listInsertNode(linkedList *list, listNode *old_node, void *...
  function listDelNode (line 165) | void listDelNode(linkedList *list, listNode *node)
  function listNode (line 198) | listNode * listSearchKey(linkedList *list, void *key)
  function listNode (line 229) | listNode * listIndex(linkedList *list, long index)
  function linkedList (line 251) | linkedList* listRewind(linkedList *list)
  function listLength (line 273) | size_t listLength(linkedList *list)

FILE: c-cpp/06_linkedlist/singlelist_gc/singleList.h
  type listNode (line 7) | typedef struct listNode
  type linkedList (line 13) | typedef struct linkedList

FILE: c-cpp/07_linkedlist/LinkedListAlgo.c
  type SinglyLinkedNode (line 14) | typedef struct SinglyLinkedNode {
  function reverse (line 24) | void reverse(SinglyLinkedNode** head_ref) {
  function test_reverse (line 41) | void test_reverse() {
  function checkCircle (line 54) | int checkCircle(SinglyLinkedNode** head_ref) {
  function test_checkCircle (line 65) | void test_checkCircle() {
  function SinglyLinkedNode (line 95) | SinglyLinkedNode* mergeSortedLinkedList(SinglyLinkedNode* la, SinglyLink...
  function moveNode (line 125) | void moveNode(SinglyLinkedNode** dest_ref, SinglyLinkedNode** src_ref) {
  function test_mergeSortedLinkedList (line 135) | void test_mergeSortedLinkedList() {
  function deleteLastKth (line 155) | void deleteLastKth(SinglyLinkedNode** head_ref, int k) {
  function test_deleteLastKth (line 186) | void test_deleteLastKth() {
  function SinglyLinkedNode (line 206) | SinglyLinkedNode* findMiddleNode(SinglyLinkedNode* head) {
  function test_findMiddleNode (line 220) | void test_findMiddleNode() {
  function insertNode (line 236) | void insertNode(SinglyLinkedNode** head_ref, int data) {
  function printLinkedList (line 244) | void printLinkedList(SinglyLinkedNode* node) {
  function test (line 254) | void test() {

FILE: c-cpp/07_linkedlist/SingleList.cpp
  class CElement (line 7) | class CElement
  class CSingleList (line 11) | class CSingleList
  class CElement (line 96) | class CElement
  function CreateList (line 114) | void CreateList(CSingleList& lst)
  function PrintList (line 124) | void PrintList(CSingleList& lst)
  function main (line 134) | int main()
  function CElement (line 291) | CElement* CSingleList::Insert(void* lpData, int iDataSize)
  function CElement (line 302) | CElement* CSingleList::Insert(CElement* lpElement, void* lpData, int iDa...
  function CElement (line 357) | CElement* CSingleList::Tail()
  function CElement (line 367) | CElement* CSingleList::Begin()
  function CElement (line 379) | CElement* CSingleList::Next()
  function CElement (line 393) | CElement* CSingleList::End()
  function CElement (line 533) | CElement* CSingleList::Center()

FILE: c-cpp/07_linkedlist/linked_list_algo.hpp
  function traverse (line 20) | void traverse(typename Node<T>::ptr_t head, UnaryFunc do_traverse) {
  function reverse (line 30) | typename Node<T>::ptr_t reverse(typename Node<T>::ptr_t head) {
  function check_circle (line 46) | bool check_circle(typename Node<T>::ptr_t head) {
  function merge_two_sorted_lists (line 62) | typename Node<T>::ptr_t merge_two_sorted_lists(typename Node<T>::ptr_t lhs,
  function deleth_last_Kth (line 99) | typename Node<T>::ptr_t deleth_last_Kth(typename Node<T>::ptr_t head,
  function find_middle_node (line 121) | typename Node<T>::ptr_t find_middle_node(typename Node<T>::ptr_t head) {

FILE: c-cpp/07_linkedlist/linklist_jinshaohui.c
  type stlistNode (line 11) | struct stlistNode
  function listNode (line 18) | listNode reverseList(listNode *head)
  function hasCycle (line 35) | int hasCycle(listNode *head)
  function listNode (line 53) | listNode *mergeTwoLists(listNode *l1,listNode *l2)
  function listNode (line 88) | listNode * removeNthFromEnd(listNode*headi,int n)
  function listNode (line 127) | listNode *middleNode(listNode *head)

FILE: c-cpp/08_stack/StackBasedOnArray/StackBasedOnArray.cpp
  function T (line 71) | T ArrayStack<T>::pop(){
  function T (line 78) | T ArrayStack<T>::peek(){
  function main (line 91) | int main(int argc, char const *argv[])

FILE: c-cpp/08_stack/StackBasedOnLinkedList/StackBasedOnLinkedList.cpp
  function T (line 49) | T LinkedListStack<T>::peek()
  function T (line 61) | T LinkedListStack<T>::pop()
  function main (line 84) | int main(int argc, char const *argv[])

FILE: c-cpp/08_stack/StackBasedOnLinkedList/StackBasedOnLinkedList.h
  type LinkedNode (line 14) | struct LinkedNode

FILE: c-cpp/08_stack/arrayStack/arrayStack.c
  function stArrayStack (line 14) | stArrayStack * arrayStack_create(int size)
  function arrayStack_destory (line 36) | void arrayStack_destory(stArrayStack * parrStack)
  function arrayStack_pop (line 52) | int arrayStack_pop(stArrayStack *parrStack)
  function arrayStack_push (line 66) | int arrayStack_push(stArrayStack *parrStack,int data)
  function arrayStack_push_new (line 79) | int arrayStack_push_new(stArrayStack*parrStack,int data)
  function arrayStack_dump (line 108) | void arrayStack_dump(stArrayStack *parrStack)
  function main (line 125) | int main()

FILE: c-cpp/08_stack/arrayStack/arrayStack.h
  type stArrayStack (line 12) | typedef struct _array_stack

FILE: c-cpp/08_stack/linkList/linklist_stack.c
  function linklist_stack (line 13) | linklist_stack * stack_create()
  function stack_destory (line 28) | void stack_destory(linklist_stack* stack)
  function stack_push (line 45) | int stack_push(linklist_stack *stack,int data)
  function stack_pop (line 62) | int stack_pop(linklist_stack*stack,int *data)
  function stack_dump (line 82) | void stack_dump(linklist_stack *stack)
  function main (line 94) | int main()

FILE: c-cpp/08_stack/linkList/linklist_stack.h
  type linklist_stack (line 12) | typedef struct _linkliststack

FILE: c-cpp/08_stack/stack_based_on_linked_list.hpp
  class Stack (line 14) | class Stack {
    method empty (line 23) | bool empty(void) const {
    method push (line 26) | void push(const value_type& value) {
    method value_type (line 35) | value_type top(void) const {
    method pop (line 42) | void pop(void) {

FILE: c-cpp/09_queue/array_queue.hpp
  class ArrayQueue (line 9) | class ArrayQueue {
    method ArrayQueue (line 17) | ArrayQueue() = delete;
    method ArrayQueue (line 18) | ArrayQueue(const size_t capacity) : capacity_(capacity) {
    method ArrayQueue (line 27) | ArrayQueue(const ArrayQueue& other) : capacity_(other.capacity_) {
    method ArrayQueue (line 33) | ArrayQueue& operator=(const ArrayQueue& rhs) {
    method ArrayQueue (line 44) | ArrayQueue(ArrayQueue&& other) : items_(other.items_),
    method ArrayQueue (line 53) | ArrayQueue& operator=(ArrayQueue&& rhs) {
    method enqueue (line 67) | void enqueue(T item) {
    method T (line 73) | T head() const {
    method dequeue (line 80) | void dequeue() {
    method traverse (line 90) | void traverse(UnaryFunc do_traverse) {

FILE: c-cpp/09_queue/array_queue/array_queue.c
  function array_queue (line 14) | array_queue * array_queue_create(int size)
  function array_queue_destory (line 37) | void array_queue_destory(array_queue *queue)
  function array_queue_enqueue (line 54) | int array_queue_enqueue(array_queue *queue,int data)
  function array_queue_dequeue (line 70) | int array_queue_dequeue(array_queue * queue,int *data)
  function array_queue_dump (line 84) | void array_queue_dump(array_queue *queue)
  function main (line 105) | int main()

FILE: c-cpp/09_queue/array_queue/array_queue.h
  type array_queue (line 11) | typedef struct _array_queue

FILE: c-cpp/09_queue/array_queue_test.cc
  function main (line 4) | int main() {

FILE: c-cpp/09_queue/block_queue.hpp
  class BlockQueue (line 13) | class BlockQueue {
    method BlockQueue (line 27) | BlockQueue() = delete;
    method BlockQueue (line 28) | BlockQueue(const size_type capacity) : capacity_(capacity) {}
    method BlockQueue (line 29) | BlockQueue(const BlockQueue&) = default;
    method BlockQueue (line 30) | BlockQueue(BlockQueue&&) = default;
    method BlockQueue (line 31) | BlockQueue& operator=(const BlockQueue&) = default;
    method BlockQueue (line 32) | BlockQueue& operator=(BlockQueue&&) = default;
    method empty (line 35) | bool empty() const { return container_.empty(); }
    method full (line 36) | bool full() const { return not(container_.size() < capacity_); }
    method put (line 39) | void put(const value_type& item) {
    method take (line 47) | void take(value_type& out) {
    method put_for (line 57) | bool put_for(const value_type& item, const Duration& d) {
    method take_for (line 68) | bool take_for(const Duration& d, value_type& out) {

FILE: c-cpp/09_queue/circular_queue.hpp
  class CircularQueue (line 9) | class CircularQueue {
    method CircularQueue (line 17) | CircularQueue() = delete;
    method CircularQueue (line 18) | CircularQueue(const size_t capacity) : capacity_(capacity) {
    method CircularQueue (line 27) | CircularQueue(const CircularQueue& other) : capacity_(other.capacity_) {
    method CircularQueue (line 33) | CircularQueue& operator=(const CircularQueue& rhs) {
    method CircularQueue (line 44) | CircularQueue(CircularQueue&& other) : items_(other.items_),
    method CircularQueue (line 53) | CircularQueue& operator=(CircularQueue&& rhs) {
    method enqueue (line 67) | void enqueue(T item) {
    method T (line 74) | T head() const {
    method dequeue (line 81) | void dequeue() {
    method traverse (line 91) | void traverse(UnaryFunc do_traverse) {

FILE: c-cpp/09_queue/circular_queue_test.cc
  function main (line 4) | int main() {

FILE: c-cpp/09_queue/concurrency_queue.hpp
  class ConcurrencyQueue (line 14) | class ConcurrencyQueue {
    method ConcurrencyQueue (line 26) | ConcurrencyQueue() = default;
    method ConcurrencyQueue (line 27) | ConcurrencyQueue(const ConcurrencyQueue&) = default;
    method ConcurrencyQueue (line 28) | ConcurrencyQueue(ConcurrencyQueue&&) = default;
    method ConcurrencyQueue (line 29) | ConcurrencyQueue& operator=(const ConcurrencyQueue&) = default;
    method ConcurrencyQueue (line 30) | ConcurrencyQueue& operator=(ConcurrencyQueue&&) = default;
    method empty_ (line 33) | bool empty_() const { return container_.empty(); }
    method empty (line 36) | bool empty() const {
    method push (line 40) | void push(value_type item) {
    method wait_and_pop (line 45) | void wait_and_pop(value_type& out) {
    method wait_and_pop (line 53) | std::shared_ptr<value_type> wait_and_pop() {
    method try_pop (line 62) | bool try_pop(value_type& out) {
    method try_pop (line 72) | std::shared_ptr<value_type> try_pop() {

FILE: c-cpp/09_queue/dynamic_array_queue.hpp
  class DynamicArrayQueue (line 9) | class DynamicArrayQueue {
    method DynamicArrayQueue (line 17) | DynamicArrayQueue() = delete;
    method DynamicArrayQueue (line 18) | DynamicArrayQueue(const size_t capacity) : capacity_(capacity) {
    method DynamicArrayQueue (line 27) | DynamicArrayQueue(const DynamicArrayQueue& other) : capacity_(other.ca...
    method DynamicArrayQueue (line 33) | DynamicArrayQueue& operator=(const DynamicArrayQueue& rhs) {
    method DynamicArrayQueue (line 44) | DynamicArrayQueue(DynamicArrayQueue&& other) : items_(other.items_),
    method DynamicArrayQueue (line 53) | DynamicArrayQueue& operator=(DynamicArrayQueue&& rhs) {
    method enqueue (line 67) | void enqueue(T item) {
    method T (line 81) | T head() const {
    method dequeue (line 88) | void dequeue() {
    method traverse (line 98) | void traverse(UnaryFunc do_traverse) {

FILE: c-cpp/09_queue/dynamic_array_queue_test.cc
  function main (line 4) | int main() {

FILE: c-cpp/09_queue/linked_queue.hpp
  type Node (line 11) | struct Node {
    method Node (line 16) | Node(T data_) : data(data_), next(nullptr) {}
    method Node (line 17) | Node() : next(nullptr) {}
  class LinkedQueue (line 21) | class LinkedQueue {
    method LinkedQueue (line 31) | LinkedQueue()  = default;
    method LinkedQueue (line 33) | LinkedQueue(const LinkedQueue& other) = default;
    method LinkedQueue (line 34) | LinkedQueue& operator=(const LinkedQueue& rhs) = default;
    method LinkedQueue (line 35) | LinkedQueue(LinkedQueue&& other) = default;
    method LinkedQueue (line 36) | LinkedQueue& operator=(LinkedQueue&& rhs) = default;
    method enqueue (line 39) | void enqueue(T item) {
    method T (line 48) | T head() const {
    method dequeue (line 55) | void dequeue() {
    method traverse (line 68) | void traverse(UnaryFunc do_traverse) {

FILE: c-cpp/09_queue/linked_queue_test.cc
  function main (line 4) | int main() {

FILE: c-cpp/09_queue/list_queue/list_queue.c
  function list_queue (line 14) | list_queue *list_queue_create()
  function list_queue_destroy (line 30) | void list_queue_destroy(list_queue*queue)
  function list_queue_enqueue (line 48) | int list_queue_enqueue(list_queue *queue,int data)
  function list_queue_dequeue (line 81) | int list_queue_dequeue(list_queue *queue,int *data)
  function list_queue_dump (line 104) | void list_queue_dump(list_queue*queue)
  function main (line 128) | int main()

FILE: c-cpp/09_queue/list_queue/list_queue.h
  type queue_node (line 12) | typedef struct _list_queue_node
  type list_queue (line 18) | typedef struct _list_queue

FILE: c-cpp/09_queue/lock_free_queue.hpp
  class LockFreeQueue (line 12) | class LockFreeQueue {
    type node (line 17) | struct node {
    method tail (line 25) | tail(head.load()) {}
    method LockFreeQueue (line 26) | LockFreeQueue(const LockFreeQueue&) = delete;
    method LockFreeQueue (line 27) | LockFreeQueue(LockFreeQueue&& other) : head(other.head.load()), tail(o...
    method LockFreeQueue (line 31) | LockFreeQueue& operator=(const LockFreeQueue&) = delete;
    method LockFreeQueue (line 32) | LockFreeQueue& operator=(LockFreeQueue&& rhs) {
    method node (line 50) | node* pop_head() {
    method empty (line 60) | bool empty() const {
    method pop (line 63) | std::shared_ptr<value_type> pop() {
    method push (line 73) | void push(value_type new_value) {

FILE: c-cpp/09_queue/ring_queue.c
  type ring_queue (line 6) | struct ring_queue {
  function alloc_queue (line 12) | int alloc_queue(struct ring_queue* queue, int cap)
  function free_queue (line 28) | void free_queue(struct ring_queue *queue)
  function _valid_index (line 35) | int _valid_index(int curr, int step, int cap)
  function _next (line 40) | int _next(int curr, int cap)
  function is_empty (line 45) | bool is_empty(struct ring_queue *queue)
  function is_full (line 50) | bool is_full(struct ring_queue *queue)
  function enqueue (line 56) | int enqueue(struct ring_queue* queue, int elem)
  function dequeue (line 66) | int dequeue(struct ring_queue* queue, int *elem)
  function size (line 77) | int size(struct ring_queue* queue)
  function dump (line 86) | void dump(struct ring_queue* queue)
  function main (line 98) | int main()

FILE: c-cpp/10_recursive/one_two_step.c
  function helper (line 14) | int helper(int n ,int *vlaue)
  function climbStaris (line 27) | int climbStaris(int n)
  function main (line 48) | int main()

FILE: c-cpp/10_recursive/one_two_step.cc
  class SolutionOFOneTwoStep (line 4) | class SolutionOFOneTwoStep {
    type POLICY (line 9) | enum class POLICY {
    method recursive (line 15) | size_t recursive(size_t steps) {
    method nonrecursive (line 25) | size_t nonrecursive(size_t steps) {
    method debug (line 47) | static void debug() {
  function main (line 57) | int main() {

FILE: c-cpp/11_sorts/sorts.c
  type array (line 5) | struct array {
  function dump (line 11) | void dump(struct array *array)
  function alloc (line 19) | void alloc(struct array *array)
  function bubble_sort (line 24) | void bubble_sort(struct array *array)
  function bubble_sort_test (line 48) | void bubble_sort_test()
  function insertion_sort (line 62) | void insertion_sort(struct array *array)
  function insertion_sort_test (line 82) | void insertion_sort_test()
  function selection_sort (line 96) | void selection_sort(struct array *array)
  function selection_sort_test (line 119) | void selection_sort_test()
  function main (line 133) | int main()

FILE: c-cpp/11_sorts/sorts.cpp
  function swap (line 4) | void swap(int *xp, int *yp)
  function selectionSort (line 11) | void selectionSort(int arr[], int n)
  function printArray (line 30) | void printArray(int arr[], int size)
  function main (line 39) | int main()

FILE: c-cpp/11_sorts/sorts.hpp
  function bubble_sort (line 13) | void bubble_sort(BidirIt first, BidirIt last, BinaryPred comp = BinaryPr...
  function insertion_sort (line 29) | void insertion_sort(BidirIt first, BidirIt last, BinaryPred comp = Binar...
  function selection_sort (line 43) | void selection_sort(BidirIt first, BidirIt last, BinaryPred comp = Binar...
  function bubble_down_sort (line 60) | void bubble_down_sort(FrwdIt first, FrwdIt last, BinaryPred comp = Binar...
  function shell_sort (line 73) | void shell_sort(BidirIt first, BidirIt last, BinaryPred comp = BinaryPre...

FILE: c-cpp/11_sorts/sorts_jinshaohui.c
  function bubble_sort (line 20) | void bubble_sort(int a[],int size)
  function insert_sort (line 52) | void insert_sort(int a[],int size)
  function select_sort (line 75) | void select_sort(int a[],int size)
  function dump (line 100) | void dump(int a[],int size)
  function main (line 113) | int main()

FILE: c-cpp/11_sorts/sorts_test.cc
  function main (line 6) | int main() {

FILE: c-cpp/12_sorts/merge_sort.c
  function dump (line 6) | void dump(int *arr, int size)
  function __merge (line 14) | void __merge(int *arr, int p, int q, int r)
  function __merge_sort (line 43) | void __merge_sort(int *arr, int p, int r)
  function merge_sort (line 56) | void merge_sort(int *arr, int size)
  function merge_verify (line 61) | void merge_verify()
  function merge_sort_test (line 70) | void merge_sort_test()
  function main (line 79) | int main()

FILE: c-cpp/12_sorts/merge_sort.hpp
  type detail (line 13) | namespace detail {
    function OutputIt (line 16) | OutputIt merge(InputIt1 first1, InputIt1 last1,
  function merge_sort (line 38) | void merge_sort(FrwdIt first, FrwdIt last, BinaryPred comp = BinaryPred(...
  function inplace_merge_sort (line 52) | void inplace_merge_sort(BidirIt first, BidirIt last, BinaryPred comp = B...

FILE: c-cpp/12_sorts/merge_sort_test.cc
  function main (line 9) | int main() {

FILE: c-cpp/12_sorts/my12_sorts/merge_sort.c
  function merge_sentry (line 16) | void merge_sentry(int a[],int middle,int left,int right)
  function merge (line 62) | void merge(int a[],int middle,int left,int right)
  function merge_sort (line 114) | void merge_sort(int a[],int left,int right)
  function dump (line 133) | void dump(int a[],int size)
  function main (line 150) | int main()

FILE: c-cpp/12_sorts/my12_sorts/quick_sort.c
  function partition2 (line 21) | int partition2(int a[],int left,int right)
  function partition (line 46) | int partition(int a[],int left,int right)
  function quick_sort (line 77) | void quick_sort(int a[],int left,int right)
  function dump (line 92) | void dump(int a[],int size)
  function helper (line 105) | int helper(int a[],int left,int right,int k)
  function findKthlagest (line 124) | int findKthlagest(int a[],int size,int k)
  function main (line 130) | int main()

FILE: c-cpp/12_sorts/quick_sort.c
  function dump (line 6) | void dump(int *arr, int size)
  function swap (line 14) | void swap(int *a, int *b)
  function partition (line 21) | int partition(int *arr, int p, int r)
  function __quick_sort (line 43) | void __quick_sort(int *arr, int p, int r)
  function quick_sort (line 55) | void quick_sort(int *arr, int size)
  function quick_sort_test (line 60) | void quick_sort_test()
  function main (line 69) | int main()

FILE: c-cpp/12_sorts/quick_sort.hpp
  type detail (line 13) | namespace detail {
    function T (line 15) | const T& median(const T& a, const T& b, const T& c, Compare comp = Com...
    function T (line 28) | const T& iter_median(Iter a, Iter b, Iter c, Compare comp = Compare()) {
    function inplace_partition (line 35) | std::pair<BidirIt, BidirIt> inplace_partition(BidirIt first,
  function quick_sort (line 61) | void quick_sort(BidirIt first, BidirIt last, Compare comp = Compare()) {

FILE: c-cpp/12_sorts/quick_sort_test.cc
  function test_quick_sort (line 11) | void test_quick_sort(std::vector<int> test_data) {
  function main (line 18) | int main() {

FILE: c-cpp/13_sorts/bucket_sort.hpp
  function bucket_sort (line 17) | void bucket_sort(IterT first, IterT last, Compare comp = Compare()) {

FILE: c-cpp/13_sorts/bucket_sort_test.cc
  function test_bucket_sort (line 15) | void test_bucket_sort(Container cont, Compare comp = Compare()) {
  function main (line 22) | int main() {

FILE: c-cpp/13_sorts/counting_sort.hpp
  function counting_sort (line 15) | void counting_sort(IterT first, IterT last) {

FILE: c-cpp/13_sorts/counting_sort_test.cc
  function test_counting_sort (line 13) | void test_counting_sort(Container cont) {
  function main (line 20) | int main() {

FILE: c-cpp/13_sorts/sort.c
  function dump (line 14) | void dump(int a[],int size)
  function count_sort (line 32) | void count_sort(int a[],int size)
  function count_sort_test (line 82) | int count_sort_test()
  function radix_sort (line 93) | void radix_sort(int a[],int size,int num_count)
  function radix_sort_test (line 152) | void radix_sort_test()
  type barrel (line 161) | struct barrel {
  function partition (line 165) | int partition(int a[],int left,int right)
  function quick_sort (line 196) | void quick_sort(int a[],int left,int right)
  function bucket_sort (line 211) | void bucket_sort(int data[], int size)
  function bucket_sort_test (line 250) | void bucket_sort_test()
  function main (line 260) | int main()

FILE: c-cpp/14_sorts/counting_sort.c
  function dump (line 6) | void dump(int *arr, int size)
  function counting_sort (line 15) | void counting_sort(int *arr, int size)
  function counting_sort_test (line 54) | void counting_sort_test()
  function main (line 62) | int main()

FILE: c-cpp/15_bsearch/binary_search.c
  function binary_search_r (line 8) | int binary_search_r(int *arr, int size, int val)
  function binary_search_i (line 32) | int binary_search_i(int *arr, int size, int val)
  function iteratioin_test (line 50) | void iteratioin_test(bs binary_search)
  function main (line 87) | int main()

FILE: c-cpp/15_bsearch/bsearch.hpp
  function IterT (line 17) | IterT bsearch(IterT first,

FILE: c-cpp/15_bsearch/bsearch_c/bsearch.c
  function mybsearch (line 13) | int mybsearch(int a[],int size,int value)
  function helper (line 41) | int helper(int a[], int left,int right,int value)
  function mybsearch_2 (line 66) | int mybsearch_2(int a[],int size,int value)
  function main (line 72) | int main()

FILE: c-cpp/15_bsearch/bsearch_c/sqrt.c
  function mybsearch (line 16) | double mybsearch(double num)
  function main (line 43) | int main()

FILE: c-cpp/15_bsearch/bsearch_test.cc
  function test_bsearch (line 11) | void test_bsearch(const VecT& test, T target) {
  function main (line 16) | int main() {

FILE: c-cpp/16_bsearch/bsearch.c
  function mybsearch_1 (line 21) | int mybsearch_1(int a[],int size,int value)
  function mybsearch_2 (line 57) | int mybsearch_2(int a[],int size,int value)
  function mybsearch_3 (line 92) | int mybsearch_3(int a[],int size,int value)
  function mybsearch_4 (line 125) | int mybsearch_4(int a[],int size,int value)
  function main (line 157) | int main()

FILE: c-cpp/16_bsearch/bsearch_variant.c
  function binary_search (line 7) | int binary_search(int *arr, int size, int val)
  function binary_search_first (line 38) | int binary_search_first(int *arr, int size, int val)
  function binary_search_last (line 59) | int binary_search_last(int *arr, int size, int val)
  function binary_search_first_r (line 78) | int binary_search_first_r(int *arr, int size, int val)
  function binary_search_last_r (line 108) | int binary_search_last_r(int *arr, int size, int val)
  function binary_search_first_bigger (line 140) | int binary_search_first_bigger(int *arr, int size, int val)
  function binary_search_first_bigger_r (line 159) | int binary_search_first_bigger_r(int *arr, int size, int val)
  function binary_search_last_smaller (line 182) | int binary_search_last_smaller(int *arr, int size, int val)
  function binary_search_last_smaller_r (line 201) | int binary_search_last_smaller_r(int *arr, int size, int val)
  function main (line 224) | int main()

FILE: c-cpp/16_bsearch/bsearch_varients.hpp
  type BsearchPolicy (line 11) | enum class BsearchPolicy { UNSPECIFIED, FIRST, LAST, FIRST_NOT_LESS, LAS...
  function IterT (line 19) | IterT bsearch(IterT first,
  function IterT (line 82) | IterT bsearch(IterT first,

FILE: c-cpp/16_bsearch/bsearch_varients_test.cc
  function test_bsearch (line 11) | void test_bsearch(const VecT& test,
  function main (line 18) | int main() {

FILE: c-cpp/17_skiplist/SkipList.cpp
  class CNode (line 33) | class CNode
  class CSkipList (line 76) | class CSkipList
  function main (line 117) | int main()
  function CNode (line 170) | CNode** CNode::GetIdxList()
  function CNode (line 211) | CNode* CSkipList::Find(int v)
  function GetRandom (line 345) | int GetRandom()

FILE: c-cpp/17_skiplist/skiplist.c
  type node (line 11) | struct node {
  type skip_list (line 17) | struct skip_list {
  function node_init (line 23) | void node_init(struct node* node)
  function skip_list_init (line 28) | void skip_list_init(struct skip_list* sl)
  function random_init (line 35) | void random_init()
  function random_level (line 46) | int random_level(void)
  function random_level_test (line 59) | void random_level_test()
  function insert (line 68) | void insert(struct skip_list *sl, int val)
  type node (line 105) | struct node
  type skip_list (line 105) | struct skip_list
  type node (line 107) | struct node
  function delete (line 122) | void delete(struct skip_list* sl, int val)
  function print_sl (line 170) | void print_sl(struct skip_list* sl)
  function main (line 189) | int main()

FILE: c-cpp/17_skiplist/skiplist.hpp
  class skiplist (line 18) | class skiplist {
    type InternalNode (line 26) | struct InternalNode {
      method InternalNode (line 31) | InternalNode(const key_type& k, const size_type lv)
      method InternalNode (line 33) | InternalNode(const value_type& v, const size_type lv)
    method skiplist (line 53) | skiplist() {
    method skiplist (line 60) | skiplist(std::initializer_list<value_type> init) : skiplist() {
    method skiplist (line 65) | skiplist(const skiplist& other) = delete;
    method skiplist (line 66) | skiplist(skiplist&& other) :
    method skiplist (line 86) | skiplist& operator=(const skiplist& other) = delete;
    method skiplist (line 87) | skiplist& operator=(skiplist&& other)      = delete;
    method size_type (line 90) | inline size_type get_random_level() const {
    method size_type (line 93) | static size_type get_node_level(const node_type* node) {
    method node_type (line 96) | static node_type* make_node(const value_type& v, const size_type lv) {
    method node_type (line 103) | node_type* get_first_equal(const value_type& v) const {
    method get_predecessors (line 120) | std::vector<node_type*> get_predecessors(const value_type& v) const {
    method value_type (line 135) | const value_type& find(const value_type& target) {
    method insert (line 143) | void  insert(const value_type& value) {
    method erase (line 152) | void  erase(const value_type& value) {
    method print (line 163) | void  print(std::ostream& os) const {

FILE: c-cpp/17_skiplist/skiplist_c/skiplist.c
  function node (line 16) | node* skip_list_create_node(int level,int key,int value)
  function skiplist (line 32) | skiplist * skip_list_create(int max_level)
  function skip_list_destory (line 55) | void skip_list_destory(skiplist * list)
  function skip_list_level (line 77) | int skip_list_level(skiplist * list)
  function skip_list_insert (line 91) | int skip_list_insert(skiplist *list,int key,int value)
  function skip_list_delete (line 158) | int skip_list_delete(skiplist * list, int key ,int *value)
  function skip_list_search (line 228) | int skip_list_search(skiplist *list,int key,int *value)
  function skip_list_dump (line 255) | void skip_list_dump(skiplist *list)
  function main (line 275) | int main()

FILE: c-cpp/17_skiplist/skiplist_c/skiplist.h
  type node (line 12) | typedef struct _node
  type skiplist (line 20) | typedef struct _skiplist

FILE: c-cpp/17_skiplist/skiplist_test.cc
  function main (line 10) | int main() {

FILE: c-cpp/17_skiplist/skiplist_tr.hpp
  type skiplist_detail (line 24) | namespace skiplist_detail {
    type InternalNode (line 26) | struct InternalNode {
      method InternalNode (line 32) | InternalNode() = delete;
      method InternalNode (line 33) | explicit InternalNode(const Key& k) : key(k) {}
    class random_level (line 37) | class random_level {
      method random_level (line 44) | random_level(IntType max_level, double prob) : dist(max_level - 1, p...
      method IntType (line 45) | inline IntType operator()() const { return dist(gen); }
  type erase_policy (line 49) | enum class erase_policy { ALL, SINGLE }
  class skiplist (line 54) | class skiplist {
    method skiplist (line 75) | skiplist() : rl_(max_lv_, prob_) {
    method skiplist (line 78) | explicit skiplist(const size_type max_lv, const double prob = 0.5)
    method skiplist (line 82) | skiplist(skiplist&& other) = default;
    method skiplist (line 83) | skiplist& operator=(skiplist&& other) = default;
    method skiplist (line 86) | skiplist(InputIt first, InputIt last) : skiplist() {
    method skiplist (line 94) | skiplist(std::initializer_list<value_type> init) : skiplist(init.begin...
    method skiplist (line 97) | skiplist(const skiplist&) = delete;
    method skiplist (line 98) | skiplist& operator=(const skiplist&) = delete;
    method init_internally (line 101) | void init_internally() {
    method const_iterator (line 129) | const_iterator find_helper(const hash_type& key) const {
    method find_predecessors (line 163) | std::vector<iterator> find_predecessors(const hash_type& key, const si...
    method size_type (line 210) | size_type size() const {
    method empty (line 213) | bool empty() const {
    method iterator (line 216) | iterator begin() {
    method const_iterator (line 219) | const_iterator begin() const {
    method const_iterator (line 222) | const_iterator cbegin() const {
    method iterator (line 225) | iterator end() {
    method const_iterator (line 228) | const_iterator end() const {
    method const_iterator (line 231) | const_iterator cend() const {
    method grow (line 234) | void grow(const size_type new_max_lv) {
    method grow (line 258) | void grow() {
    method size_type (line 261) | size_type capability() const {
    method const_iterator (line 266) | const_iterator find(const value_type& target) const {
    method insert (line 274) | void insert(const value_type& target) {
    method erase (line 311) | void erase(const value_type& target,

FILE: c-cpp/17_skiplist/skiplist_tr_test.cc
  function main (line 12) | int main() {

FILE: c-cpp/18_hashtable/hash_map.cc
  class hash_map (line 16) | class hash_map {
    method hash_map (line 28) | hash_map() {
    method empty (line 33) | bool empty() const { return empty_; }
    method size_type (line 34) | size_type size() const { return size_; }
    method size_type (line 35) | size_type max_size() const { return primes_[size_level_]; }
    method mapped_type (line 38) | mapped_type& operator[](const key_type& key) {
    method load_factor (line 48) | double load_factor() const { return static_cast<double>(size()) / max_...
    method max_load_factor (line 49) | double max_load_factor() const { return max_load_factor_; }
    method expand (line 50) | void expand() const {
    method size_type (line 64) | size_type find_hash(const key_type& key) const {
    method construct_new_on_position (line 73) | bool construct_new_on_position(const size_type pos, const key_type& ke...
  function main (line 92) | int main() {

FILE: c-cpp/18_hashtable/hashtable.c
  type hash_table (line 13) | struct hash_table {
  function hash_table_reset (line 18) | void hash_table_reset(struct hash_table *table)
  function hash_function (line 27) | unsigned int hash_function(unsigned long value)
  function dump_hash_table (line 32) | void dump_hash_table(struct hash_table *table)
  function hash_function_test (line 46) | void hash_function_test()
  function next_probe (line 58) | unsigned int next_probe(unsigned int prev_key)
  function next_probe_test (line 63) | void next_probe_test()
  function hash_table_add (line 76) | void hash_table_add(struct hash_table *table, unsigned long value)
  function hash_table_slot (line 90) | unsigned int hash_table_slot(struct hash_table *table, unsigned long value)
  function hash_table_find (line 104) | bool hash_table_find(struct hash_table *table, unsigned long value)
  function hash_table_del (line 109) | void hash_table_del(struct hash_table *table, unsigned long value)
  function hash_table_add_test (line 134) | void hash_table_add_test()
  function hash_table_del_test1 (line 147) | void hash_table_del_test1()
  function hash_table_del_test2 (line 162) | void hash_table_del_test2()
  function main (line 178) | int main()

FILE: c-cpp/18_hashtable/listhash/listhash.c
  function hashtab (line 18) | hashtab * hashtab_create(int size,hash_key_func hash_value,
  function hashtab_destory (line 55) | void hashtab_destory(hashtab *h)
  function hashtab_insert (line 83) | int hashtab_insert(hashtab * h,void *key,void *data)
  function hashtab_node (line 136) | hashtab_node *hashtab_delete(hashtab *h, void *key)
  function hashtab_dump (line 200) | void hashtab_dump(hashtab *h)
  type test_node (line 225) | struct test_node
  function siample_hash (line 231) | unsigned int siample_hash(const char *str)
  function hashtab_hvalue (line 244) | int hashtab_hvalue(hashtab *h,const void *key)
  function hashtab_keycmp (line 249) | int hashtab_keycmp(hashtab *h,const void *key1,const void *key2)
  function hashtab_node_free (line 254) | void hashtab_node_free(hashtab_node*node)
  function main (line 264) | int main ()

FILE: c-cpp/18_hashtable/listhash/listhash.h
  type hashtab_node (line 16) | typedef struct _hashtab_node
  type hashtab (line 23) | typedef struct _hashtab
  type _hashtab (line 36) | struct _hashtab
  type _hashtab (line 37) | struct _hashtab

FILE: c-cpp/19_Dlisthash/Dlist.h
  type list_head (line 12) | struct list_head {
  function INIT_LIST_HEAD (line 24) | static inline void INIT_LIST_HEAD(struct list_head *list)
  function __list_add (line 31) | static inline void __list_add(struct list_head *new,
  function list_add (line 42) | static inline void list_add(struct list_head *new, struct list_head *head)
  function list_add_tail (line 48) | static inline void list_add_tail(struct list_head *new, struct list_head...
  function __list_del (line 54) | static inline void __list_del(struct list_head * prev, struct list_head ...
  function list_del (line 61) | static inline void list_del(struct list_head *entry)
  function __list_del_entry (line 67) | static inline void __list_del_entry(struct list_head *entry)
  function list_del_init (line 73) | static inline void list_del_init(struct list_head *entry)
  function list_replace (line 80) | static inline void list_replace(struct list_head *old,
  function list_empty (line 90) | static inline int list_empty(const struct list_head *head)

FILE: c-cpp/19_Dlisthash/LinkedHashMap.c
  function LinkedHashMap (line 16) | LinkedHashMap *LinkedHashMap_Create(int size,int nel_max,
  function LinkedHashMap_destory (line 56) | void LinkedHashMap_destory(LinkedHashMap *h)
  function LinkedHashMap_insert (line 84) | int LinkedHashMap_insert(LinkedHashMap *h,void *key,void *data)
  function LiskedHashMapNode (line 152) | LiskedHashMapNode * LinkedHashMap_delete(LinkedHashMap *h,void *key)
  function LinkedHashMap__dump (line 218) | void LinkedHashMap__dump(LinkedHashMap *h)
  type test_node (line 257) | struct test_node
  function siample_hash (line 263) | unsigned int siample_hash(const char *str)
  function hashtab_hvalue (line 276) | int hashtab_hvalue(LinkedHashMap *h,const void *key)
  function hashtab_keycmp (line 281) | int hashtab_keycmp(LinkedHashMap *h,const void *key1,const void *key2)
  function hashtab_node_free (line 286) | void hashtab_node_free(LiskedHashMapNode *node,int flg)
  function main (line 300) | int main ()

FILE: c-cpp/19_Dlisthash/LinkedHashMap.h
  type LiskedHashMapNode (line 14) | typedef struct _lisked_hash_map_node
  type LinkedHashMap (line 22) | typedef struct _lisked_hash_map
  type _lisked_hash_map (line 35) | struct _lisked_hash_map
  type _lisked_hash_map (line 36) | struct _lisked_hash_map

FILE: c-cpp/23_binarytree/binarytree.c
  type node (line 11) | struct node {
  type binary_tree (line 15) | struct binary_tree {
  function init_binary_tree (line 22) | void init_binary_tree(struct binary_tree *tree)
  type node (line 31) | struct node
  type node (line 33) | struct node
  type node (line 35) | struct node
  function fake_a_tree (line 43) | void fake_a_tree(struct binary_tree* tree)
  function _in_order (line 57) | void _in_order(struct binary_tree* tree, int index)
  function in_order (line 71) | void in_order(struct binary_tree* tree)
  function main (line 76) | int main()

FILE: c-cpp/23_binarytree/tree/binarytree.c
  type Tnode (line 15) | typedef struct _treenode
  function binarytree_create (line 22) | void binarytree_create(Tree **Root)
  function binarytree_destory (line 51) | void binarytree_destory(Tree *root)
  function binarytree_preorder (line 64) | void binarytree_preorder(Tree *root)
  function binarytree_inorder (line 76) | void binarytree_inorder(Tree *root)
  function binarytree_postorder (line 88) | void binarytree_postorder(Tree *root)
  function binarytree_levelorder (line 100) | void binarytree_levelorder(Tree * root)
  function binarytree_printfleaf (line 135) | void binarytree_printfleaf(Tree *root)
  function binarytree_getleafnum (line 153) | int binarytree_getleafnum(Tree*root)
  function binarytree_gethigh (line 169) | int binarytree_gethigh(Tree *root)
  function main (line 185) | int main()

FILE: c-cpp/23_binarytree/tree/list_queue.c
  function list_queue (line 14) | list_queue *list_queue_create()
  function list_queue_enqueue (line 30) | int list_queue_enqueue(list_queue *queue,void *data)
  function list_queue_dequeue (line 63) | int list_queue_dequeue(list_queue *queue,void **data)

FILE: c-cpp/23_binarytree/tree/list_queue.h
  type queue_node (line 12) | typedef struct _list_queue_node
  type list_queue (line 18) | typedef struct _list_queue

FILE: c-cpp/24_binarysearchtree/binary_search_tree.cpp
  type treeNode (line 16) | struct treeNode
  class binarySearchTree (line 23) | class binarySearchTree
    method binarySearchTree (line 29) | binarySearchTree() : num(0)
    method find (line 36) | bool find(DataType it, treeNode *root)
    method find_data (line 49) | bool find_data(DataType it)
    method DataType (line 64) | DataType get_max()
    method DataType (line 75) | DataType get_min()
    method insert_data (line 86) | void insert_data(DataType it)
    method DataType (line 116) | DataType get_prenode(DataType it)
    method DataType (line 140) | DataType get_postnode(DataType it)
    method mid_order (line 165) | void mid_order(treeNode *rt)
    method order (line 174) | void order()
    method get_high (line 181) | int get_high(treeNode *rt)
    method high (line 192) | int high()
    method delet (line 199) | void delet(DataType it)
  function main (line 249) | int main()

FILE: c-cpp/24_binarysearchtree/binarysearchtree.c
  function bstree (line 15) | bstree *bstree_create(compare_fuc compare,destory_fuc destory)
  function bstree_node (line 32) | bstree_node *bstree_search(bstree *tree,mytype data)
  function bstree_insert (line 63) | int bstree_insert(bstree * tree, mytype data)
  function bstree_delete (line 122) | int bstree_delete(bstree *tree,mytype data)
  function bstree_destory_node (line 211) | void bstree_destory_node(bstree *tree,bstree_node *root)
  function bstree_destory (line 224) | void bstree_destory(bstree *tree)
  function bstree_inorder_node (line 232) | void bstree_inorder_node(bstree_node *root)
  function bstree_dump (line 246) | void bstree_dump(bstree *tree)
  function bstree_compare (line 259) | int bstree_compare(mytype key1,mytype key2)
  function main (line 275) | int main()

FILE: c-cpp/24_binarysearchtree/binarysearchtree.h
  type mytype (line 10) | typedef int mytype;
  type bstree_node (line 12) | typedef struct _bstree_node
  type bstree (line 19) | typedef struct _bstree

FILE: c-cpp/24_binarysearchtree/bst.c
  type child_dir (line 7) | enum child_dir {
  type node (line 13) | struct node {
  type root (line 19) | struct root {
  function dump (line 23) | void dump(struct node *node, int level, enum child_dir dir)
  type node (line 41) | struct node
  type root (line 41) | struct root
  type node (line 43) | struct node
  type node (line 57) | struct node
  type node (line 59) | struct node
  type node (line 61) | struct node
  function insert (line 68) | void insert(struct root *root, struct node *new)
  type node (line 100) | struct node
  type root (line 100) | struct root
  type node (line 102) | struct node
  type node (line 103) | struct node
  type node (line 119) | struct node
  function insert_test (line 137) | void insert_test()
  function delete_test (line 163) | void delete_test()
  function main (line 192) | int main()

FILE: c-cpp/24_tree/Trie.c
  type Status (line 16) | typedef int Status;
  type Trie (line 18) | typedef struct Node {
  function Init (line 24) | void Init(TriePtr *T)
  function Insert (line 31) | void Insert(TriePtr T, char *str) {
  function Status (line 55) | Status Search(TriePtr T, char *str) {
  function main (line 79) | int main(int argc, char const *argv[])

FILE: c-cpp/24_tree/binarysearchtree.c
  type Status (line 15) | typedef int Status;
  type ElemType (line 16) | typedef char ElemType;
  type BTree (line 18) | typedef struct node {
  function Status (line 24) | Status Insert(BTreePtr *T, ElemType e) {
  function Status (line 62) | Status Delete(BTreePtr T, ElemType e) {
  function Status (line 128) | Status Find(BTreePtr T, ElemType e) {
  function ElemType (line 150) | ElemType FindMax(BTreePtr T) {
  function ElemType (line 162) | ElemType FindMin(BTreePtr T) {
  function PreOrderTraverse (line 173) | void PreOrderTraverse(BTreePtr T)//前序遍历二叉树
  function DestroyTree (line 186) | void DestroyTree(BTreePtr T) {
  function main (line 205) | int main(int argc, char const *argv[])

FILE: c-cpp/28_heap/heap.c
  type element (line 11) | struct element {
  type heap (line 15) | struct heap {
  function init_heap (line 22) | void init_heap(struct heap *heap)
  function dump_heap (line 31) | void dump_heap(struct heap *heap, int index)
  function dump (line 55) | void dump(struct heap *heap, int elements)
  type element (line 64) | struct element
  type element (line 66) | struct element
  type element (line 68) | struct element
  function fake_a_heap (line 76) | void fake_a_heap(struct heap *heap)
  function swap (line 90) | void swap(struct heap *heap, int i, int j)
  function heapify (line 99) | void heapify(struct heap *heap, int parent)
  function build_heap (line 123) | void build_heap(struct heap *heap)
  function heap_sort (line 131) | int heap_sort(struct heap *heap)
  function main (line 144) | int main()

FILE: c-cpp/30_Graph/graph.c
  type vertex (line 7) | struct vertex
  type vertex_adjs (line 8) | struct vertex_adjs {
  type vertex (line 13) | struct vertex {
  type graph (line 19) | struct graph {
  function init_graph (line 23) | void init_graph(struct graph *graph)
  type vertex (line 31) | struct vertex
  type vertex (line 33) | struct vertex
  type vertex (line 35) | struct vertex
  type vertex_adjs (line 45) | struct vertex_adjs
  type vertex (line 45) | struct vertex
  type vertex_adjs (line 47) | struct vertex_adjs
  type vertex_adjs (line 49) | struct vertex_adjs
  function insert_adj (line 59) | void insert_adj(struct vertex *v, struct vertex *adj)
  function dump_raw (line 71) | void dump_raw(struct graph *graph)
  function fake_a_graph (line 101) | void fake_a_graph(struct graph *graph)
  function main (line 131) | int main()

FILE: c-cpp/bst.c
  type child_dir (line 7) | enum child_dir {
  type node (line 13) | struct node {
  type root (line 19) | struct root {
  function dump (line 23) | void dump(struct node *node, int level, enum child_dir dir)
  type node (line 41) | struct node
  type root (line 41) | struct root
  type node (line 43) | struct node
  type node (line 57) | struct node
  type node (line 59) | struct node
  type node (line 61) | struct node
  function insert (line 68) | void insert(struct root *root, struct node *new)
  type node (line 100) | struct node
  type root (line 100) | struct root
  type node (line 102) | struct node
  type node (line 103) | struct node
  type node (line 119) | struct node
  function insert_test (line 137) | void insert_test()
  function delete_test (line 163) | void delete_test()
  function main (line 192) | int main()

FILE: csharp/05-array/Array.cs
  class Array (line 5) | public sealed class Array<T> where T : IComparable<T>
    method Array (line 11) | public Array(int capacity)
    method Insert (line 22) | public void Insert(int index, T newElem)
    method Find (line 46) | public T Find(int index)
    method IndexOf (line 57) | public int IndexOf(T val)
    method Delete (line 74) | public bool Delete(int index)
    method Delete (line 96) | public bool Delete(T val)
    method Clear (line 110) | public void Clear()

FILE: csharp/06-linkedlist/LRUWithArray.cs
  class LRUWithArray (line 8) | public class LRUWithArray
    method LRUWithArray (line 12) | public LRUWithArray(int capacity)
    method Set (line 20) | public void Set(int val)

FILE: csharp/06-linkedlist/LRUWithLinkedList.cs
  class LRUWithLinkedList (line 6) | public class LRUWithLinkedList
    method LRUWithLinkedList (line 14) | public LRUWithLinkedList(int capacity = 10)
    method Set (line 25) | public void Set(int val)

FILE: csharp/06-linkedlist/SingleLinkedList.cs
  class SingleLinkedList (line 9) | public class SingleLinkedList<T> where T : IComparable<T>
    method SingleLinkedList (line 11) | public SingleLinkedList()
    method SingleLinkedList (line 16) | public SingleLinkedList(params T[] list)
    method Insert (line 38) | public ListNode<T> Insert(int position, T newElem)
    method Find (line 63) | public ListNode<T> Find(int position)
    method Find (line 82) | public ListNode<T> Find(T elem)
    method Delete (line 96) | public ListNode<T> Delete(T value)
    method Delete (line 114) | public ListNode<T> Delete(int position)
    method Clear (line 137) | public void Clear()
  class ListNode (line 152) | public class ListNode<T>
    method ListNode (line 154) | public ListNode(T value)

FILE: csharp/07-linkedlist/_07_linkedlist/SingleLinkedListAlgo.cs
  class SingleLinkedListAlgo (line 15) | public class SingleLinkedListAlgo<T> : SingleLinkedList<T> where T : ICo...
    method SingleLinkedListAlgo (line 17) | public SingleLinkedListAlgo(params T[] list) : base(list)
    method Reverse (line 24) | public void Reverse()
    method HasCycle (line 53) | public bool HasCycle()
    method Merge (line 76) | public SingleLinkedListAlgo<T> Merge(SingleLinkedListAlgo<T> listAlgo)
    method RemoveNthNodeFromEnd (line 124) | public void RemoveNthNodeFromEnd(int n)
    method FindMiddleNode (line 155) | public ListNode<T> FindMiddleNode()

FILE: csharp/08-stack/algo08_stack/ArrayStack.cs
  class ArrayStack (line 5) | public class ArrayStack<T>
    method ArrayStack (line 13) | public ArrayStack(int capacity)
    method Push (line 22) | public void Push(T val)
    method Pop (line 31) | public T Pop()

FILE: csharp/08-stack/algo08_stack/LinkedStack.cs
  class LinkedStack (line 5) | public class LinkedStack<T>
    method Push (line 11) | public void Push(T val)
    method Pop (line 20) | public T Pop()
    method Clear (line 32) | public void Clear()
  class StackListNode (line 41) | public class StackListNode<T>
    method StackListNode (line 43) | public StackListNode(T nodeValue)

FILE: csharp/08-stack/algo08_stack/LinkedStackBrowser.cs
  class LinkedStackBrowser (line 6) | public class LinkedStackBrowser
    method Open (line 11) | public void Open(string url)
    method Backward (line 18) | public string Backward()
    method Forward (line 29) | public string Forward()

FILE: csharp/Tests/_05_array_tests/Array.Tests.cs
  class ArrayTests (line 8) | public class ArrayTests
    method ArrayTests (line 13) | public ArrayTests(ITestOutputHelper output)
    method PrintList (line 19) | private void PrintList()
    method Length_Equal_1_After_InsertOneElement (line 28) | [Fact]
    method Insert_ThrowIndexOutOfRangeException_When_Index_GreaterThan_Length (line 35) | [Fact]
    method Insert_ThrowIndexOutOfRangeException_When_Index_LessThan_Zero (line 43) | [Fact]
    method Insert_ThrowIndexOutOfRangeException_When_List_Is_Full (line 50) | [Fact]
    method Delete_ThrowIndexOutOfRangeException_When_Index_LessThan_Zero (line 70) | [Fact]
    method Delete_ThrowIndexOutOfRangeException_When_Index_GreaterThan_Length (line 77) | [Fact]
    method Delete_First_Element_Success (line 86) | [Fact]
    method Delete_Last_Element_Success (line 97) | [Fact]
    method Delete_Middle_Element (line 109) | [Fact]
    method Find_ThrowsIndexOutOfRangeException_When_Index_LessThan_Zero (line 121) | [Fact]
    method Find_ThrowsIndexOutOfRangeException_When_Index_GreaterThan_Length (line 133) | [Fact]
    method Find_Last_Position_Return_33 (line 145) | [Fact]
    method Find_First_Element_Return_11 (line 158) | [Fact]
    method IndexOf_Return_Negative_1_When_Element_Not_Exist (line 171) | [Fact]
    method IndexOf_Return_First_Index (line 184) | [Fact]
    method IndexOf_Return_Last_Index (line 197) | [Fact]
    method Clear_Then_Length_Equal_Zero (line 210) | [Fact]

FILE: csharp/Tests/_06_linkedlist_tests/BaseLinkedListTests.cs
  class BaseLinkedListTests (line 6) | public class BaseLinkedListTests
    method PrintLinkedList (line 8) | protected void PrintLinkedList<T> (SingleLinkedList<T> list) where T :...

FILE: csharp/Tests/_06_linkedlist_tests/LRUWithArray.Tests.cs
  class LRUWithArrayTests (line 8) | public class LRUWithArrayTests
    method LRUWithArrayTests (line 12) | public LRUWithArrayTests(ITestOutputHelper output)
    method PrintList (line 17) | private void PrintList(Array<int> list)
    method LRU_Set_Value_When_Not_Existed (line 26) | [Fact]
    method LRU_Set_Value_When_Existed (line 45) | [Fact]
    method LRU_Set_Value_When_Full (line 63) | [Fact]

FILE: csharp/Tests/_06_linkedlist_tests/LRUWithLinkedList.Tests.cs
  class LRUWithLinkedListTests (line 7) | public class LRUWithLinkedListTests : BaseLinkedListTests
    method LRU_Set_Value_When_Not_Existed (line 9) | [Fact]
    method LRU_Set_Value_When_Existed (line 27) | [Fact]
    method LRU_Set_Value_When_Full (line 45) | [Fact]

FILE: csharp/Tests/_06_linkedlist_tests/SingleLinkedList.Tests.cs
  class SingleLinkedListTests (line 8) | public class SingleLinkedListTests : BaseLinkedListTests
    method Insert_3_Elements_Return_Length_3 (line 10) | [Fact]
    method Insert_Some_Elements_Then_Verify_First (line 20) | [Fact]
    method Insert_Some_Elements_Then_Verify_Last (line 28) | [Fact]
    method Find_Return_Null_When_Position_LessThan_1 (line 36) | [Fact]
    method Find_Return_Null_When_Position_GreaterThan_Length (line 45) | [Fact]
    method Find_Return_Correct_When_Position_Valid (line 54) | [Fact]
    method Delete_Return_Null_When_Position_LessThan_1 (line 63) | [Fact]
    method Delete_Return_Null_When_Position_GreaterThan_Length (line 72) | [Fact]
    method Delete_By_Value_Success_When_Element_Exist (line 81) | [Fact]
    method Delete_By_Value_Success_When_Element_Not_Exist (line 95) | [Fact]
    method Delete_By_Value_Success_When_Delete_First (line 109) | [Fact]
    method Delete_By_Value_Success_When_Delete_Last (line 123) | [Fact]
    method Delete_Success_When_Position_Valid (line 137) | [Fact]
    method Clear_Length_Equal_0 (line 151) | [Fact]
    method Clear_First_Is_Null (line 161) | [Fact]

FILE: csharp/Tests/_07_linkedlist_tests/SingleLinkedListAlgo.Tests.cs
  class SingleLinkedListAlgoTests (line 9) | public class SingleLinkedListAlgoTests : BaseLinkedListTests
    method Reverse_When_List_Is_Empty (line 11) | [Fact]
    method Reverse_When_List_Has_Many_Elements (line 23) | [Fact]
    method HasCycle_List_Empty (line 36) | [Fact]
    method HasCycle_False_When_List_Length_1 (line 47) | [Fact]
    method HasCycle_False_When_List_Length_2 (line 57) | [Fact]
    method HasCycle_True_When_List_Length_2 (line 67) | [Fact]
    method HasCycle_False (line 82) | [Fact]
    method HasCycle_True (line 93) | [Fact]
    method Merge (line 116) | [Fact]
    method Remove_2th_Node_From_End (line 129) | [Fact]
    method FindMiddleNode (line 140) | [Fact]

FILE: csharp/Tests/algo08_stack_tests/ArrayStack.Tests.cs
  class ArrayStackTests (line 8) | public class ArrayStackTests
    method ArrayStackTests (line 12) | public ArrayStackTests(ITestOutputHelper output)
    method PrintStackArray (line 17) | private void PrintStackArray<T>(ArrayStack<T> list)
    method Push_3_Elements_Then_Length_Equal_3 (line 28) | [Fact]
    method Push_Throw_InvalidOperationException_When_Stack_Full (line 41) | [Fact]
    method Pop_Throw_InvalidOperationException_When_Stack_Empty (line 57) | [Fact]
    method Pop_Valid_When_Stack_Not_Empty (line 68) | [Fact]

FILE: csharp/Tests/algo08_stack_tests/LinkedStack.Tests.cs
  class LinkedStackTests (line 8) | public class LinkedStackTests
    method LinkedStackTests (line 12) | public LinkedStackTests(ITestOutputHelper output)
    method PrintStackLinkedList (line 17) | private void PrintStackLinkedList<T>(LinkedStack<T> list)
    method Push_3_Elements_Then_Length_Equal_3 (line 28) | [Fact]
    method Pop_Throw_InvalidOperationException_When_Stack_Empty (line 41) | [Fact]
    method Pop_Valid_When_Stack_Not_Empty (line 52) | [Fact]

FILE: csharp/Tests/algo08_stack_tests/LinkedStackBrowser.Tests.cs
  class LinkedStackBrowserTests (line 7) | public class LinkedStackBrowserTests
    method LinkedStackBrowserTests (line 11) | public LinkedStackBrowserTests(ITestOutputHelper output)
    method Browser_Open_4_Links_Back_2_Return_Right_Link (line 16) | [Fact]
    method Browser_Open_4_Links_Back_4_Return_Empty (line 31) | [Fact]
    method Browser_Forward_Before_End (line 49) | [Fact]
    method Browser_Forward_Until_End (line 68) | [Fact]
    method Browser_Backward_And_Open_New_Then_Cannot_Forward (line 89) | [Fact]

FILE: go/05_array/array.go
  type Array (line 15) | type Array struct
    method Len (line 31) | func (this *Array) Len() uint {
    method isIndexOutOfRange (line 36) | func (this *Array) isIndexOutOfRange(index uint) bool {
    method Find (line 44) | func (this *Array) Find(index uint) (int, error) {
    method Insert (line 52) | func (this *Array) Insert(index uint, v int) error {
    method InsertToTail (line 68) | func (this *Array) InsertToTail(v int) error {
    method Delete (line 73) | func (this *Array) Delete(index uint) (int, error) {
    method Print (line 86) | func (this *Array) Print() {
  function NewArray (line 21) | func NewArray(capacity uint) *Array {

FILE: go/05_array/array_test.go
  function TestInsert (line 7) | func TestInsert(t *testing.T) {
  function TestDelete (line 25) | func TestDelete(t *testing.T) {
  function TestFind (line 45) | func TestFind(t *testing.T) {

FILE: go/06_linkedlist/palindrome-linked-list.go
  function isPalindrome (line 8) | func isPalindrome(head *ListNode) bool  {

FILE: go/06_linkedlist/palindrome.go
  function isPalindrome1 (line 8) | func isPalindrome1(l *LinkedList) bool {
  function isPalindrome2 (line 41) | func isPalindrome2(l *LinkedList) bool {

FILE: go/06_linkedlist/palindrome_test.go
  function TestPalindrome1 (line 5) | func TestPalindrome1(t *testing.T) {
  function TestPalindrome2 (line 17) | func TestPalindrome2(t *testing.T) {

FILE: go/06_linkedlist/singlelinkedlist.go
  type ListNode (line 10) | type ListNode struct
    method GetNext (line 24) | func (this *ListNode) GetNext() *ListNode {
    method GetValue (line 28) | func (this *ListNode) GetValue() interface{} {
  type LinkedList (line 15) | type LinkedList struct
    method InsertAfter (line 37) | func (this *LinkedList) InsertAfter(p *ListNode, v interface{}) bool {
    method InsertBefore (line 50) | func (this *LinkedList) InsertBefore(p *ListNode, v interface{}) bool {
    method InsertToHead (line 74) | func (this *LinkedList) InsertToHead(v interface{}) bool {
    method InsertToTail (line 79) | func (this *LinkedList) InsertToTail(v interface{}) bool {
    method FindByIndex (line 88) | func (this *LinkedList) FindByIndex(index uint) *ListNode {
    method DeleteNode (line 101) | func (this *LinkedList) DeleteNode(p *ListNode) bool {
    method Print (line 124) | func (this *LinkedList) Print() {
  function NewListNode (line 20) | func NewListNode(v interface{}) *ListNode {
  function NewLinkedList (line 32) | func NewLinkedList() *LinkedList {

FILE: go/06_linkedlist/singlelinkedlist_test.go
  function TestInsertToHead (line 5) | func TestInsertToHead(t *testing.T) {
  function TestInsertToTail (line 13) | func TestInsertToTail(t *testing.T) {
  function TestFindByIndex (line 21) | func TestFindByIndex(t *testing.T) {
  function TestDeleteNode (line 32) | func TestDeleteNode(t *testing.T) {

FILE: go/07_linkedlist/main.go
  type ListNode (line 6) | type ListNode struct
  type LinkedList (line 12) | type LinkedList struct
    method Print (line 17) | func (this *LinkedList) Print() {
    method Reverse (line 34) | func (this *LinkedList) Reverse() {
    method HasCycle (line 54) | func (this *LinkedList) HasCycle() bool {
    method DeleteBottomN (line 107) | func (this *LinkedList) DeleteBottomN(n int) {
    method FindMiddleNode (line 132) | func (this *LinkedList) FindMiddleNode() *ListNode {
  function MergeSortedList (line 72) | func MergeSortedList(l1, l2 *LinkedList) *LinkedList {

FILE: go/07_linkedlist/main_test.go
  function init (line 7) | func init() {
  function TestReverse (line 16) | func TestReverse(t *testing.T) {
  function TestHasCycle (line 22) | func TestHasCycle(t *testing.T) {
  function TestMergeSortedList (line 28) | func TestMergeSortedList(t *testing.T) {
  function TestDeleteBottomN (line 46) | func TestDeleteBottomN(t *testing.T) {
  function TestFindMiddleNode (line 52) | func TestFindMiddleNode(t *testing.T) {

FILE: go/08_stack/SimpleBrowser.go
  type Browser (line 5) | type Browser struct
    method CanForward (line 17) | func (this *Browser) CanForward() bool {
    method CanBack (line 24) | func (this *Browser) CanBack() bool {
    method Open (line 31) | func (this *Browser) Open(addr string) {
    method PushBack (line 36) | func (this *Browser) PushBack(addr string) {
    method Forward (line 40) | func (this *Browser) Forward() {
    method Back (line 49) | func (this *Browser) Back() {
  function NewBrowser (line 10) | func NewBrowser() *Browser {

FILE: go/08_stack/SimpleBrowser_test.go
  function TestBrowser (line 5) | func TestBrowser(t *testing.T) {

FILE: go/08_stack/StackBasedOnArray.go
  type ArrayStack (line 9) | type ArrayStack struct
    method IsEmpty (line 23) | func (this *ArrayStack) IsEmpty() bool {
    method Push (line 30) | func (this *ArrayStack) Push(v interface{}) {
    method Pop (line 44) | func (this *ArrayStack) Pop() interface{} {
    method Top (line 53) | func (this *ArrayStack) Top() interface{} {
    method Flush (line 60) | func (this *ArrayStack) Flush() {
    method Print (line 64) | func (this *ArrayStack) Print() {
  function NewArrayStack (line 16) | func NewArrayStack() *ArrayStack {

FILE: go/08_stack/StackBasedOnArray_test.go
  function TestArrayStack_Push (line 5) | func TestArrayStack_Push(t *testing.T) {
  function TestArrayStack_Pop (line 18) | func TestArrayStack_Pop(t *testing.T) {
  function TestArrayStack_Top (line 32) | func TestArrayStack_Top(t *testing.T) {

FILE: go/08_stack/StackBasedOnLinkedList.go
  type node (line 8) | type node struct
  type LinkedListStack (line 13) | type LinkedListStack struct
    method IsEmpty (line 22) | func (this *LinkedListStack) IsEmpty() bool {
    method Push (line 26) | func (this *LinkedListStack) Push(v interface{}) {
    method Pop (line 30) | func (this *LinkedListStack) Pop() interface{} {
    method Top (line 39) | func (this *LinkedListStack) Top() interface{} {
    method Flush (line 46) | func (this *LinkedListStack) Flush() {
    method Print (line 50) | func (this *LinkedListStack) Print() {
  function NewLinkedListStack (line 18) | func NewLinkedListStack() *LinkedListStack {

FILE: go/08_stack/StackBasedOnLinkedList_test.go
  function TestLinkedListStack_Push (line 5) | func TestLinkedListStack_Push(t *testing.T) {
  function TestLinkedListStack_Pop (line 13) | func TestLinkedListStack_Pop(t *testing.T) {
  function TestLinkedListStack_Top (line 27) | func TestLinkedListStack_Top(t *testing.T) {

FILE: go/08_stack/StatckInterface.go
  type Stack (line 3) | type Stack interface

FILE: go/09_queue/CircularQueue.go
  type CircularQueue (line 5) | type CircularQueue struct
    method IsEmpty (line 22) | func (this *CircularQueue) IsEmpty() bool {
    method IsFull (line 32) | func (this *CircularQueue) IsFull() bool {
    method EnQueue (line 39) | func (this *CircularQueue) EnQueue(v interface{}) bool {
    method DeQueue (line 48) | func (this *CircularQueue) DeQueue() interface{} {
    method String (line 57) | func (this *CircularQueue) String() string {
  function NewCircularQueue (line 12) | func NewCircularQueue(n int) *CircularQueue {

FILE: go/09_queue/CircularQueue_test.go
  function TestCircularQueue_EnQueue (line 5) | func TestCircularQueue_EnQueue(t *testing.T) {
  function TestCircularQueue_DeQueue (line 16) | func TestCircularQueue_DeQueue(t *testing.T) {

FILE: go/09_queue/QueueBasedOnArray.go
  type ArrayQueue (line 5) | type ArrayQueue struct
    method EnQueue (line 16) | func (this *ArrayQueue) EnQueue(v interface{}) bool {
    method DeQueue (line 25) | func (this *ArrayQueue) DeQueue() interface{} {
    method String (line 34) | func (this *ArrayQueue) String() string {
  function NewArrayQueue (line 12) | func NewArrayQueue(n int) *ArrayQueue {

FILE: go/09_queue/QueueBasedOnArray_test.go
  function TestArrayQueue_EnQueue (line 5) | func TestArrayQueue_EnQueue(t *testing.T) {
  function TestArrayQueue_DeQueue (line 16) | func TestArrayQueue_DeQueue(t *testing.T) {

FILE: go/09_queue/QueueBasedOnLinkedList.go
  type ListNode (line 5) | type ListNode struct
  type LinkedListQueue (line 10) | type LinkedListQueue struct
    method EnQueue (line 20) | func (this *LinkedListQueue) EnQueue(v interface{}) {
    method DeQueue (line 32) | func (this *LinkedListQueue) DeQueue() interface{} {
    method String (line 42) | func (this *LinkedListQueue) String() string {
  function NewLinkedListQueue (line 16) | func NewLinkedListQueue() *LinkedListQueue {

FILE: go/09_queue/QueueBasedOnLinkedList_test.go
  function TestListQueue_EnQueue (line 5) | func TestListQueue_EnQueue(t *testing.T) {
  function TestListQueue_DeQueue (line 16) | func TestListQueue_DeQueue(t *testing.T) {

FILE: go/10_recursion/Factorial.go
  type Fac (line 4) | type Fac struct
    method Factorial (line 14) | func (fac *Fac) Factorial(n int) int {
    method Print (line 29) | func (fac *Fac) Print(n int )  {
  function NewFactorial (line 8) | func  NewFactorial(n int) *Fac {

FILE: go/10_recursion/Factorial_test.go
  function TestFac_Factorial (line 5) | func TestFac_Factorial(t *testing.T) {

FILE: go/10_recursion/Fibonacci.go
  type Fibs (line 6) | type Fibs struct
    method Fibonacci (line 16) | func (fib *Fibs)Fibonacci(n int) int {
    method Print (line 33) | func (fib *Fibs)Print(n int) {
  function NewFibs (line 10) | func NewFibs(n int) *Fibs  {

FILE: go/10_recursion/Fibonacci_test.go
  function TestFibs_Fibonacci (line 5) | func TestFibs_Fibonacci(t *testing.T) {

FILE: go/10_recursion/RangAll.go
  type RangeType (line 7) | type RangeType struct
    method RangeALL (line 17) | func (slice *RangeType)RangeALL( start int)  {
  function NewRangeArray (line 11) | func NewRangeArray(n int) *RangeType  {

FILE: go/10_recursion/RangAll_test.go
  function TestRangeALL (line 5) | func TestRangeALL(t *testing.T) {

FILE: go/11_sorts/Sort.go
  function BubbleSort (line 8) | func BubbleSort(a []int, n int) {
  function InsertionSort (line 30) | func InsertionSort(a []int, n int) {
  function SelectionSort (line 50) | func SelectionSort(a []int, n int) {

FILE: go/11_sorts/Sort_test.go
  function TestBubbleSort (line 8) | func TestBubbleSort(t *testing.T) {
  function TestInsertionSort (line 15) | func TestInsertionSort(t *testing.T) {
  function TestSelectionSort (line 22) | func TestSelectionSort(t *testing.T) {

FILE: go/12_sorts/MergeSort.go
  function MergeSort (line 3) | func MergeSort(arr []int) {
  function mergeSort (line 12) | func mergeSort(arr []int, start, end int) {
  function merge (line 23) | func merge(arr []int, start, mid, end int) {

FILE: go/12_sorts/MergeSort_test.go
  function TestMergeSort (line 5) | func TestMergeSort(t *testing.T) {

FILE: go/12_sorts/QuickSort.go
  function QuickSort (line 4) | func QuickSort(arr []int) {
  function separateSort (line 8) | func separateSort(arr []int, start, end int) {
  function partition (line 17) | func partition(arr []int, start, end int) int {

FILE: go/12_sorts/QuickSort_test.go
  function createRandomArr (line 8) | func createRandomArr(length int) []int {
  function TestQuickSort (line 16) | func TestQuickSort(t *testing.T) {

FILE: go/13_sorts/BucketSort.go
  function getMax (line 11) | func getMax(a []int)int{
  function BucketSort (line 22) | func BucketSort(a []int)  {
  function BucketSortSimple (line 50) | func BucketSortSimple(source []int)  {

FILE: go/13_sorts/BucketSort_test.go
  function TestBucketSort (line 5) | func TestBucketSort(t *testing.T) {
  function TestBucketSortSimple (line 11) | func TestBucketSortSimple(t *testing.T) {

FILE: go/14_sorts/CountingSort.go
  function CountingSort (line 5) | func CountingSort(a []int, n int) {

FILE: go/14_sorts/CountingSort_test.go
  function TestCountingSort (line 5) | func TestCountingSort(t *testing.T) {

FILE: go/15_binarysearch/binarysearch.go
  function BinarySearch (line 3) | func BinarySearch(a []int, v int) int {
  function BinarySearchRecursive (line 25) | func BinarySearchRecursive(a []int, v int) int {
  function bs (line 34) | func bs(a []int, v int, low, high int) int {
  function BinarySearchFirst (line 50) | func BinarySearchFirst(a []int, v int) int {
  function BinarySearchLast (line 77) | func BinarySearchLast(a []int, v int) int {
  function BinarySearchFirstGT (line 104) | func BinarySearchFirstGT(a []int, v int) int {
  function BinarySearchLastLT (line 131) | func BinarySearchLastLT(a []int, v int) int {

FILE: go/15_binarysearch/binarysearch_test.go
  function TestBinarySearch (line 5) | func TestBinarySearch(t *testing.T) {
  function TestBinarySearchRecursive (line 17) | func TestBinarySearchRecursive(t *testing.T) {
  function TestBinarySearchFirst (line 29) | func TestBinarySearchFirst(t *testing.T) {
  function TestBinarySearchLast (line 43) | func TestBinarySearchLast(t *testing.T) {
  function TestBinarySearchFirstGT (line 57) | func TestBinarySearchFirstGT(t *testing.T) {
  function TestBinarySearchLastLT (line 81) | func TestBinarySearchLastLT(t *testing.T) {

FILE: go/17_skiplist/skiplist.go
  constant MAX_LEVEL (line 11) | MAX_LEVEL = 16
  type skipListNode (line 15) | type skipListNode struct
  function newSkipListNode (line 27) | func newSkipListNode(v interface{}, score, level int) *skipListNode {
  type SkipList (line 32) | type SkipList struct
    method Length (line 49) | func (sl *SkipList) Length() int {
    method Level (line 54) | func (sl *SkipList) Level() int {
    method Insert (line 59) | func (sl *SkipList) Insert(v interface{}, score int) int {
    method Find (line 116) | func (sl *SkipList) Find(v interface{}, score int) *skipListNode {
    method Delete (line 137) | func (sl *SkipList) Delete(v interface{}, score int) int {
    method String (line 175) | func (sl *SkipList) String() string {
  function NewSkipList (line 42) | func NewSkipList() *SkipList {

FILE: go/17_skiplist/skiplist_test.go
  function TestSkipList (line 5) | func TestSkipList(t *testing.T) {

FILE: go/20_lru/lru_cache.go
  constant hostbit (line 4) | hostbit = uint64(^uint(0)) == ^uint64(0)
  constant LENGTH (line 5) | LENGTH  = 100
  type lruNode (line 8) | type lruNode struct
  type LRUCache (line 18) | type LRUCache struct
    method Get (line 38) | func (this *LRUCache) Get(key int) int {
    method Put (line 50) | func (this *LRUCache) Put(key int, value int) {
    method addNode (line 68) | func (this *LRUCache) addNode(key int, value int) {
    method delNode (line 88) | func (this *LRUCache) delNode() {
    method searchNode (line 108) | func (this *LRUCache) searchNode(key int) *lruNode {
    method moveToTail (line 124) | func (this *LRUCache) moveToTail(node *lruNode) {
  function Constructor (line 28) | func Constructor(capacity int) LRUCache {
  function hash (line 143) | func hash(key int) int {

FILE: go/20_lru/lru_cache_test.go
  function Test_Hostbit (line 10) | func Test_Hostbit(t *testing.T) {
  function Test_LRU (line 14) | func Test_LRU(t *testing.T) {
  function Test_LRU_PutGet (line 28) | func Test_LRU_PutGet(t *testing.T) {
  function Test_LRU_PutGetPutGetGet (line 35) | func Test_LRU_PutGetPutGetGet(t *testing.T) {
  function Test_LRU_PPGPPG (line 45) | func Test_LRU_PPGPPG(t *testing.T) {
  function Test_LRU_PPGPPG_2 (line 57) | func Test_LRU_PPGPPG_2(t *testing.T) {

FILE: go/23_binarytree/binarytree.go
  type TreeNode (line 3) | type TreeNode struct
  function preOrderTraversal (line 9) | func preOrderTraversal(root *TreeNode) []int {
  function inOrderTraversal (line 33) | func inOrderTraversal(root *TreeNode) []int {
  function postOrderTraversal (line 47) | func postOrderTraversal(root *TreeNode) []int {

FILE: go/23_binarytree/binarytree_test.go
  function PreIn2Tree (line 28) | func PreIn2Tree(pre, in []int) *TreeNode {
  function indexOf (line 53) | func indexOf(val int, nums []int) int {
  function Test_preOrderTraversal (line 63) | func Test_preOrderTraversal(t *testing.T) {
  function Test_inOrderTraversal (line 74) | func Test_inOrderTraversal(t *testing.T) {
  function Test_postOrderTraversal (line 85) | func Test_postOrderTraversal(t *testing.T) {

FILE: go/24_tree/BinarySearchTree.go
  type BST (line 3) | type BST struct
    method Find (line 16) | func (this *BST) Find(v interface{}) *Node {
    method Insert (line 31) | func (this *BST) Insert(v interface{}) bool {
    method Delete (line 54) | func (this *BST) Delete(v interface{}) bool {
    method Min (line 131) | func (this *BST) Min() *Node {
    method Max (line 139) | func (this *BST) Max() *Node {
  function NewBST (line 9) | func NewBST(rootV interface{}, compareFunc func(v, nodeV interface{}) in...

FILE: go/24_tree/BinarySearchTree_test.go
  function TestBST_Find (line 17) | func TestBST_Find(t *testing.T) {
  function TestBST_Insert (line 29) | func TestBST_Insert(t *testing.T) {
  function TestBST_Min (line 41) | func TestBST_Min(t *testing.T) {
  function TestBST_Max (line 53) | func TestBST_Max(t *testing.T) {
  function TestBST_DeleteA (line 65) | func TestBST_DeleteA(t *testing.T) {
  function TestBST_DeleteB (line 78) | func TestBST_DeleteB(t *testing.T) {
  function TestBST_DeleteC (line 87) | func TestBST_DeleteC(t *testing.T) {
  function TestBST_DeleteD (line 100) | func TestBST_DeleteD(t *testing.T) {
  function TestBST_DeleteE (line 111) | func TestBST_DeleteE(t *testing.T) {
  function TestBST_DeleteF (line 123) | func TestBST_DeleteF(t *testing.T) {
  function TestBST_DeleteG (line 135) | func TestBST_DeleteG(t *testing.T) {

FILE: go/24_tree/BinaryTree.go
  type BinaryTree (line 5) | type BinaryTree struct
    method InOrderTraverse (line 13) | func (this *BinaryTree) InOrderTraverse() {
    method PreOrderTraverse (line 30) | func (this *BinaryTree) PreOrderTraverse() {
    method PostOrderTraverse (line 47) | func (this *BinaryTree) PostOrderTraverse() {
    method PostOrderTraverse2 (line 68) | func (this *BinaryTree) PostOrderTraverse2() {
  function NewBinaryTree (line 9) | func NewBinaryTree(rootV interface{}) *BinaryTree {

FILE: go/24_tree/BinaryTree_test.go
  function TestBinaryTree_InOrderTraverse (line 5) | func TestBinaryTree_InOrderTraverse(t *testing.T) {
  function TestBinaryTree_PreOrderTraverse (line 14) | func TestBinaryTree_PreOrderTraverse(t *testing.T) {
  function TestBinaryTree_PostOrderTraverse (line 23) | func TestBinaryTree_PostOrderTraverse(t *testing.T) {
  function TestBinaryTree_PostOrderTraverse2 (line 32) | func TestBinaryTree_PostOrderTraverse2(t *testing.T) {

FILE: go/24_tree/StackBasedOnArray.go
  type ArrayStack (line 9) | type ArrayStack struct
    method IsEmpty (line 23) | func (this *ArrayStack) IsEmpty() bool {
    method Push (line 30) | func (this *ArrayStack) Push(v interface{}) {
    method Pop (line 44) | func (this *ArrayStack) Pop() interface{} {
    method Top (line 53) | func (this *ArrayStack) Top() interface{} {
    method Flush (line 60) | func (this *ArrayStack) Flush() {
    method Print (line 64) | func (this *ArrayStack) Print() {
  function NewArrayStack (line 16) | func NewArrayStack() *ArrayStack {

FILE: go/24_tree/TreeNode.go
  type Node (line 5) | type Node struct
    method String (line 15) | func (this *Node) String() string {
  function NewNode (line 11) | func NewNode(data interface{}) *Node {

FILE: go/28_heap/heap.go
  type Heap (line 3) | type Heap struct
    method insert (line 19) | func (heap *Heap) insert(data int) {
    method removeMax (line 39) | func (heap *Heap) removeMax() {
  function NewHeap (line 10) | func NewHeap(capacity int) *Heap {
  function heapifyUpToDown (line 55) | func heapifyUpToDown(a []int, count int) {
  function swap (line 79) | func swap(a []int, i int, j int) {

FILE: go/28_heap/heap_sort.go
  function buidHeap (line 4) | func buidHeap(a []int, n int) {
  function sort (line 14) | func sort(a []int, n int) {
  function heapifyUpToDown (line 26) | func heapifyUpToDown(a []int, top int, count int) {
  function swap (line 50) | func swap(a []int, i int, j int) {

FILE: go/29_priority_queue/heap.go
  function adjustHeap (line 3) | func adjustHeap(src []Node, start, end int) {

FILE: go/29_priority_queue/heap_test.go
  function Test_AdjustHeap (line 9) | func Test_AdjustHeap(t *testing.T) {

FILE: go/29_priority_queue/priority_queue.go
  type Node (line 4) | type Node struct
  type PQueue (line 10) | type PQueue struct
    method Push (line 27) | func (q *PQueue) Push(node Node) {
    method Pop (line 40) | func (q *PQueue) Pop() Node {
    method Top (line 55) | func (q *PQueue) Top() Node {
  function NewPriorityQueue (line 18) | func NewPriorityQueue(capacity int) PQueue {

FILE: go/29_priority_queue/priority_queue_test.go
  function Test_Push (line 9) | func Test_Push(t *testing.T) {
  function Test_PushPop (line 31) | func Test_PushPop(t *testing.T) {

FILE: go/31_graph/graph_search.go
  type Graph (line 9) | type Graph struct
    method addEdge (line 26) | func (self *Graph) addEdge(s int, t int) {
    method BFS (line 32) | func (self *Graph) BFS(s int, t int) {
    method DFS (line 78) | func (self *Graph) DFS(s int, t int) {
    method recurse (line 95) | func (self *Graph) recurse(s int, t int, prev []int, visited []bool, i...
  function newGraph (line 15) | func newGraph(v int) *Graph {
  function printPrev (line 120) | func printPrev(prev []int, s int, t int) {

FILE: go/32_string/string_bf.go
  function bfSearch (line 8) | func bfSearch(main string, pattern string) int {
  function main (line 25) | func main() {

FILE: go/32_string/string_bm.go
  function generateBC (line 9) | func generateBC(pattern string) []int {
  function generateGS (line 25) | func generateGS(pattern string) ([]int, []bool) {
  function moveByGS (line 54) | func moveByGS(patternLength int, badCharStartIndex int, suffix []int, pr...
  function bmSearch (line 76) | func bmSearch(main string, pattern string) int {
  function findBadChar (line 112) | func findBadChar(subStr string, pattern string, bc []int) (int, int) {
  function main (line 134) | func main() {

FILE: go/34_kmp/kmp.go
  function getNexts (line 7) | func getNexts(pattern string) []int {
  function findByKMP (line 31) | func findByKMP(s string, pattern string) int {
  function main (line 57) | func main(){

FILE: go/41_dynamic_programming/backtracking/leastcoins.go
  constant intMax (line 7) | intMax = int(^uint(0) >> 1)
  function LeastCoins (line 12) | func LeastCoins(targetTotal int, coinOptions []int) int {
  function leastCoins (line 27) | func leastCoins(minNum *int, cNum, totalValue, opIndex int, coinOptions ...
  function shouldSkip (line 60) | func shouldSkip(memo [][]int, totalValue, nextOpIdex, cNum int) bool {
  function LeastCoins2 (line 71) | func LeastCoins2(targetTotal int, coinOptions []int) int {
  function leastCoins2 (line 87) | func leastCoins2(minNum *int, targetTotal int, coinOptions []int, cNum, ...

FILE: go/41_dynamic_programming/backtracking/leastcoins_test.go
  function TestFindLeastCoins (line 5) | func TestFindLeastCoins(t *testing.T) {
  function TestFindLeastCoins2 (line 31) | func TestFindLeastCoins2(t *testing.T) {

FILE: go/41_dynamic_programming/dp/leastcoins.go
  function LeastCoins (line 6) | func LeastCoins(targetTotal int, coinOptions []int) int {
  function LeastCoins2 (line 16) | func LeastCoins2(targetTotal int, coinOptions []int) int {
  function leastCoins (line 42) | func leastCoins(targetTotal int, coinOptions, memo []int) int {

FILE: go/41_dynamic_programming/dp/leastcoins_test.go
  function TestFindLeastCoins (line 5) | func TestFindLeastCoins(t *testing.T) {
  function TestFindLeastCoins2 (line 31) | func TestFindLeastCoins2(t *testing.T) {

FILE: go/42_dynamic_programming/longest_common_substring.go
  function lsc (line 5) | func lsc(s1 string, s2 string) int {
  function main (line 36) | func main() {

FILE: go/45_bitmap/bitmap.go
  type BitMap (line 4) | type BitMap
    method Set (line 12) | func (b BitMap) Set(value uint) {
    method Get (line 22) | func (b BitMap) Get(value uint) bool {
  function New (line 7) | func New(length uint) BitMap {

FILE: go/45_bitmap/bitmap_test.go
  function TestBitMap (line 7) | func TestBitMap(t *testing.T) {

FILE: go/binarysearch2.go
  function BinarySearch2 (line 4) | func BinarySearch2(nums []int, value int) int {
  function BinarySearch3 (line 28) | func BinarySearch3(nums []int, value int) int {
  function BinarySearch4 (line 51) | func BinarySearch4(nums []int, value int) int {
  function BinarySearch5 (line 72) | func BinarySearch5(nums []int, value int) int {

FILE: java/05_array/Array.java
  class Array (line 10) | public class Array {
    method Array (line 19) | public Array(int capacity){
    method find (line 26) | public int find(int index){
    method insert (line 32) | public boolean insert(int index, int value){
    method delete (line 61) | public boolean delete(int index){
    method printAll (line 77) | public void printAll() {
    method main (line 84) | public static void main(String[] args) {

FILE: java/05_array/GenericArray.java
  class GenericArray (line 1) | public class GenericArray<T> {
    method GenericArray (line 6) | public GenericArray(int capacity) {
    method GenericArray (line 12) | public GenericArray() {
    method getCapacity (line 17) | public int getCapacity() {
    method count (line 22) | public int count() {
    method isEmpty (line 27) | public boolean isEmpty() {
    method set (line 32) | public void set(int index, T e) {
    method get (line 38) | public T get(int index) {
    method contains (line 44) | public boolean contains(T e) {
    method find (line 54) | public int find(T e) {
    method add (line 65) | public void add(int index, T e) {
    method addFirst (line 80) | public void addFirst(T e) {
    method addLast (line 85) | public void addLast(T e) {
    method remove (line 90) | public T remove(int index) {
    method removeFirst (line 109) | public T removeFirst() {
    method removeLast (line 114) | public T removeLast() {
    method removeElement (line 119) | public void removeElement(T e) {
    method toString (line 126) | @Override
    method resize (line 143) | private void resize(int capacity) {
    method checkIndex (line 152) | private void checkIndex(int index) {
    method checkIndexForAdd (line 158) | private void checkIndexForAdd(int index) {

FILE: java/06_linkedlist/LRUBaseLinkedList.java
  class LRUBaseLinkedList (line 12) | public class LRUBaseLinkedList<T> {
    method LRUBaseLinkedList (line 34) | public LRUBaseLinkedList() {
    method LRUBaseLinkedList (line 40) | public LRUBaseLinkedList(Integer capacity) {
    method add (line 46) | public void add(T data) {
    method deleteElemOptim (line 67) | private void deleteElemOptim(SNode preNode) {
    method intsertElemAtBegin (line 79) | private void intsertElemAtBegin(T data) {
    method findPreNode (line 91) | private SNode findPreNode(T data) {
    method deleteElemAtEnd (line 105) | private void deleteElemAtEnd() {
    method printAll (line 123) | private void printAll() {
    class SNode (line 132) | public class SNode<T> {
      method SNode (line 138) | public SNode(T element) {
      method SNode (line 142) | public SNode(T element, SNode next) {
      method SNode (line 147) | public SNode() {
      method getElement (line 151) | public T getElement() {
      method setElement (line 155) | public void setElement(T element) {
      method getNext (line 159) | public SNode getNext() {
      method setNext (line 163) | public void setNext(SNode next) {
    method main (line 168) | public static void main(String[] args) {

FILE: java/06_linkedlist/LRUBasedArray.java
  class LRUBasedArray (line 13) | public class LRUBasedArray<T> {
    method LRUBasedArray (line 25) | public LRUBasedArray() {
    method LRUBasedArray (line 29) | public LRUBasedArray(int capacity) {
    method offer (line 40) | public void offer(T object) {
    method update (line 60) | public void update(int end) {
    method cache (line 72) | public void cache(T object, int end) {
    method removeAndCache (line 83) | public void removeAndCache(T object) {
    method rightShift (line 93) | private void rightShift(int end) {
    method isContain (line 100) | public boolean isContain(T object) {
    method isEmpty (line 104) | public boolean isEmpty() {
    method isFull (line 108) | public boolean isFull() {
    method toString (line 112) | @Override
    class TestLRUBasedArray (line 122) | static class TestLRUBasedArray {
      method main (line 124) | public static void main(String[] args) {
      method testWithException (line 130) | private static void testWithException() {
      method testDefaultConstructor (line 135) | public static void testDefaultConstructor() {
      method testSpecifiedConstructor (line 151) | public static void testSpecifiedConstructor(int capacity) {

FILE: java/06_linkedlist/SinglyLinkedList.java
  class SinglyLinkedList (line 9) | public class SinglyLinkedList {
    method findByValue (line 13) | public Node findByValue(int value) {
    method findByIndex (line 22) | public Node findByIndex(int index) {
    method insertToHead (line 36) | public void insertToHead(int value) {
    method insertToHead (line 41) | public void insertToHead(Node newNode) {
    method insertTail (line 52) | public void insertTail(int value){
    method insertAfter (line 68) | public void insertAfter(Node p, int value) {
    method insertAfter (line 73) | public void insertAfter(Node p, Node newNode) {
    method insertBefore (line 80) | public void insertBefore(Node p, int value) {
    method insertBefore (line 85) | public void insertBefore(Node p, Node newNode) {
    method deleteByNode (line 106) | public void deleteByNode(Node p) {
    method deleteByValue (line 126) | public void deleteByValue(int value) {
    method printAll (line 161) | public void printAll() {
    method TFResult (line 171) | public boolean TFResult(Node left, Node right){
    method palindrome (line 201) | public boolean palindrome(){
    method inverseLinkList_head (line 240) | public Node inverseLinkList_head(Node p){
    method inverseLinkList (line 269) | public Node inverseLinkList(Node p){
    method createNode (line 290) | public static Node createNode(int value) {
    class Node (line 294) | public static class Node {
      method Node (line 298) | public Node(int data, Node next) {
      method getData (line 303) | public int getData() {
    method main (line 308) | public static void main(String[]args){

FILE: java/07_linkedlist/LinkedListAlgo.java
  class LinkedListAlgo (line 12) | public class LinkedListAlgo {
    method reverse (line 15) | public static Node reverse(Node list) {
    method checkCircle (line 27) | public static boolean checkCircle(Node list) {
    method mergeTwoLists (line 91) | public ListNode mergeTwoLists(ListNode l1, ListNode l2) {
    method deleteLastKth (line 114) | public static Node deleteLastKth(Node list, int k) {
    method findMiddleNode (line 141) | public static Node findMiddleNode(Node list) {
    method printAll (line 155) | public static void printAll(Node list) {
    method createNode (line 164) | public static Node createNode(int value) {
    class Node (line 168) | public static class Node {
      method Node (line 172) | public Node(int data, Node next) {
      method getData (line 177) | public int getData() {

FILE: java/08_stack/SampleBrowser.java
  class SampleBrowser (line 8) | public class SampleBrowser {
    method main (line 10) | public static void main(String[] args) {
    method SampleBrowser (line 33) | public SampleBrowser() {
    method open (line 38) | public void open(String url) {
    method canGoBack (line 46) | public boolean canGoBack() {
    method canGoForward (line 50) | public boolean canGoForward() {
    method goBack (line 54) | public String goBack() {
    method goForward (line 66) | public String goForward() {
    method showUrl (line 78) | public void showUrl(String url, String prefix) {
    method checkCurrentPage (line 83) | public void checkCurrentPage() {
    class LinkedListBasedStack (line 90) | public static class LinkedListBasedStack {
      method createNode (line 111) | static Node createNode(String data, Node next) {
      method clear (line 115) | public void clear() {
      method push (line 120) | public void push(String data) {
      method pop (line 126) | public String pop() {
      method getTopData (line 139) | public String getTopData() {
      method size (line 146) | public int size() {
      method print (line 150) | public void print() {
      class Node (line 161) | public static class Node {
        method Node (line 166) | public Node(String data) {
        method Node (line 170) | public Node(String data, Node next) {
        method setData (line 175) | public void setData(String data) {
        method getData (line 179) | public String getData() {
        method setNext (line 183) | public void setNext(Node next) {
        method getNext (line 187) | public Node getNext() {

FILE: java/08_stack/StackBasedOnLinkedList.java
  class StackBasedOnLinkedList (line 8) | public class StackBasedOnLinkedList {
    method push (line 11) | public void push(int value) {
    method pop (line 25) | public int pop() {
    method printAll (line 32) | public void printAll() {
    class Node (line 41) | private static class Node {
      method Node (line 45) | public Node(int data, Node next) {
      method getData (line 50) | public int getData() {

FILE: java/09_queue/ArrayQueue.java
  class ArrayQueue (line 7) | public class ArrayQueue {
    method ArrayQueue (line 16) | public ArrayQueue(int capacity) {
    method enqueue (line 22) | public boolean enqueue(String item) {
    method dequeue (line 31) | public String dequeue() {
    method printAll (line 40) | public void printAll() {

FILE: java/09_queue/CircularQueue.java
  class CircularQueue (line 6) | public class CircularQueue {
    method CircularQueue (line 15) | public CircularQueue(int capacity) {
    method enqueue (line 21) | public boolean enqueue(String item) {
    method dequeue (line 30) | public String dequeue() {
    method printAll (line 38) | public void printAll() {

FILE: java/09_queue/DynamicArrayQueue.java
  class DynamicArrayQueue (line 6) | public class DynamicArrayQueue {
    method DynamicArrayQueue (line 15) | public DynamicArrayQueue(int capacity) {
    method enqueue (line 21) | public boolean enqueue(String item) {
    method dequeue (line 41) | public String dequeue() {
    method printAll (line 50) | public void printAll() {

FILE: java/09_queue/QueueBasedOnLinkedList.java
  class QueueBasedOnLinkedList (line 8) | public class QueueBasedOnLinkedList {
    method enqueue (line 15) | public void enqueue(String value) {
    method dequeue (line 27) | public String dequeue() {
    method printAll (line 38) | public void printAll() {
    class Node (line 47) | private static class Node {
      method Node (line 51) | public Node(String data, Node next) {
      method getData (line 56) | public String getData() {

FILE: java/11_sorts/InsertionSortAdd.java
  class InsertionSortAdd (line 9) | public class InsertionSortAdd {
    method main (line 11) | public static void main(String[] args) {
    method fromStartToEnd (line 21) | private static void fromStartToEnd(int[] data) {

FILE: java/11_sorts/Sorts.java
  class Sorts (line 10) | public class Sorts {
    method bubbleSort (line 13) | public static void bubbleSort(int[] a, int n) {
    method bubbleSort2 (line 36) | public static void bubbleSort2(int[] a, int n) {
    method insertionSort (line 63) | public static void insertionSort(int[] a, int n) {
    method selectionSort (line 82) | public static void selectionSort(int[] a, int n) {
    method main (line 101) | public static void main(String[] args) {

FILE: java/11_sorts/SortsAddOn.java
  class SortsAddOn (line 9) | public class SortsAddOn {
    method main (line 11) | public static void main(String[] args) {
    method bubbleDownSort (line 54) | private static void bubbleDownSort(int[] arr) {
    method shellSort (line 70) | private static void shellSort(int[] arr) {
    method print (line 93) | private static void print(int[] arr) {

FILE: java/12_sorts/KthSmallest.java
  class KthSmallest (line 7) | public class KthSmallest {
    method kthSmallest (line 9) | public static int kthSmallest(int[] arr, int k) {
    method partition (line 26) | private static int partition(int[] arr, int p, int r) {
    method swap (line 43) | private static void swap(int[] arr, int i, int j) {

FILE: java/12_sorts/MergeSort.java
  class MergeSort (line 6) | public class MergeSort {
    method mergeSort (line 9) | public static void mergeSort(int[] a, int n) {
    method mergeSortInternally (line 14) | private static void mergeSortInternally(int[] a, int p, int r) {
    method merge (line 28) | private static void merge(int[] a, int p, int q, int r) {
    method mergeBySentry (line 68) | private static void mergeBySentry(int[] arr, int p, int q, int r) {

FILE: java/12_sorts/QuickSort.java
  class QuickSort (line 6) | public class QuickSort {
    method quickSort (line 9) | public static void quickSort(int[] a, int n) {
    method quickSortInternally (line 14) | private static void quickSortInternally(int[] a, int p, int r) {
    method partition (line 22) | private static int partition(int[] a, int p, int r) {

FILE: java/12_sorts/Sorts.java
  class Sorts (line 11) | public class Sorts {
    method bubbleSort (line 18) | public static void bubbleSort(int[] arr) {
    method bubbleSort2 (line 35) | public static void bubbleSort2(int[] arr) {
    method insertSort (line 57) | public static void insertSort(int[] arr) {
    method insertSort (line 75) | public static void insertSort(int[] arr, int n) {
    method selectSort (line 92) | public static void selectSort(int[] arr) {
    method mergeSort (line 113) | public static void mergeSort(int[] arr, int left, int right) {
    method merge2 (line 124) | private static void merge2(int[] arr, int left, int q, int right) {
    method merge (line 153) | private static void merge(int[] arr, int left, int q, int right) {
    method quickSort (line 185) | public static void quickSort(int[] arr, int left, int right) {
    method partition (line 194) | private static int partition(int[] arr, int left, int right) {
    method partition2 (line 214) | private static int partition2(int[] arr, int left, int right) {
    method quickSort3 (line 248) | private static void quickSort3(int[] arr, int left, int right) {
    method quickSort4 (line 298) | private static void quickSort4(int[] arr, int left, int right) {
    method sort (line 360) | public static int sort(int[] arr, int l, int r, int k) {
    method main (line 374) | public static void main(String[] args) {
    method print (line 387) | public static void print(int[] arr) {

FILE: java/13_sorts/BucketSort.java
  class BucketSort (line 8) | public class BucketSort {
    method bucketSort (line 16) | public static void bucketSort(int[] arr, int bucketSize) {
    method ensureCapacity (line 66) | private static void ensureCapacity(int[][] buckets, int bucketIndex) {
    method quickSortC (line 82) | private static void quickSortC(int[] arr, int p, int r) {
    method partition (line 100) | private static int partition(int[] arr, int p, int r) {
    method swap (line 121) | private static void swap(int[] arr, int i, int j) {

FILE: java/13_sorts/CountingSort.java
  class CountingSort (line 8) | public class CountingSort {
    method countingSort (line 11) | public static void countingSort(int[] a, int n) {

FILE: java/13_sorts/RadixSort.java
  class RadixSort (line 8) | public class RadixSort {
    method radixSort (line 15) | public static void radixSort(int[] arr) {
    method countingSort (line 35) | public static void countingSort(int[] arr, int exp) {

FILE: java/17_skiplist/SkipList.java
  class SkipList (line 10) | public class SkipList {
    method find (line 19) | public Node find(int value) {
    method insert (line 34) | public void insert(int value) {
    method delete (line 63) | public void delete(int value) {
    method randomLevel (line 93) | private int randomLevel() {
    method printAll (line 101) | public void printAll() {
    class Node (line 110) | public class Node {
      method toString (line 115) | @Override

FILE: java/17_skiplist/SkipList2.java
  class SkipList2 (line 11) | public class SkipList2 {
    method find (line 22) | public Node find(int value) {
    method insert (line 44) | public void insert(int value) {
    method insert2 (line 82) | public void insert2(int value) {
    method insert (line 119) | public void insert(int value, int level) {
    method delete (line 162) | public void delete(int value) {
    method randomLevel (line 186) | private int randomLevel() {
    method printAll (line 199) | public void printAll() {
    method printAll_beautiful (line 211) | public void printAll_beautiful() {
    class Node (line 228) | public class Node {
      method Node (line 241) | public Node(int level) {
      method toString (line 245) | @Override
    method main (line 257) | public static void main(String[] args) {

FILE: java/18_hashtable/HashTable.java
  class HashTable (line 8) | public class HashTable<K, V> {
    method HashTable (line 35) | public HashTable() {
    class Entry (line 39) | static class Entry<K, V> {
      method Entry (line 46) | Entry(K key, V value, Entry<K, V> next) {
    method put (line 59) | public void put(K key, V value) {
    method hash (line 102) | private int hash(Object key) {
    method resize (line 110) | private void resize() {
    method remove (line 137) | public void remove(K key) {
    method get (line 164) | public V get(K key) {

FILE: java/20_hashtable/LRUBaseHashTable.java
  class LRUBaseHashTable (line 10) | public class LRUBaseHashTable<K, V> {
    class DNode (line 45) | static class DNode<K, V> {
      method DNode (line 64) | DNode() {
      method DNode (line 67) | DNode(K key, V value) {
    method LRUBaseHashTable (line 74) | public LRUBaseHashTable(int capacity) {
    method LRUBaseHashTable (line 88) | public LRUBaseHashTable() {
    method add (line 98) | public void add(K key, V value) {
    method addNode (line 121) | private void addNode(DNode<K, V> newNode) {
    method popTail (line 132) | private DNode<K, V> popTail() {
    method removeNode (line 143) | private void removeNode(DNode<K, V> node) {
    method moveToHead (line 153) | private void moveToHead(DNode<K, V> node) {
    method get (line 164) | public V get(K key) {
    method remove (line 178) | public void remove(K key) {
    method printAll (line 188) | private void printAll() {

FILE: java/24_tree/BinarySearchTree.java
  class BinarySearchTree (line 1) | public class BinarySearchTree {
    method find (line 4) | public Node find(int data) {
    method insert (line 14) | public void insert(int data) {
    method delete (line 38) | public void delete(int data) {
    method findMin (line 72) | public Node findMin() {
    method findMax (line 81) | public Node findMax() {
    class Node (line 90) | public static class Node {
      method Node (line 95) | public Node(int data) {

FILE: java/28_sorts/HeapSort.java
  class HeapSort (line 4) | public class HeapSort {
    method sort (line 13) | public static void sort(int[] arr) {
    method buildHeap (line 36) | private static void buildHeap(int[] arr) {
    method heapify (line 51) | private static void heapify(int[] arr, int n, int i) {

FILE: java/30_graph/Graph.java
  class Graph (line 10) | public class Graph {
    method Graph (line 14) | public Graph(int v) {
    method addEdge (line 28) | public void addEdge(int s, int t) { // 无向图一条边存两次
    method bfs (line 34) | public void bfs(int s, int t) {
    method print (line 64) | private void print(int[] prev, int s, int t) { // 递归打印 s->t 的路径
    method main (line 71) | public static void main(String[] args) {
    method dfs (line 91) | public void dfs(int s, int t) {
    method recurDfs (line 102) | private void recurDfs(int w, int t, boolean[] visited, int[] prev) {

FILE: java/36_ac_automata/ACAutoMata.java
  class ACAutoMata (line 10) | public class ACAutoMata {
    method ACAutoMata (line 13) | public ACAutoMata() {
    method insert (line 17) | private void insert (String pattern) {
    method buildFailurePointer (line 32) | private void buildFailurePointer() {
    method match (line 66) | private Boolean match (String text) {
    method match (line 95) | public static boolean match(String text, String[] patterns) {
    class ACNode (line 105) | public class ACNode {
      method ACNode (line 112) | public ACNode(String data) {
    method main (line 121) | public static void main(String[] args) {

FILE: javascript/06_linkedlist/SinglyLinkedList.js
  class Node (line 5) | class Node {
    method constructor (line 6) | constructor (element) {
  class LinkedList (line 12) | class LinkedList {
    method constructor (line 13) | constructor () {
    method findByValue (line 17) | findByValue (item) {
    method findByIndex (line 27) | findByIndex (index) {
    method append (line 39) | append(newElement) {
    method insert (line 49) | insert (newElement, element) {
    method findPrev (line 61) | findPrev (item) {
    method remove (line 73) | remove (item) {
    method display (line 83) | display () {

FILE: javascript/07_linkedlist/LinkedListAlgo.js
  class Node (line 9) | class Node {
    method constructor (line 10) | constructor(element) {
  class LinkedList (line 16) | class LinkedList {
    method constructor (line 17) | constructor() {
    method findByValue (line 21) | findByValue(item) {
    method findByIndex (line 29) | findByIndex(index) {
    method insert (line 39) | insert(newElement, element) {
    method findPrev (line 50) | findPrev(item) {
    method remove (line 61) | remove(item) {
    method display (line 71) | display() {
    method reverseList (line 83) | reverseList() {
    method reverseList1 (line 96) | reverseList1(){
    method reverseList2 (line 120) | reverseList2() {
    method checkCircle (line 140) | checkCircle() {
    method removeByIndexFromEnd (line 151) | removeByIndexFromEnd(index) {
    method findMiddleNode (line 169) | findMiddleNode() {

FILE: javascript/08_stack/SampleBrowser.js
  class SampleBrowser (line 8) | class SampleBrowser {
    method constructor (line 9) | constructor() {
    method pushNormal (line 14) | pushNormal(name) {
    method back (line 20) | back() {
    method front (line 30) | front() {
    method displayAllStack (line 40) | displayAllStack() {

FILE: javascript/08_stack/StackBasedOnLinkedList.js
  class Node (line 7) | class Node {
    method constructor (line 8) | constructor(element) {
  class StackBasedLinkedList (line 14) | class StackBasedLinkedList {
    method constructor (line 15) | constructor() {
    method push (line 18) | push(value) {
    method pop (line 27) | pop() {
    method clear (line 36) | clear() {
    method display (line 39) | display() {

FILE: javascript/09_queue/CircularQueueBasedOnLinkedList.js
  class Node (line 7) | class Node {
    method constructor (line 8) | constructor(element) {
  class CircularQueue (line 14) | class CircularQueue {
    method constructor (line 15) | constructor() {
    method enqueue (line 20) | enqueue(value) {
    method dequeue (line 36) | dequeue() {
    method display (line 51) | display() {

FILE: javascript/09_queue/QueueBasedOnLinkedList.js
  class Node (line 7) | class Node {
    method constructor (line 8) | constructor(element) {
  class QueueBasedOnLinkedList (line 14) | class QueueBasedOnLinkedList {
    method constructor (line 15) | constructor() {
    method enqueue (line 20) | enqueue(value) {
    method dequeue (line 30) | dequeue() {

FILE: javascript/12_sorts/KthNum.js
  function kthNum (line 6) | function kthNum(arr, k) {
  function partition (line 22) | function partition(arr, start, end) {
  function swap (line 35) | function swap(arr, i, j) {

FILE: javascript/13_sorts/bucketSort.js
  function bucketSort (line 6) | function bucketSort(array, bucketSize = 5) {
  function createBuckets (line 14) | function createBuckets(array, bucketSize) {
  function sortBuckets (line 40) | function sortBuckets(buckets) {
  function insertionSort (line 52) | function insertionSort(array) {

FILE: javascript/13_sorts/countingSort.js
  function findMaxValue (line 30) | function findMaxValue(array) {

FILE: javascript/17_skiplist/SkipList.js
  constant MAX_LEVEL (line 6) | const MAX_LEVEL = 16;
  class Node (line 8) | class Node {
    method constructor (line 9) | constructor({
  class SkipList (line 20) | class SkipList{
    method constructor (line 21) | constructor() {
    method randomLevel (line 25) | randomLevel() {
    method insert (line 34) | insert(value) {
    method find (line 56) | find(value) {
    method remove (line 71) | remove(value) {
    method printAll (line 94) | printAll() {
  function test (line 104) | function test() {

FILE: javascript/19_hashTable/hashtable.js
  class HashTable (line 11) | class HashTable {
    method constructor (line 12) | constructor() {
    method hash (line 23) | hash(string) {
    method isCresh (line 32) | isCresh(item) {
    method put (line 39) | put(item) {
    method get (line 60) | get(key) {
    method remove (line 69) | remove(key) {
    method clear (line 81) | clear() {
    method print (line 84) | print() {
  class HashTableBaseMap (line 101) | class HashTableBaseMap {
    method constructor (line 102) | constructor() {
    method hash (line 112) | hash(string) {
    method isCresh (line 121) | isCresh(item) {
    method put (line 128) | put(item) {
    method get (line 149) | get(key) {
    method remove (line 158) | remove(key) {
    method clear (line 170) | clear() {
    method print (line 173) | print() {
  function baseTest (line 189) | function baseTest() {
  function ordKeyTest (line 221) | function ordKeyTest() {
  function randKeyTest (line 248) | function randKeyTest() {
  function randKeyTestFromObj (line 277) | function randKeyTestFromObj() {
  function randKeyTestFromMap (line 305) | function randKeyTestFromMap() {
  function randomString (line 331) | function randomString(len) {

FILE: javascript/23_tree/binary_tree.js
  class Node (line 1) | class Node {
    method constructor (line 2) | constructor(value) {
  class SearchTree (line 13) | class SearchTree {
    method constructor (line 14) | constructor() {
    method insert (line 17) | insert(num) {
    method remove (line 31) | remove(num) {
    method print (line 106) | print() {
    method find (line 122) | find(num) {
    method getPrev (line 130) | getPrev(num, find = false) {
  function baseTest (line 175) | function baseTest() {
  function delTest (line 194) | function delTest() {

FILE: javascript/28_heapsort/heap-sort.js
  class HeapSort (line 8) | class HeapSort {
    method constructor (line 9) | constructor(originArray) {
    method buildHeap (line 13) | buildHeap() {
    method heapify (line 22) | heapify(arr, len, i) {
    method sort (line 39) | sort() {
    method swap (line 50) | swap(arr, i, max) {

FILE: javascript/28_heapsort/heap.js
  class HeapNode (line 4) | class HeapNode {
    method constructor (line 5) | constructor(num, item) {
  class Heap (line 11) | class Heap {
    method constructor (line 12) | constructor(arr = []) {
    method insert (line 48) | insert(node) {
    method getMax (line 61) | getMax() {
  function HeapTest (line 77) | function HeapTest() {
  function createTest (line 96) | function createTest() {
  function isHeapArr (line 109) | function isHeapArr(arr) {

FILE: javascript/35_trie/trie.js
  class TrieNode (line 3) | class TrieNode {
    method constructor (line 4) | constructor(data){
  class TrieTree (line 11) | class TrieTree {
    method constructor (line 13) | constructor(data){
    method insert (line 17) | insert (text) {
    method find (line 30) | find (text) {

FILE: javascript/36_ac_automata/ac_automata.js
  class ACNode (line 4) | class ACNode {
    method constructor (line 5) | constructor(data){
  class ACTree (line 14) | class ACTree {
    method constructor (line 16) | constructor(data){
    method insert (line 20) | insert (text) {
    method buildFailurePointer (line 34) | buildFailurePointer() {
    method match (line 69) | match (text) {

FILE: javascript/36_ac_automata/ac_automata_unicode.js
  class ACNode (line 2) | class ACNode {
    method constructor (line 3) | constructor(data){
  class ACTree (line 12) | class ACTree {
    method constructor (line 14) | constructor(data){
    method insert (line 18) | insert (text) {
    method buildFailurePointer (line 31) | buildFailurePointer() {
    method match (line 65) | match (text) {
  function match (line 92) | function match( text, patterns) {

FILE: javascript/42_dynamic_programming/levenshtein_distance.js
  function lsDist (line 1) | function lsDist(str1, str2) {

FILE: javascript/43_topological_sorting/dsf.js
  function Graph (line 2) | function Graph() {

FILE: javascript/45_bitmap/bitmap.js
  class BitMap (line 2) | class BitMap {
    method constructor (line 3) | constructor(n) {
    method get (line 9) | get(k) {
    method set (line 18) | set(k) {

FILE: php/05_array/array.php
  class MyArray (line 12) | class MyArray
    method __construct (line 25) | public function __construct($capacity)
    method checkIfFull (line 40) | public function checkIfFull()
    method checkOutOfRange (line 53) | private function checkOutOfRange($index)
    method insert (line 67) | public function insert($index, $value)
    method delete (line 93) | public function delete($index)
    method find (line 119) | public function find($index)
    method printData (line 134) | public function printData()

FILE: php/06_linkedlist/SingleLinkedList.php
  class SingleLinkedList (line 18) | class SingleLinkedList
    method __construct (line 41) | public function __construct($head = null)
    method getLength (line 57) | public function getLength()
    method insert (line 69) | public function insert($data)
    method delete (line 81) | public function delete(SingleLinkedListNode $node)
    method getNodeByIndex (line 108) | public function getNodeByIndex($index)
    method getPreNode (line 129) | public function getPreNode(SingleLinkedListNode $node)
    method printList (line 155) | public function printList()
    method printListSimple (line 179) | public function printListSimple()
    method insertDataAfter (line 204) | public function insertDataAfter(SingleLinkedListNode $originNode, $data)
    method insertDataBefore (line 235) | public function insertDataBefore(SingleLinkedListNode $originNode, $data)
    method insertNodeAfter (line 256) | public function insertNodeAfter(SingleLinkedListNode $originNode, Sing...
    method buildHasCircleList (line 274) | public function buildHasCircleList()

FILE: php/06_linkedlist/SingleLinkedListNode.php
  class SingleLinkedListNode (line 18) | class SingleLinkedListNode
    method __construct (line 39) | public function __construct($data = null)

FILE: php/06_linkedlist/main.php
  function isPalindrome (line 18) | function isPalindrome(SingleLinkedList $list)

FILE: php/07_linkedlist/main.php
  class SingleLinkedListAlgo (line 27) | Class SingleLinkedListAlgo
    method __construct (line 43) | public function __construct(SingleLinkedList $list = null)
    method setList (line 53) | public function setList(SingleLinkedList $list)
    method reverse (line 68) | public function reverse()
    method checkCircle (line 104) | public function checkCircle()
    method mergerSortedList (line 134) | public function mergerSortedList(SingleLinkedList $listA, SingleLinked...
    method deleteLastKth (line 180) | public function deleteLastKth($index)
    method findMiddleNode (line 221) | public function findMiddleNode()

FILE: php/08_stack/Compute.php
  function expression (line 6) | function expression($str)
  function compute (line 66) | function compute(&$numStack, &$operStack){

FILE: php/08_stack/StackOnLinkedList.php
  class StackOnLinkedList (line 13) | class StackOnLinkedList
    method __construct (line 33) | public function __construct()
    method pop (line 44) | public function pop()
    method push (line 63) | public function push($data)
    method pushNode (line 75) | public function pushNode(SingleLinkedListNode $node)
    method pushData (line 95) | public function pushData($data)
    method top (line 111) | public function top()
    method printSelf (line 123) | public function printSelf()
    method getLength (line 145) | public function getLength()
    method isEmpty (line 155) | public function isEmpty()

FILE: php/09_queue/QueueOnLinkedList.php
  class QueueOnLinkedList (line 17) | class QueueOnLinkedList
    method __construct (line 43) | public function __construct()
    method enqueue (line 56) | public function enqueue($data)
    method dequeue (line 72) | public function dequeue()
    method getLength (line 91) | public function getLength()
    method printSelf (line 99) | public function printSelf()

FILE: php/09_queue/Sequential.php
  class LoopQueue (line 3) | class LoopQueue
    method __construct (line 13) | public function __construct($size = 10)
    method enQueue (line 21) | public function enQueue($data)
    method deQueue (line 30) | public function deQueue()
    method getLength (line 41) | public function getLength()

FILE: php/10_heap/Heap.php
  class Heap (line 12) | class Heap
    method __construct (line 19) | public function __construct($size = 0, $heapType = 1)
    method insert (line 29) | public function insert($data)
    method isFull (line 47) | public function isFull()
    method isEmpty (line 57) | public function isEmpty(){
    method peak (line 61) | public function peak(){
    method insertOnly (line 70) | public function insertOnly($data)
    method deleteFirst (line 86) | public function deleteFirst()
    method heapFromOneToDown (line 108) | protected function heapFromOneToDown($i)
    method heapAll (line 168) | public function heapAll()
    method heapSort (line 179) | public function heapSort()
    method smallHeapLast (line 214) | public function smallHeapLast()
    method smallHeapFirst (line 239) | public function smallHeapFirst()
    method bigHeapFirst (line 271) | public function bigHeapFirst()
    method bigHeapLast (line 300) | public function bigHeapLast()
    method topn (line 314) | public function topn($data)

FILE: php/10_heap/findmiddle.php
  function findMiddle (line 17) | function findMiddle($arr)
  function midPeak (line 51) | function midPeak($heap1, $heap2)

FILE: php/11_sort/Sort.php
  function bubbleSort (line 3) | function bubbleSort(&$arr)
  function insertionSort (line 25) | function insertionSort(&$arr)
  function selectionSort (line 46) | function selectionSort(&$arr)

FILE: php/12_sort/mergeSort.php
  function mergeSort (line 17) | function mergeSort(array $arr, $p, $r)
  function mergeSortRecursive (line 23) | function mergeSortRecursive(array $arr, $p, $r)
  function merge (line 40) | function merge(array $left, array $right)

FILE: php/12_sort/quicksort.php
  function quickSort (line 3) | function quickSort(array &$a)
  function quickSortInternally (line 10) | function quickSortInternally(array &$a, int $l, int $r)
  function partition (line 19) | function partition(&$a, $l, $r): int

FILE: php/13_sort/bucketSort.php
  function bucketSort (line 22) | function bucketSort(array $numbers) {

FILE: php/13_sort/countingSort.php
  function countingSort (line 11) | function countingSort(array $score) {

FILE: php/13_sort/radixSort.php
  function radixSort (line 31) | function radixSort(array &$numbers,$loop) {

FILE: php/15_binary/binary.php
  function binarySearch (line 13) | function binarySearch(array $numbers, $find)
  function search (line 20) | function search(array $numbers, $low, $high, $find)
  function squareRoot (line 52) | function squareRoot($number)
  function getDecimalPlaces (line 86) | function getDecimalPlaces($number)

FILE: php/16_binary/binary.php
  function findFirstEqual (line 11) | function findFirstEqual(array $numbers,$find) {
  function findLastEqual (line 46) | function findLastEqual(array $numbers,$find) {
  function findFirstGreaterEqual (line 82) | function findFirstGreaterEqual(array $numbers,$find) {
  function findLastLessEqual (line 110) | function findLastLessEqual(array $numbers,$find) {
  function searchCircularArray (line 141) | function searchCircularArray(array $numbers,$find) {

FILE: php/17_skiplist/skipList.php
  class SNode (line 3) | class SNode
    method __construct (line 11) | public function __construct($data = null)
    method getMaxLevel (line 17) | public function getMaxLevel()
  class SkipList (line 23) | class SkipList
    method __construct (line 31) | public function __construct(int $indexLevel)
    method addData (line 37) | public function addData($data)
    method deleteData (line 52) | public function deleteData($data)
    method findData (line 68) | public function findData($data)
    method getRandomLevel (line 81) | protected function getRandomLevel()

FILE: php/24_tree/Tree.php
  class Tree (line 5) | class Tree
    method __construct (line 18) | public function __construct($headData = null)
    method find (line 30) | public function find($data)
    method insert (line 56) | public function insert($data)
    method delete (line 87) | public function delete($data)
    method preOrder (line 143) | public function preOrder($node)
    method inOrder (line 157) | public function inOrder($node){
    method postOrder (line 171) | public function postOrder($node){
    method levelOrder (line 190) | public function levelOrder($queue, $index = 0)

FILE: php/24_tree/TreeNode.php
  class TreeNode (line 5) | class TreeNode
    method __construct (line 30) | public function __construct($data = null)

FILE: php/38_divide_and_conquer/matrix_production.php
  function popRow (line 3) | function popRow(&$matrix)
  function popColumn (line 8) | function popColumn(&$matrix)
  function countProduction (line 22) | function countProduction($row, $column)
  function merger (line 30) | function merger($value1, $value2, $value3, $value4)
  function matrixProduction (line 48) | function matrixProduction($matrix1, $matrix2)

FILE: php/39_backtracking/queens.php
  class Queen (line 7) | class Queen
    method cal8queens (line 11) | function cal8queens($row)
    method isOk (line 28) | function isOk($row, $column)
    method printQueens (line 58) | function printQueens()

FILE: php/Stack/Compute.php
  function expression (line 6) | function expression($str)
  function compute (line 58) | function compute(&$numStack, &$operStack){

FILE: python/05_array/myarray.py
  class MyArray (line 9) | class MyArray:
    method __init__ (line 14) | def __init__(self, capacity: int):
    method __getitem__ (line 18) | def __getitem__(self, position: int) -> object:
    method __setitem__ (line 21) | def __setitem__(self, index: int, value: object):
    method __len__ (line 24) | def __len__(self) -> int:
    method __iter__ (line 27) | def __iter__(self):
    method find (line 31) | def find(self, index: int) -> object:
    method delete (line 37) | def delete(self, index: int) -> bool:
    method insert (line 44) | def insert(self, index: int, value: int) -> bool:
    method print_all (line 50) | def print_all(self):
  function test_myarray (line 55) | def test_myarray():

FILE: python/06_linkedlist/LRUCache.py
  class DbListNode (line 2) | class DbListNode(object):
    method __init__ (line 3) | def __init__(self, x, y):
  class LRUCache (line 10) | class LRUCache:
    method __init__ (line 26) | def __init__(self, capacity: int):
    method get (line 35) | def get(self, key: int) -> int:
    method put (line 53) | def put(self, key: int, value: int) -> None:
    method __repr__ (line 83) | def __repr__(self):

FILE: python/06_linkedlist/palindrome.py
  function reverse (line 10) | def reverse(head):
  function is_palindrome (line 20) | def is_palindrome(l):

FILE: python/06_linkedlist/singlyLinkedList.py
  class Node (line 7) | class Node(object):
    method __init__ (line 10) | def __init__(self, data, next_node=None):
    method data (line 20) | def data(self):
    method data (line 28) | def data(self, data):
    method next_node (line 36) | def next_node(self):
    method next_node (line 44) | def next_node(self, next_node):
  class SinglyLinkedList (line 52) | class SinglyLinkedList(object):
    method __init__ (line 55) | def __init__(self):
    method find_by_value (line 59) | def find_by_value(self, value):
    method find_by_index (line 71) | def find_by_index(self, index):
    method insert_to_head (line 85) | def insert_to_head(self, value):
    method insert_after (line 94) | def insert_after(self, node, value):
    method insert_before (line 107) | def insert_before(self, node, value):
    method delete_by_node (line 133) | def delete_by_node(self, node):
    method delete_by_value (line 156) | def delete_by_value(self, value):
    method delete_last_n_node (line 180) | def delete_last_n_node(self, n):
    method find_mid_node (line 203) | def find_mid_node(self):
    method create_node (line 219) | def create_node(self, value):
    method print_all (line 228) | def print_all(self):
    method reversed_self (line 239) | def reversed_self(self):
    method __reversed_with_two_node (line 252) | def __reversed_with_two_node(self, pre, node):
    method has_ring (line 266) | def has_ring(self):

FILE: python/06_linkedlist/singly_linked_list.py
  class Node (line 10) | class Node:
    method __init__ (line 12) | def __init__(self, data: int, next_node=None):
  class SinglyLinkedList (line 17) | class SinglyLinkedList:
    method __init__ (line 19) | def __init__(self):
    method find_by_value (line 22) | def find_by_value(self, value: int) -> Optional[Node]:
    method find_by_index (line 28) | def find_by_index(self, index: int) -> Optional[Node]:
    method insert_value_to_head (line 36) | def insert_value_to_head(self, value: int):
    method insert_node_to_head (line 40) | def insert_node_to_head(self, new_node: Node):
    method insert_value_after (line 45) | def insert_value_after(self, node: Node, value: int):
    method insert_node_after (line 49) | def insert_node_after(self, node: Node, new_node: Node):
    method insert_value_before (line 55) | def insert_value_before(self, node: Node, value: int):
    method insert_node_before (line 59) | def insert_node_before(self, node: Node, new_node: Node):
    method delete_by_node (line 73) | def delete_by_node(self, node: Node):
    method delete_by_value (line 88) | def delete_by_value(self, value: int):
    method __repr__ (line 103) | def __repr__(self) -> str:
    method __iter__ (line 112) | def __iter__(self):
    method print_all (line 118) | def print_all(self):

FILE: python/07_linkedlist/linked_list_algo.py
  class Node (line 14) | class Node:
    method __init__ (line 16) | def __init__(self, data: int, next=None):
  function reverse (line 23) | def reverse(head: Node) -> Optional[Node]:
  function has_cycle (line 32) | def has_cycle(head: Node) -> bool:
  function merge_sorted_list (line 43) | def merge_sorted_list(l1: Node, l2: Node) -> Optional[Node]:
  function remove_nth_from_end (line 62) | def remove_nth_from_end(head: Node, n: int) -> Optional[Node]:
  function find_middle_node (line 79) | def find_middle_node(head: Node) -> Optional[Node]:
  function print_all (line 86) | def print_all(head: Node):

FILE: python/08_stack/linked_stack.py
  class Node (line 10) | class Node:
    method __init__ (line 12) | def __init__(self, data: int, next=None):
  class LinkedStack (line 17) | class LinkedStack:
    method __init__ (line 20) | def __init__(self):
    method push (line 23) | def push(self, value: int):
    method pop (line 28) | def pop(self) -> Optional[int]:
    method __repr__ (line 34) | def __repr__(self) -> str:

FILE: python/08_stack/simple_browser.py
  class NewLinkedStack (line 16) | class NewLinkedStack(LinkedStack):
    method is_empty (line 18) | def is_empty(self):
  class Browser (line 22) | class Browser():
    method __init__ (line 24) | def __init__(self):
    method can_forward (line 28) | def can_forward(self):
    method can_back (line 34) | def can_back(self):
    method open (line 40) | def open(self, url):
    method back (line 44) | def back(self):
    method forward (line 52) | def forward(self):

FILE: python/09_queue/array_queue.py
  class ArrayQueue (line 10) | class ArrayQueue:
    method __init__ (line 12) | def __init__(self, capacity: int):
    method enqueue (line 18) | def enqueue(self, item: str) -> bool:
    method dequeue (line 32) | def dequeue(self) -> Optional[str]:
    method __repr__ (line 40) | def __repr__(self) -> str:

FILE: python/09_queue/circular_queue.py
  class CircularQueue (line 8) | class CircularQueue:
    method __init__ (line 10) | def __init__(self, capacity):
    method enqueue (line 16) | def enqueue(self, item: str) -> bool:
    method dequeue (line 24) | def dequeue(self) -> Optional[str]:
    method __repr__ (line 30) | def __repr__(self) -> str:

FILE: python/09_queue/dynamic_array_queue.py
  class DynamicArrayQueue (line 7) | class DynamicArrayQueue:
    method __init__ (line 9) | def __init__(self, capacity: int):
    method enqueue (line 15) | def enqueue(self, item: str) -> bool:
    method dequeue (line 30) | def dequeue(self) -> Optional[str]:
    method __repr__ (line 36) | def __repr__(self) -> str:

FILE: python/09_queue/linked_queue.py
  class Node (line 9) | class Node:
    method __init__ (line 11) | def __init__(self, data: str, next=None):
  class LinkedQueue (line 15) | class LinkedQueue:
    method __init__ (line 17) | def __init__(self):
    method enqueue (line 21) | def enqueue(self, value: str):
    method dequeue (line 29) | def dequeue(self) -> Optional[str]:
    method __repr__ (line 37) | def __repr__(self) -> str:

FILE: python/11_sorts/sorts.py
  function bubble_sort (line 12) | def bubble_sort(a: List[int]):
  function insertion_sort (line 28) | def insertion_sort(a: List[int]):
  function selection_sort (line 43) | def selection_sort(a: List[int]):
  function test_bubble_sort (line 58) | def test_bubble_sort():
  function test_insertion_sort (line 70) | def test_insertion_sort():
  function test_selection_sort (line 82) | def test_selection_sort():

FILE: python/12_sorts/merge_sort.py
  function merge_sort (line 8) | def merge_sort(a: List[int]):
  function _merge_sort_between (line 12) | def _merge_sort_between(a: List[int], low: int, high: int):
  function _merge (line 21) | def _merge(a: List[int], low: int, mid: int, high: int):
  function test_merge_sort (line 38) | def test_merge_sort():

FILE: python/12_sorts/quick_sort.py
  function quick_sort (line 9) | def quick_sort(a: List[int]):
  function _quick_sort_between (line 13) | def _quick_sort_between(a: List[int], low: int, high: int):
  function _partition (line 24) | def _partition(a: List[int], low: int, high: int):
  function test_quick_sort (line 34) | def test_quick_sort():

FILE: python/12_sorts/quicksort_twoway.py
  function QuickSort (line 4) | def QuickSort(arr):

FILE: python/14_sorts/counting_sort.py
  function counting_sort (line 10) | def counting_sort(a: List[int]):

FILE: python/15_bsearch/bsearch.py
  function bsearch (line 7) | def bsearch(nums: List[int], target: int) -> int:

FILE: python/15_bsearch/bsearch_recursion.py
  function bsearch (line 8) | def bsearch(nums: List[int], target: int) -> int:
  function bsearch_internally (line 12) | def bsearch_internally(nums: List[int], low: int, high: int, target: int...

FILE: python/16_bsearch/bsearch_variants.py
  function bsearch_left (line 8) | def bsearch_left(nums: List[int], target: int) -> int:
  function bsearch_right (line 26) | def bsearch_right(nums: List[int], target: int) -> int:
  function bsearch_left_not_less (line 44) | def bsearch_left_not_less(nums: List[int], target: int) -> int:
  function bsearch_right_not_greater (line 61) | def bsearch_right_not_greater(nums: List[int], target: int) -> int:

FILE: python/17_skiplist/skip_list.py
  class ListNode (line 14) | class ListNode:
    method __init__ (line 16) | def __init__(self, data: Optional[int] = None):
  class SkipList (line 20) | class SkipList:
    method __init__ (line 24) | def __init__(self):
    method find (line 29) | def find(self, value: int) -> Optional[ListNode]:
    method insert (line 37) | def insert(self, value: int):
    method delete (line 55) | def delete(self, value):
    method _random_level (line 68) | def _random_level(self, p: float = 0.5) -> int:
    method __repr__ (line 74) | def __repr__(self) -> str:

FILE: python/17_skiplist/skip_list_comments.py
  class SkipListNode (line 4) | class SkipListNode(object):
    method __init__ (line 5) | def __init__(self, val, high=1):
  class SkipList (line 12) | class SkipList(object):
    method __init__ (line 21) | def __init__(self):
    method find (line 29) | def find(self, val):
    method insert (line 42) | def insert(self, val):
    method delete (line 70) | def delete(self, val):
    method randomLevel (line 88) | def randomLevel(self, p=0.25):
    method __repr__ (line 99) | def __repr__(self):

FILE: python/23_binarytree/binary_search_tree.py
  class TreeNode (line 8) | class TreeNode:
    method __init__ (line 9) | def __init__(self, val=None):
  class BinarySearchTree (line 16) | class BinarySearchTree:
    method __init__ (line 17) | def __init__(self, val_list=[]):
    method insert (line 22) | def insert(self, data):
    method search (line 51) | def search(self, data):
    method delete (line 74) | def delete(self, data):
    method _del (line 92) | def _del(self, node):
    method get_min (line 158) | def get_min(self):
    method get_max (line 171) | def get_max(self):
    method in_order (line 184) | def in_order(self):
    method _in_order (line 194) | def _in_order(self, node):
    method __repr__ (line 206) | def __repr__(self):
    method _bfs (line 211) | def _bfs(self):
    method _draw_tree (line 235) | def _draw_tree(self):

FILE: python/23_binarytree/binary_tree.py
  class TreeNode (line 10) | class TreeNode(Generic[T]):
    method __init__ (line 11) | def __init__(self, value: T):
  function pre_order (line 18) | def pre_order(root: Optional[TreeNode[T]]) -> Generator[T, None, None]:
  function in_order (line 25) | def in_order(root: Optional[TreeNode[T]]) -> Generator[T, None, None]:
  function post_order (line 32) | def post_order(root: Optional[TreeNode[T]]) -> Generator[T, None, None]:

FILE: python/24_tree/binary_search_tree.py
  class TreeNode (line 8) | class TreeNode:
    method __init__ (line 9) | def __init__(self, value: int):
  class BinarySearchTree (line 14) | class BinarySearchTree:
    method __init__ (line 15) | def __init__(self):
    method find (line 18) | def find(self, value: int) -> Optional[TreeNode]:
    method insert (line 24) | def insert(self, value: int):
    method delete (line 39) | def delete(self, value: int):

FILE: python/26_red_black_tree/red_black_tree.py
  class TreeNode (line 11) | class TreeNode:
    method __init__ (line 12) | def __init__(self, val=None, color=None):
    method is_black (line 21) | def is_black(self):
    method set_black (line 24) | def set_black(self):
    method set_red (line 28) | def set_red(self):
  class RedBlackTree (line 32) | class RedBlackTree:
    method __init__ (line 44) | def __init__(self, val_list=None):
    method search (line 54) | def search(self, val):
    method insert (line 73) | def insert(self, val):
    method _insert_fixup (line 107) | def _insert_fixup(self, node):
    method delete (line 148) | def delete(self, val):
    method _delete_node (line 163) | def _delete_node(self, node):
    method _delete_fixup (line 195) | def _delete_fixup(self, node):
    method _transplant (line 266) | def _transplant(self, n1, n2):
    method rotate_l (line 288) | def rotate_l(self, node):
    method rotate_r (line 321) | def rotate_r(self, node):
    method bro (line 355) | def bro(node):
    method parent (line 371) | def parent(node):
    method children_count (line 382) | def children_count(self, node):
    method draw_img (line 390) | def draw_img(self, img_name='Red_Black_Tree.png'):

FILE: python/28_binary_heap/binary_heap.py
  class BinaryHeap (line 8) | class BinaryHeap:
    method __init__ (line 12) | def __init__(self, data=None, capacity=100):
    method heapify (line 23) | def heapify(self):
    method _heapify (line 30) | def _heapify(self, data, tail_idx):
    method _heap_down (line 48) | def _heap_down(data, idx, tail_idx):
    method insert (line 77) | def insert(self, num):
    method _insert (line 90) | def _insert(data, num):
    method get_top (line 116) | def get_top(self):
    method remove_top (line 125) | def remove_top(self):
    method _remove_top (line 137) | def _remove_top(data):
    method _type_assert (line 160) | def _type_assert(nums):
    method _draw_heap (line 166) | def _draw_heap(data):
    method __repr__ (line 188) | def __repr__(self):

FILE: python/28_binary_heap/binary_heap_sort.py
  class BinaryHeapSort (line 7) | class BinaryHeapSort(BinaryHeap):
    method __init__ (line 8) | def __init__(self):
    method sort (line 11) | def sort(self, nums):

FILE: python/28_binary_heap/heap.py
  class Heap (line 8) | class Heap:
    method __init__ (line 9) | def __init__(self, nums=None, capacity=100):
    method _heapify (line 19) | def _heapify(self):
    method _heap_down (line 29) | def _heap_down(self, idx):
    method insert (line 32) | def insert(self, num):
    method get_top (line 35) | def get_top(self):
    method remove_top (line 40) | def remove_top(self):
    method get_data (line 51) | def get_data(self):
    method get_length (line 54) | def get_length(self):
    method _draw_heap (line 58) | def _draw_heap(data):
    method __repr__ (line 80) | def __repr__(self):
  class MaxHeap (line 84) | class MaxHeap(Heap):
    method _heap_down (line 85) | def _heap_down(self, idx):
    method insert (line 106) | def insert(self, num):
  class MinHeap (line 126) | class MinHeap(Heap):
    method _heap_down (line 127) | def _heap_down(self, idx):
    method insert (line 148) | def insert(self, num):

FILE: python/28_binary_heap/priority_queue.py
  class QueueNode (line 7) | class QueueNode:
    method __init__ (line 8) | def __init__(self, priority, data=None):
    method __repr__ (line 13) | def __repr__(self):
  class PriorityQueue (line 17) | class PriorityQueue:
    method __init__ (line 18) | def __init__(self, capacity=100):
    method enqueue (line 23) | def enqueue(self, priority, data=None):
    method dequeue (line 43) | def dequeue(self):
    method get_length (line 72) | def get_length(self):
    method _draw_heap (line 76) | def _draw_heap(data):
    method __repr__ (line 98) | def __repr__(self):

FILE: python/28_binary_heap/top_k.py
  function top_k (line 8) | def top_k(nums, k):

FILE: python/28_heap/heap.py
  class Heap (line 9) | class Heap:
    method __init__ (line 10) | def __init__(self, capacity: int):
    method _parent (line 16) | def _parent(cls, child_index: int) -> int:
    method _left (line 21) | def _left(cls, parent_index: int) -> int:
    method _right (line 26) | def _right(cls, parent_index: int) -> int:
    method _siftup (line 30) | def _siftup(self) -> None:
    method _siftdown (line 37) | def _siftdown(cls, a: List[int], count: int, root_index: int = 1) -> N...
    method insert (line 49) | def insert(self, value: int) -> None:
    method remove_max (line 55) | def remove_max(self) -> Optional[int]:
    method build_heap (line 64) | def build_heap(cls, a: List[int]) -> None:
    method sort (line 70) | def sort(cls, a: List[int]) -> None:
    method __repr__ (line 79) | def __repr__(self):

FILE: python/28_heap/min_heap.py
  class Heap (line 1) | class Heap(object):
    method __init__ (line 9) | def __init__(self, nums):
    method _siftup (line 12) | def _siftup(self, pos):
    method _siftdown (line 36) | def _siftdown(self, start, pos):
    method heapify (line 53) | def heapify(self):
    method heappop (line 67) | def heappop(self):
    method heappush (line 81) | def heappush(self, val):
    method __repr__ (line 90) | def __repr__(self):

FILE: python/31_bfs_dfs/bfs_dfs.py
  class Graph (line 10) | class Graph:
    method __init__ (line 12) | def __init__(self, num_vertices: int):
    method add_edge (line 16) | def add_edge(self, s: int, t: int) -> None:
    method _generate_path (line 20) | def _generate_path(self, s: int, t: int, prev: List[Optional[int]]) ->...
    method bfs (line 25) | def bfs(self, s: int, t: int) -> IO[str]:
    method dfs (line 48) | def dfs(self, s: int, t: int) -> IO[str]:

FILE: python/31_bfs_dfs/graph.py
  class Undigraph (line 4) | class Undigraph(object):
    method __init__ (line 7) | def __init__(self, vertex_num):
    method add_edge (line 13) | def add_edge(self, s, t):
    method __len__ (line 20) | def __len__(self):
    method __getitem__ (line 23) | def __getitem__(self, ind):
    method __repr__ (line 28) | def __repr__(self):
    method __str__ (line 31) | def __str__(self):
  class Digraph (line 35) | class Digraph(object):
    method __init__ (line 38) | def __init__(self, vertex_num):
    method add_edge (line 44) | def add_edge(self, frm, to):
    method __len__ (line 49) | def __len__(self):
    method __getitem__ (line 52) | def __getitem__(self, ind):
    method __repr__ (line 57) | def __repr__(self):
    method __str__ (line 60) | def __str__(self):

FILE: python/31_bfs_dfs/graph_application.py
  function find_vertex_by_degree (line 8) | def find_vertex_by_degree(graph, s, degree):

FILE: python/32_bf_rk/bf_rk.py
  function bf (line 7) | def bf(main, pattern):
  function simple_hash (line 32) | def simple_hash(s, start, end):
  function rk (line 49) | def rk(main, pattern):

FILE: python/33_bm/bm.py
  function _generate_bad_character_table (line 11) | def _generate_bad_character_table(pattern: str) -> List[int]:
  function _generate_good_suffix_table (line 18) | def _generate_good_suffix_table(pattern: str) -> Tuple[List[bool], List[...
  function _move_by_good_suffix (line 40) | def _move_by_good_suffix(bad_character_index: int, suffix: List[int], pr...
  function bm (line 49) | def bm(s: str, pattern: str) -> int:

FILE: python/33_bm/bm_.py
  function bm (line 7) | def bm(main, pattern):
  function generate_bc (line 58) | def generate_bc(pattern, m, bc):
  function generate_gs (line 70) | def generate_gs(pattern, m, suffix, prefix):
  function move_by_gs (line 91) | def move_by_gs(j, m, suffix, prefix):

FILE: python/34_kmp/kmp.py
  function kmp (line 9) | def kmp(s: int, pattern: int) -> int:
  function _get_partial_match_table (line 22) | def _get_partial_match_table(pattern: int) -> List[int]:

FILE: python/34_kmp/kmp_.py
  function kmp (line 5) | def kmp(main, pattern):
  function get_next (line 38) | def get_next(pattern):

FILE: python/35_trie/trie.py
  class TrieNode (line 5) | class TrieNode:
    method __init__ (line 6) | def __init__(self, data: str):
  class Trie (line 12) | class Trie:
    method __init__ (line 13) | def __init__(self):
    method insert (line 16) | def insert(self, text: str) -> None:
    method find (line 24) | def find(self, pattern: str) -> bool:

FILE: python/35_trie/trie_.py
  class Node (line 10) | class Node:
    method __init__ (line 11) | def __init__(self, c):
    method insert_child (line 17) | def insert_child(self, c):
    method _insert_child (line 20) | def _insert_child(self, node):
    method has_child (line 38) | def has_child(self, c):
    method get_child (line 41) | def get_child(self, c):
    method _find_insert_idx (line 62) | def _find_insert_idx(self, v):
    method __repr__ (line 83) | def __repr__(self):
  class Trie (line 88) | class Trie:
    method __init__ (line 89) | def __init__(self):
    method gen_tree (line 92) | def gen_tree(self, string_list):
    method search (line 109) | def search(self, pattern):
    method draw_img (line 129) | def draw_img(self, img_name='Trie.png'):

FILE: python/36_ac_automata/ac_automata.py
  class ACNode (line 10) | class ACNode:
    method __init__ (line 11) | def __init__(self, data: str):
  class ACAutomata (line 19) | class ACAutomata:
    method __init__ (line 20) | def __init__(self):
    method _build_suffix_link (line 23) | def _build_suffix_link(self) -> None:
    method _insert (line 44) | def _insert(self, text: str) -> None:
    method insert (line 53) | def insert(self, patterns: List[str]) -> None:
    method match (line 58) | def match(self, text: str) -> None:

FILE: python/36_ac_automata/ac_automata_.py
  class ACNode (line 8) | class ACNode(Node):
    method __init__ (line 9) | def __init__(self, c: str):
    method insert_child (line 14) | def insert_child(self, c: str):
  class ACTrie (line 18) | class ACTrie(Trie):
    method __init__ (line 19) | def __init__(self):
  function ac_automata (line 23) | def ac_automata(main: str, ac_trie: ACTrie) -> list:
  function build_failure_pointer (line 45) | def build_failure_pointer(ac_trie: ACTrie) -> None:

FILE: python/38_divide_and_conquer/merge_sort_counting.py
  function merge_sort_counting (line 7) | def merge_sort_counting(nums, start, end):
  function merge (line 17) | def merge(nums, start, mid, end):

FILE: python/39_back_track/01_bag.py
  function bag (line 11) | def bag(capacity: int, cur_weight: int, items_info: List, pick_idx: int):
  function get_value (line 36) | def get_value(items_info: List, pick_items: List):

FILE: python/39_back_track/eight_queens.py
  function eight_queens (line 11) | def eight_queens(cur_column: int):
  function is_valid_pos (line 29) | def is_valid_pos(cur_column: int, pos: int) -> bool:

FILE: python/39_back_track/permutations.py
  function permutations (line 9) | def permutations(nums: List, n: int, pick_count: int):

FILE: python/39_back_track/regex.py
  function rmatch (line 7) | def rmatch(r_idx: int, m_idx: int, regex: str, main: str):

FILE: python/39_backtracking/backtracking.py
  function eight_queens (line 7) | def eight_queens() -> None:

FILE: python/40_dynamic_programming/01_bag.py
  function bag (line 7) | def bag(items_info: List[int], capacity: int) -> int:
  function bag_with_max_value (line 33) | def bag_with_max_value(items_info: List[Tuple[int, int]], capacity: int)...

FILE: python/40_dynamic_programming/knapsack.py
  function knapsack01 (line 7) | def knapsack01(weights: List[int], values: List[int], capacity: int) -> ...

FILE: python/40_dynamic_programming/yh_triangle.py
  function yh_triangle (line 9) | def yh_triangle(nums: List[Layer_nums]) -> int:
  function yh_triangle_space_optimization (line 32) | def yh_triangle_space_optimization(nums: List[Layer_nums]) -> int:
  function yh_triangle_bottom_up (line 49) | def yh_triangle_bottom_up(nums: List[Layer_nums]) -> int:

FILE: python/41_dynamic_programming/coins_problem.py
  function coins_dp (line 7) | def coins_dp(values: List[int], target: int) -> int:
  function coins_backtracking (line 29) | def coins_backtracking(values: List[int], target: int, cur_value: int, c...

FILE: python/41_dynamic_programming/min_dist.py
  function min_dist (line 8) | def min_dist(weights: List[List[int]]) -> int:
  function min_dist_recur (line 24) | def min_dist_recur(weights: List[List[int]]) -> int:

FILE: python/42_dynamic_programming/longest_increasing_subsequence.py
  function longest_increasing_subsequence (line 7) | def longest_increasing_subsequence(nums: List[int]) -> int:

FILE: python/42_dynamic_programming/min_edit_dist.py
  function levenshtein_dp (line 5) | def levenshtein_dp(s: str, t: str) -> int:
  function common_substring_dp (line 33) | def common_substring_dp(s: str, t: str) -> int:

FILE: python/43_topological_sorting/topological_sorting.py
  class Graph (line 8) | class Graph:
    method __init__ (line 9) | def __init__(self, num_vertices: int):
    method add_edge (line 13) | def add_edge(self, s: int, t: int) -> None:
    method tsort_by_kahn (line 16) | def tsort_by_kahn(self) -> None:
    method tsort_by_dfs (line 32) | def tsort_by_dfs(self) -> None:

FILE: python/44_shortest_path/dijkstra.py
  class Graph (line 8) | class Graph:
    method __init__ (line 9) | def __init__(self, vertex_count: int) -> None:
    method add_edge (line 12) | def add_edge(self, s: int, t: int, w: int) -> None:
    method __len__ (line 16) | def __len__(self) -> int:
  class Vertex (line 20) | class Vertex:
    method __init__ (line 21) | def __init__(self, v: int, dist: int) -> None:
    method __gt__ (line 25) | def __gt__(self, other) -> bool:
    method __repr__ (line 28) | def __repr__(self) -> str:
  class Edge (line 32) | class Edge:
    method __init__ (line 33) | def __init__(self, source: int, target: int, weight: int) -> None:
  class VertexPriorityQueue (line 39) | class VertexPriorityQueue:
    method __init__ (line 40) | def __init__(self) -> None:
    method get (line 43) | def get(self) -> Vertex:
    method put (line 46) | def put(self, v: Vertex) -> None:
    method empty (line 50) | def empty(self) -> bool:
    method update_priority (line 53) | def update_priority(self) -> None:
    method __repr__ (line 56) | def __repr__(self) -> str:
  function dijkstra (line 60) | def dijkstra(g: Graph, s: int, t: int) -> int:
  function print_path (line 99) | def print_path(s: int, t: int, p: List[int]) -> Generator[int, None, None]:

FILE: python/44_shortest_path/shortest_path.py
  class Edge (line 11) | class Edge:
  class Vertex (line 17) | class Vertex:
  class Graph (line 21) | class Graph:
    method __init__ (line 22) | def __init__(self, num_vertices: int):
    method add_edge (line 26) | def add_edge(self, from_vertex: int, to_vertex: int, weight: int) -> N...
    method dijkstra (line 29) | def dijkstra(self, from_vertex: int, to_vertex: int) -> None:

FILE: python/45_bitmap/bitmap.py
  class Bitmap (line 7) | class Bitmap:
    method __init__ (line 8) | def __init__(self, num_bits: int):
    method setbit (line 12) | def setbit(self, k: int) -> None:
    method getbit (line 16) | def getbit(self, k: int) -> Optional[bool]:

FILE: python/array.py
  class Array (line 6) | class Array():
    method __init__ (line 8) | def __init__(self):
    method find (line 12) | def find(self, index):
    method delete (line 27) | def delete(self, index):
    method insert (line 43) | def insert(self, index, value):
    method insertToTail (line 60) | def insertToTail(self, value):
    method printAll (line 68) | def printAll(self):

FILE: rust/05_array/main.rs
  type NewArray (line 1) | struct NewArray {
    method new (line 7) | fn new(capacity: usize) -> NewArray {
    method find (line 11) | fn find(&self, index: usize) -> i32 {
    method insert (line 16) | fn insert(&mut self, index: usize, value: i32) -> bool {
    method remove (line 40) | fn remove(&mut self, index: usize) -> i32 {
  function main (line 60) | fn main() {

FILE: rust/07_linkedlist/linked_list_cycle.rs
  function has_cycle (line 3) | pub fn has_cycle(head: Option<Box<ListNode>>) -> bool {
  function main (line 16) | fn main() {

FILE: rust/07_linkedlist/merge_two_sorted_lists.rs
  function merge_two_lists (line 3) | pub fn merge_two_lists(l1: Option<Box<ListNode>>, l2: Option<Box<ListNod...
  function main (line 22) | fn main() {

FILE: rust/07_linkedlist/middle_of_the_linked_list.rs
  function middle_node (line 3) | pub fn middle_node(head: Option<Box<ListNode>>) -> Option<Box<ListNode>> {
  function main (line 14) | fn main() {

FILE: rust/07_linkedlist/remove_nth_node_from_end_of_list.rs
  function remove_nth_from_end (line 3) | pub fn remove_nth_from_end(head: Option<Box<ListNode>>, n: i32) -> Optio...
  function main (line 26) | fn main() {

FILE: rust/07_linkedlist/reverse_linked_list.rs
  function reverse_list (line 3) | pub fn reverse_list(head: Option<Box<ListNode>>) -> Option<Box<ListNode>> {
  function main (line 18) | fn main() {

FILE: rust/07_linkedlist/util/linked_list.rs
  type ListNode (line 3) | pub struct ListNode {
    method new (line 10) | fn new(val: i32) -> Self {
  function to_list (line 18) | pub fn to_list(vec: Vec<i32>) -> Option<Box<ListNode>> {

FILE: rust/08_stack/simple_browser.rs
  type Browser (line 6) | struct Browser {
    method new (line 13) | fn new() -> Self {
    method open (line 17) | fn open(&mut self, url: &String) {
    method go_back (line 25) | fn go_back(&mut self) -> String {
    method go_forward (line 37) | fn go_forward(&mut self) -> String {
    method can_go_back (line 49) | fn can_go_back(&self) -> bool {
    method can_go_forward (line 53) | fn can_go_forward(&self) -> bool {
    method show_url (line 57) | fn show_url(&mut self, url: &String, prefix: String) {
    method check_current_page (line 62) | fn check_current_page(&self) {
  function main (line 66) | fn main() {

FILE: rust/08_stack/stack_based_on_array.rs
  type ArrayStack (line 2) | struct ArrayStack {
    method new (line 8) | fn new() -> Self {
    method push (line 12) | fn push(&mut self, x: i32) {
    method pop (line 24) | fn pop(&mut self) {
    method top (line 30) | fn top(&self) -> i32 {
    method is_empty (line 35) | fn is_empty(&self) -> bool {
  function main (line 40) | fn main() {

FILE: rust/08_stack/stack_based_on_linked_list.rs
  type ListNode (line 2) | pub struct ListNode {
    method new (line 13) | fn new(val: String) -> Self {
  type LinkedListStack (line 8) | pub struct LinkedListStack {
    method new (line 19) | pub fn new() -> Self {
    method push (line 23) | pub fn push(&mut self, x: String) {
    method pop (line 29) | pub fn pop(&mut self) -> String {
    method print_all (line 37) | pub fn print_all(&mut self) {
    method clear (line 48) | pub fn clear(&mut self) {
    method is_empty (line 52) | pub fn is_empty(&self) -> bool {

FILE: rust/09_queue/array_queue.rs
  type ArrayQueue (line 2) | struct ArrayQueue {
    method new (line 9) | fn new(n: usize) -> Self {
    method enqueue (line 17) | fn enqueue(&mut self, num: i32) -> bool {
    method dequeue (line 36) | fn dequeue(&mut self) -> i32 {
    method print_all (line 44) | fn print_all(&self) {
  function main (line 54) | fn main() {

FILE: rust/09_queue/circle_queue.rs
  type CircleQueue (line 2) | struct CircleQueue {
    method new (line 10) | fn new(n: i32) -> Self {
    method enqueue (line 19) | fn enqueue(&mut self, num: i32) -> bool {
    method dequeue (line 26) | fn dequeue(&mut self) -> i32 {
    method print_all (line 34) | fn print_all(&self) {
  function main (line 44) | fn main() {

FILE: rust/09_queue/linked_list_queue.rs
  type LinkedListQueue (line 6) | pub struct LinkedListQueue {
    method new (line 30) | pub fn new() -> Self {
    method dequeue (line 37) | pub fn dequeue(&mut self) -> i32 {
    method enqueue (line 45) | pub fn enqueue(&mut self, elt: i32) {
  type Node (line 11) | pub struct Node {
    method new (line 17) | fn new(element: i32) -> Self {
    method into_element (line 24) | fn into_element(self: Box<Self>) -> i32 {
  function main (line 61) | fn main() {

FILE: rust/11_sorts/bubble_sort.rs
  function bubble_sort (line 4) | fn bubble_sort(mut nums: Vec<i32>) -> Vec<i32> {
  function main (line 26) | fn main() {

FILE: rust/11_sorts/insertion_sort.rs
  function insertion_sort (line 4) | fn insertion_sort(mut nums: Vec<i32>) -> Vec<i32> {
  function main (line 24) | fn main() {

FILE: rust/11_sorts/selection_sort.rs
  function selection_sort (line 4) | fn selection_sort(mut nums: Vec<i32>) -> Vec<i32> {
  function main (line 23) | fn main() {

FILE: rust/12_sorts/kth_largest.rs
  function kth_largest (line 1) | pub fn kth_largest(mut nums: Vec<i32>, k: i32) -> Option<i32> {
  function partition (line 19) | fn partition(nums: &mut Vec<i32>, start: usize, end: usize) -> usize {
  function swap (line 33) | fn swap(nums: &mut Vec<i32>, i: usize, j: usize) {
  function main (line 41) | fn main() {

FILE: rust/12_sorts/merge_sort.rs
  function merge_sort (line 4) | pub fn merge_sort(mut nums: Vec<i32>) -> Vec<i32> {
  function merge_sort_internally (line 12) | fn merge_sort_internally(nums: &mut Vec<i32>, start: usize, end: usize) {
  function merge (line 23) | fn merge(nums: &mut Vec<i32>, start: usize, middle: usize, end: usize) {
  function main (line 54) | fn main() {

FILE: rust/12_sorts/quick_sort.rs
  function quick_sort (line 4) | pub fn quick_sort(mut nums: Vec<i32>) -> Vec<i32> {
  function quick_sort_internally (line 12) | fn quick_sort_internally(nums: &mut Vec<i32>, start: usize, end: usize) {
  function partition (line 23) | fn partition(nums: &mut Vec<i32>, start: usize, end: usize) -> usize {
  function swap (line 37) | fn swap(nums: &mut Vec<i32>, i: usize, j: usize) {
  function main (line 45) | fn main() {

FILE: rust/13_sorts/bucket_sort.rs
  function bucket_sort (line 4) | pub fn bucket_sort(mut nums: Vec<i32>, step: i32) -> Vec<i32> {
  function quick_sort (line 35) | pub fn quick_sort(mut nums: Vec<i32>) -> Vec<i32> {
  function quick_sort_internally (line 43) | fn quick_sort_internally(nums: &mut Vec<i32>, start: usize, end: usize) {
  function partition (line 54) | fn partition(nums: &mut Vec<i32>, start: usize, end: usize) -> usize {
  function swap (line 68) | fn swap(nums: &mut Vec<i32>, i: usize, j: usize) {
  function main (line 76) | fn main() {

FILE: rust/13_sorts/counting_sort.rs
  function counting_sort (line 4) | pub fn counting_sort(mut nums: Vec<i32>) -> Vec<i32> {
  function main (line 48) | fn main() {

FILE: rust/13_sorts/radix_sort.rs
  function radix_sort (line 4) | pub fn radix_sort(mut nums: Vec<i64>) -> Vec<i64> {
  function max_bit (line 40) | fn max_bit(nums: &Vec<i64>) -> i32 {
  function main (line 54) | fn main() {

FILE: rust/13_sorts/sort_string.rs
  function sort_string (line 1) | fn sort_string(s: String) -> Vec<Vec<char>> {
  function main (line 15) | fn main() {

FILE: rust/15_binary_search/binary_search.rs
  function binary_search (line 2) | pub fn binary_search(nums: Vec<i32>, value: i32) -> i32 {
  function binary_search_recursion (line 22) | pub fn binary_search_recursion(nums: Vec<i32>, value: i32) -> i32 {
  function _recursion (line 28) | fn _recursion(nums: &Vec<i32>, low: usize, high: usize, value: i32) -> i...
  function main (line 41) | fn main() {

FILE: rust/15_binary_search/sqrtx.rs
  function my_sqrt (line 3) | pub fn my_sqrt(x: i32, precision: f32) -> f32 {
  function main (line 26) | fn main() {

FILE: rust/16_binary_search/binary_search.rs
  function find_first_eq (line 2) | fn find_first_eq(nums: Vec<i32>, value: i32) -> i32 {
  function find_last_eq (line 21) | fn find_last_eq(nums: Vec<i32>, value: i32) -> i32 {
  function find_first_ge (line 40) | fn find_first_ge(nums: Vec<i32>, value: i32) -> i32 {
  function find_last_le (line 59) | fn find_last_le(nums: Vec<i32>, value: i32) -> i32 {
  function main (line 77) | fn main() {

FILE: rust/16_binary_search/search_in_rotated_sorted_array.rs
  function search (line 2) | pub fn search(nums: Vec<i32>, target: i32) -> i32 {
  function main (line 31) | fn main() {

FILE: rust/19_hash_table/hash_table.rs
  type MyHashTable (line 2) | pub struct MyHashTable<'a> {
  function new (line 8) | fn new() -> MyHashTable<'a> {
  function insert (line 15) | pub fn insert(&mut self, key: &'a str, value: &'a str) {
  function get (line 20) | pub fn get(&self, key: &'a str) -> Option<&'a str> {
  function remove (line 25) | pub fn remove(&mut self, key: &'a str) -> Option<&'a str> {
  function hash (line 32) | fn hash(&self, key: &'a str) -> i32 {
  function hash_code (line 37) | fn hash_code(&self, key: &'a str) -> i32 {
  function main (line 45) | fn main() {

FILE: rust/23_binary_tree/inorder_traversal.rs
  function inorder_traversal (line 5) | pub fn inorder_traversal(root: Option<Rc<RefCell<TreeNode>>>) -> Vec<i32> {
  function _inorder (line 13) | fn _inorder(root: Option<Rc<RefCell<TreeNode>>>, result: &mut Vec<i32>) {
  function inorder_traversal (line 25) | pub fn inorder_traversal(root: Option<Rc<RefCell<TreeNode>>>) -> Vec<i32> {

FILE: rust/23_binary_tree/level_order_traversal.rs
  function level_order (line 6) | pub fn level_order(root: Option<Rc<RefCell<TreeNode>>>) -> Vec<Vec<i32>> {

FILE: rust/23_binary_tree/postorder_traversal.rs
  function postorder_traversal (line 5) | pub fn postorder_traversal(root: Option<Rc<RefCell<TreeNode>>>) -> Vec<i...
  function _postorder (line 13) | fn _postorder(root: Option<Rc<RefCell<TreeNode>>>, result: &mut Vec<i32>) {
  function postorder_traversal (line 25) | pub fn postorder_traversal(root: Option<Rc<RefCell<TreeNode>>>) -> Vec<i...

FILE: rust/23_binary_tree/preorder_traversal.rs
  function preorder_traversal (line 5) | pub fn preorder_traversal(root: Option<Rc<RefCell<TreeNode>>>) -> Vec<i3...
  function _preorder (line 13) | fn _preorder(root: Option<Rc<RefCell<TreeNode>>>, result: &mut Vec<i32>) {
  function inorder_traversal (line 25) | pub fn inorder_traversal(root: Option<Rc<RefCell<TreeNode>>>) -> Vec<i32> {

FILE: rust/23_binary_tree/util/tree.rs
  type TreeNode (line 5) | pub struct TreeNode {
    method new (line 13) | pub fn new(val: i32) -> Self {
  function to_tree (line 22) | pub fn to_tree(vec: Vec<Option<i32>>) -> Option<Rc<RefCell<TreeNode>>> {

FILE: rust/24_binary_tree/insert_in_binary_tree.rs
  function insert_into_bst (line 4) | pub fn insert_into_bst(root: Option<Rc<RefCell<TreeNode>>>, val: i32) ->...
  function insert (line 8) | fn insert(node: &Option<Rc<RefCell<TreeNode>>>, val: i32) {

FILE: rust/24_binary_tree/max_depth_in_binary_tree.rs
  function max_depth (line 5) | pub fn max_depth(root: Option<Rc<RefCell<TreeNode>>>) -> i32 {
  function max_depth (line 29) | pub fn max_depth(root: Option<Rc<RefCell<TreeNode>>>) -> i32 {

FILE: rust/24_binary_tree/search_in_binary_tree.rs
  function search_bst (line 5) | pub fn search_bst(root: Option<Rc<RefCell<TreeNode>>>, val: i32) -> Opti...
  function search_bst (line 19) | pub fn search_bst(root: Option<Rc<RefCell<TreeNode>>>, val: i32) -> Opti...

FILE: rust/24_binary_tree/util/tree.rs
  type TreeNode (line 5) | pub struct TreeNode {
    method new (line 13) | pub fn new(val: i32) -> Self {
  function to_tree (line 22) | pub fn to_tree(vec: Vec<Option<i32>>) -> Option<Rc<RefCell<TreeNode>>> {

FILE: rust/28_heap/build_heap.rs
  function build_heap_down_up (line 2) | pub fn build_heap_down_up(nums: &mut Vec<i32>) {
  function heapify_down_up (line 8) | fn heapify_down_up(nums: &mut Vec<i32>, idx: usize) {
  function build_heap_up_down (line 20) | pub fn build_heap_up_down(nums: &mut Vec<i32>) {
  function heapify_up_down (line 27) | fn heapify_up_down(nums: &mut Vec<i32>, idx: usize, nums_len: usize) {
  function swap (line 40) | fn swap(nums: &mut Vec<i32>, idx: usize, parent_idx: usize) {
  function main (line 46) | fn main() {

FILE: rust/28_heap/heap.rs
  type Heap (line 2) | struct Heap {
    method new (line 9) | pub fn new(capacity: usize) -> Self {
    method insert (line 17) | pub fn insert(&mut self, x: i32) -> bool {
    method remove_max (line 40) | pub fn remove_max(&mut self) -> Option<i32> {
    method heapify (line 55) | fn heapify(&mut self) {
    method swap (line 68) | fn swap(&mut self, idx: usize, parent_idx: usize) {
  function main (line 75) | fn main() {

FILE: rust/28_heap/sort_heap.rs
  function sort (line 1) | pub fn sort(nums: &mut Vec<i32>) {
  function build_heap (line 9) | fn build_heap(nums: &mut Vec<i32>) {
  function heapify (line 16) | fn heapify(nums: &mut Vec<i32>, idx: usize, nums_len: usize) {
  function swap (line 29) | fn swap(nums: &mut Vec<i32>, idx: usize, parent_idx: usize) {
  function main (line 35) | fn main() {

FILE: rust/29_heap/get_median.rs
  function get_median (line 5) | fn get_median(nums: &mut Vec<i32>, x: i32) -> i32 {
  function main (line 46) | fn main() {

FILE: rust/29_heap/get_top_k.rs
  function get_top_k (line 4) | fn get_top_k(nums: &mut Vec<i32>, k: i32, x: i32) -> Vec<i32> {
  function main (line 38) | fn main() {

FILE: rust/29_heap/merge_sorted_array.rs
  function merge_sorted_array (line 3) | fn merge_sorted_array(nums1: &mut Vec<i32>, nums2: &mut Vec<i32>, nums3:...
  function main (line 31) | fn main() {

FILE: rust/31_graph/graph_search.rs
  type Graph (line 6) | struct Graph {
    method new (line 12) | fn new(v: i32) -> Self {
    method add_edge (line 20) | fn add_edge(&mut self, s: i32, t: i32) {
    method bfs (line 25) | fn bfs(&self, s: i32, t: i32) {
    method dfs (line 50) | fn dfs(&self, s: i32, t: i32) {
    method recur_dfs (line 59) | fn recur_dfs(&self,
    method draw (line 79) | fn draw(&self, prev: &Vec<i32>, s: i32, t: i32) {
  function main (line 88) | fn main() {

FILE: rust/32_string/bf_rk.rs
  function bf (line 3) | fn bf(primary: &str, pattern: &str) -> i32 {
  function rk (line 18) | fn rk(primary: &str, pattern: &str) -> i32 {
  function main (line 65) | fn main() {

FILE: rust/33_string/bm.rs
  function generate_bc (line 2) | fn generate_bc(pattern: &str) -> Vec<i32> {
  function generate_gs (line 12) | fn generate_gs(pattern: &str) -> (Vec<i32>, Vec<bool>) {
  function move_by_gs (line 34) | fn move_by_gs(bad_char_start_index: usize, pattern_len: usize, suffix: &...
  function bm_search (line 47) | fn bm_search(primary: &str, pattern: &str) -> i32 {
  function main (line 75) | fn main() {

FILE: rust/34_string/kmp.rs
  function kmp_search (line 1) | fn kmp_search(primary: &str, pattern: &str) -> Vec<i32> {
  function get_failure_function (line 29) | fn get_failure_function(pattern: &str) -> Vec<i32> {
  function main (line 50) | fn main() {

FILE: rust/35_trie/trie.rs
  type Trie (line 4) | struct Trie {
    method new (line 10) | fn new() -> Self {
    method insert (line 14) | fn insert(&mut self, word: &str) {
    method find (line 22) | fn find(&self, word: &str) -> bool {
  function main (line 34) | fn main() {

FILE: rust/38_divide_and_conquer/merge_sort_count.rs
  function merge_sort_count (line 1) | fn merge_sort_count(mut nums: Vec<i32>) -> i32 {
  function merge_sort (line 8) | fn merge_sort(nums: &mut Vec<i32>, low: usize, high: usize, count: &mut ...
  function merge (line 18) | fn merge(nums:   &mut Vec<i32>,
  function main (line 53) | fn main() {

FILE: rust/39_back_tracking/bag.rs
  function solve_bag (line 3) | fn solve_bag(items: Vec<i32>, capacity: i32) -> HashMap<i32, Vec<i32>> {
  function bag (line 21) | fn bag(pick_idx:       i32,
  function get_value (line 62) | fn get_value(items: &Vec<i32>, picks: &Vec<i32>) -> i32 {
  function main (line 70) | fn main() {

FILE: rust/39_back_tracking/bag_exec.rs
  function solve_bag (line 3) | fn solve_bag(items: Vec<(i32, i32)>, capacity: i32) -> HashMap<i32, Vec<...
  function bag (line 21) | fn bag(pick_idx:       i32,
  function get_value (line 63) | fn get_value(items: &Vec<(i32, i32)>, picks: &Vec<i32>) -> i32 {
  function main (line 71) | fn main() {

FILE: rust/39_back_tracking/n_queens.rs
  function solve_n_queens (line 3) | pub fn solve_n_queens(n: i32) -> Vec<Vec<String>> {
  function schedule_queens (line 10) | fn schedule_queens(board: &mut Vec<Vec<char>>, solution: &mut Vec<Vec<St...
  function collision (line 25) | fn collision(board: &Vec<Vec<char>>, len: usize, row: usize, col: usize)...
  function main (line 42) | fn main() {

FILE: rust/39_back_tracking/regex.rs
  function regex_match (line 1) | fn regex_match(text: &str, regex: &str) -> bool {
  function rematch (line 9) | fn rematch(text_chars:  &Vec<char>,
  function main (line 44) | fn main() {

FILE: rust/40_dynamic_programming/bag.rs
  function knapsack (line 1) | fn knapsack(items: Vec<i32>, capacity: i32) -> i32 {
  function main (line 37) | fn main() {

FILE: rust/40_dynamic_programming/knapsack.rs
  function knapsack (line 1) | fn knapsack(items: Vec<(i32, i32)>, capacity: i32) -> i32 {
  function main (line 27) | fn main() {

FILE: rust/40_dynamic_programming/triangle.rs
  function minimum_total (line 3) | pub fn minimum_total(mut triangle: Vec<Vec<i32>>) -> i32 {
  function main (line 14) | fn main() {

FILE: rust/41_dynamic_programming/coin_change.rs
  function coin_change (line 1) | fn coin_change(coins: Vec<i32>, amount: i32) -> i32 {
  function main (line 15) | fn main() {

FILE: rust/41_dynamic_programming/min_dis_path.rs
  function min_dis_path (line 1) | fn min_dis_path(matrix: Vec<Vec<i32>>) -> i32 {
  function main (line 28) | fn main() {

FILE: rust/42_dynamic_programming/edit_distance.rs
  function edit_distance (line 2) | fn edit_distance(word1: &str, word2: &str) -> i32 {
  function main (line 24) | fn main() {

FILE: rust/42_dynamic_programming/longest_increasing_subsequence.rs
  function longest_increasing_subsequence (line 2) | fn longest_increasing_subsequence(nums: Vec<i32>) -> i32 {
  function main (line 18) | fn main() {

FILE: typescript/06_linkedlist/LRUCache.ts
  class LRUCache (line 5) | class LRUCache<K, V> {
    method constructor (line 11) | constructor(limit: number) {
    method get (line 17) | public get(key: K): V | null {
    method put (line 24) | public put(key: K, value: V) {
    method refreshNode (line 43) | private refreshNode(node: LinkedListNode<K, V>) {
    method removeNode (line 49) | private removeNode(node: LinkedListNode<K, V>): K {
    method addNode (line 66) | private addNode(node: LinkedListNode<K, V>) {
  class LinkedListNode (line 80) | class LinkedListNode<K, V> {
    method constructor (line 86) | constructor(

FILE: typescript/06_linkedlist/LinkedList.ts
  class LinkedList (line 7) | class LinkedList<T> implements List<T> {
    method findByIndex (line 12) | findByIndex(index: number): LinkedListNode<T> | null {
    method findByValue (line 22) | findByValue(value: T): LinkedListNode<T> | null {
    method insertToHead (line 30) | insertToHead(value: T): void {
    method insertToIndex (line 49) | insertToIndex(value: T, index: number): void {
    method insertToTail (line 64) | insertToTail(value: T): void {
    method remove (line 78) | remove(value: T): boolean {
    method toString (line 98) | toString(): string {
  class LinkedListNode (line 109) | class LinkedListNode<T> {
    method constructor (line 114) | constructor(

FILE: typescript/06_linkedlist/List.ts
  type List (line 1) | interface List<T> {

FILE: typescript/06_linkedlist/SingleLinkedList.ts
  class SingleLinkedList (line 7) | class SingleLinkedList<T> implements List<T> {
    method constructor (line 11) | constructor() {
    method findByValue (line 15) | public findByValue(value: T): SingleNode<T> | null {
    method findByIndex (line 24) | public findByIndex(index: number): SingleNode<T> | null {
    method insertToIndex (line 39) | public insertToIndex(value: T, index: number): void {
    method remove (line 56) | public remove(value: T): boolean {
    method insertToHead (line 67) | public insertToHead(value: T): void {
    method insertToTail (line 72) | public insertToTail(value: T): void {
    method insertNodeToHead (line 77) | private insertNodeToHead(node: SingleNode<T>): void {
    method toString (line 82) | public toString(): string {
    method insertNodeToTail (line 96) | private insertNodeToTail(newNode: SingleNode<T>): void {
  class SingleNode (line 105) | class SingleNode<T> {
    method constructor (line 109) | constructor(value: T, next: SingleNode<T> | null = null) {

FILE: typescript/07_linkedlist/LinkedListAlog.ts
  class LinkedListAlog (line 9) | class LinkedListAlog {
    method reverse (line 14) | public static reverse<T>(list: SingleNode<T>): SingleNode<T> | null {
    method checkCircle (line 30) | public static checkCircle<T>(list: SingleNode<T>): boolean {
    method removeFromEnd (line 47) | public static removeFromEnd<T>(list: SingleNode<T>, index: number): Si...
    method findMidNode (line 65) | public static findMidNode<T>(list: SingleNode<T>): SingleNode<T> | null {
    method mergeSortedLists (line 81) | public static mergeSortedLists<T>(a: SingleNode<T>, b: SingleNode<T>):...
  class SingleNode (line 114) | class SingleNode<T> {
    method constructor (line 118) | constructor(value: T, next: SingleNode<T> | null = null) {

FILE: typescript/08_stack/StackAndBrowser.ts
  class Stack (line 4) | class Stack<T> {
    method push (line 8) | public push(value: T) {
    method pop (line 20) | public pop(): T | null {
  class LinkedNode (line 34) | class LinkedNode<T> {
    method constructor (line 38) | constructor(value: T, next: LinkedNode<T> | null = null) {
  class Browser (line 47) | class Browser<T> {
    method constructor (line 54) | constructor(current: T) {
    method back (line 60) | public back(): T | null {
    method forward (line 69) | public forward(): T | null {
    method linkUrl (line 82) | public linkUrl(value: T) {
    method getCurrentPage (line 87) | public getCurrentPage(): T {

FILE: typescript/09_queue/CircularQueue.ts
  class CircularQueue (line 5) | class CircularQueue<T> {
    method constructor (line 14) | constructor(capacity: number) {
    method enqueue (line 18) | public enqueue(item: T): boolean {
    method dequeue (line 27) | public dequeue(): T | null {

FILE: typescript/09_queue/SimpleQueue.ts
  class SimpleQueue (line 4) | class SimpleQueue<T> {
    method enqueue (line 12) | public enqueue(value: T) {
    method dequeue (line 25) | public dequeue(): T | null {
    method printAll (line 32) | public printAll(): string {
  class LinkedNode (line 46) | class LinkedNode<T> {
    method constructor (line 50) | constructor(value: T, next: LinkedNode<T> | null = null) {

FILE: typescript/10_recursive/climbStairs.ts
  function fn (line 9) | function fn(n: number): any {
  function fnWithDepth (line 23) | function fnWithDepth(depth: number) {
  function fnWithMap (line 40) | function fnWithMap() {

FILE: typescript/11_sorts/simpleSort.ts
  type SortType (line 11) | enum SortType {
  type SortAlgo (line 16) | interface SortAlgo {
  class BubbleSort (line 20) | class BubbleSort implements SortAlgo {
    method sort (line 21) | sort(array: number[]) {
  class InsertSort (line 39) | class InsertSort implements SortAlgo {
    method sort (line 40) | sort(array: number[]) {
  class SortFactory (line 57) | class SortFactory {
    method getSortAlgo (line 58) | static getSortAlgo(type: SortType): SortAlgo {

FILE: typescript/12_sorts/KthNum.ts
  class KthNum (line 6) | class KthNum {
    method getKthNum (line 7) | getKthNum(array: number[], k: number): number {
    method partition (line 29) | private partition(array: number[], p: number, r: number) {
    method swap (line 42) | private swap(array: number[], p: number, q: number) {

FILE: typescript/12_sorts/MergeSort.ts
  class MergeSort (line 7) | class MergeSort {
    method mergeSort (line 8) | public static mergeSort(array: number[]) {
    method mergeSortInternally (line 14) | static mergeSortInternally(array: number[], p: number, r: number) {
    method mergeArray (line 24) | private static mergeArray(a: number[], p: number, q: number, r: number) {

FILE: typescript/12_sorts/quickSort.ts
  class QuickSort (line 7) | class QuickSort {
    method sort (line 8) | static sort(array: number[]): void {
    method sortInternally (line 11) | private static sortInternally(array: number[], p: number, r: number) {
    method partition (line 18) | private static partition(array: number[], p: number, r: number): number {
    method swap (line 37) | private static swap(array: number[], p: number, q: number) {

FILE: typescript/13_sorts/BucketSort.ts
  class BucketSort (line 10) | class BucketSort {
    method sort (line 11) | static sort(array: number[], bucketSize: number = 5) {

FILE: typescript/13_sorts/CountingSort.ts
  class CountingSort (line 8) | class CountingSort {
    method sort (line 9) | static sort(array: number[]) {

FILE: typescript/14_binarysearch/BinarySearch.ts
  class BinarySearch (line 6) | class BinarySearch {
    method bSearch (line 7) | static bSearch(array: number[], target: number) {

FILE: typescript/15_binarysearch/BinaryFind.ts
  class BinaryFind (line 5) | class BinaryFind {
    method findFirstElement (line 12) | static findFirstElement(array: number[], target: number): number {
    method findLastElement (line 39) | static findLastElement(array: number[], target: number): number {
    method findFirstElementGreaterThanTarget (line 67) | static findFirstElementGreaterThanTarget(array: number[], target: numb...
    method findLastElementLessThanTarget (line 92) | static findLastElementLessThanTarget(array: number[], target: number):...

FILE: typescript/17_skiplist/SkipList.ts
  class SkipList (line 18) | class SkipList<T> {
    method constructor (line 32) | constructor() {
    method insert (line 37) | public insert(key: number, value: T): void {
    method get (line 93) | public get(key: number): T | null {
    method remove (line 98) | public remove(key: number) {
    method addEmptyLevel (line 109) | private addEmptyLevel() {
    method findNode (line 129) | private findNode(key: number): SkipListNode<T> {
  class SkipListNode (line 149) | class SkipListNode<T> {
    method constructor (line 157) | constructor(key: number, value: T | null) {

FILE: typescript/24_treesearch/TreeSearch.ts
  class TreeSearch (line 4) | class TreeSearch {
    method find (line 7) | public find(data: number) {
    method insert (line 21) | public insert(data: number) {
    method delete (line 52) | public delete(data: number) {
    method printAllData (line 97) | public printAllData(): void {
    method printAll (line 101) | private printAll(node?: Node): void {
  class Node (line 109) | class Node {
    method constructor (line 114) | constructor(data: number) {
Condensed preview — 622 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,160K chars).
[
  {
    "path": ".gitignore",
    "chars": 536,
    "preview": "# Compiled class file\n*.class\n\n# Log file\n*.log\n\n# BlueJ files\n*.ctxt\n\n# Mobile Tools for Java (J2ME)\n.mtj.tmp/\n\n# Packa"
  },
  {
    "path": "DynamicStackBaseArray.java",
    "chars": 2675,
    "preview": "package Stack;\n\nimport java.util.Iterator;\n\n/**\n * 顺序栈的动态扩容\n * Author: PeiJiaNi\n * @param <T>  顺序栈元素类型\n */\n\npublic class"
  },
  {
    "path": "LICENSE",
    "chars": 11357,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "README.md",
    "chars": 1182,
    "preview": "# 数据结构和算法必知必会的50个代码实现\n### 微信搜索我的公众号“小争哥”,或者微信扫描下面二维码关注\n### 关注微信公众号,回复”PDF“获取独家算法资料。\n### 前Google工程师,10万人跟着学的《数据结构和算法之美》《设"
  },
  {
    "path": "StackBaseArray.java",
    "chars": 1397,
    "preview": "package Stack;\n\n/**\n * 顺序栈(基于数组实现)\n * Author: PeiJiaNi\n */\npublic class StackBaseArray {\n    private int[] items;    // "
  },
  {
    "path": "c-cpp/.gitignore",
    "chars": 69,
    "preview": "# main files\nmain.*\n\n# executives\na.out\n\n# objective files\n*.o\n*.obj\n"
  },
  {
    "path": "c-cpp/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "c-cpp/05_array/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "c-cpp/05_array/Array_gp.c",
    "chars": 4863,
    "preview": "#include \"Array.h\"\n\n#include <string.h>\n#include <stdbool.h>\n\nArray* arrayCreate()\n{\n    struct Array *array = NULL;\n   "
  },
  {
    "path": "c-cpp/05_array/Array_gp.h",
    "chars": 1161,
    "preview": "#ifndef __ARRAY_H__\n#define __ARRAY_H__\n\n#include <stdio.h>\n#include <stdlib.h>\n\ntypedef struct Array\n{\n    // pָĿռС\n   "
  },
  {
    "path": "c-cpp/05_array/array.c",
    "chars": 1651,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\nstruct array {\n\tint size;\n\tint used;\n\tint *arr;\n};\n\nvoid dum"
  },
  {
    "path": "c-cpp/06_linkedlist/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "c-cpp/06_linkedlist/Dlist/Dlist.c",
    "chars": 3926,
    "preview": "/*************************************************************************\n > File Name: Dlist.c\n > Author:  jinshaohui\n"
  },
  {
    "path": "c-cpp/06_linkedlist/Dlist/Dlist.h",
    "chars": 618,
    "preview": "/*************************************************************************\n > File Name: Dlist.c\n > Author:  jinshaohui\n"
  },
  {
    "path": "c-cpp/06_linkedlist/LRUBasedLinkedList.cpp",
    "chars": 4673,
    "preview": "typedef int DataType;\n\n//定义\nclass SNode\n{\npublic:\n    DataType data;\n    SNode * next;\n};\n\nclass SList \n{\npublic:\n    SL"
  },
  {
    "path": "c-cpp/06_linkedlist/list_isPalindrome/LinkList.cpp",
    "chars": 2042,
    "preview": "#include \"LinkList.h\"\n\nvoid CreateListHead(LinkList *&L,ElemType a[],int n)\n{\n\tint i;\n\tLinkList *s;\n\tL = (LinkList *)mal"
  },
  {
    "path": "c-cpp/06_linkedlist/list_isPalindrome/LinkList.h",
    "chars": 620,
    "preview": "#ifndef LINKLIST_H\n#define LINKLIST_H\n\n#include <stdlib.h>\n#include <stdio.h>\ntypedef char ElemType;\ntypedef struct LNod"
  },
  {
    "path": "c-cpp/06_linkedlist/palindromeList/LinkedList.hpp",
    "chars": 2722,
    "preview": "/**\n * Author:  TripleZ<me@triplez.cn>\n * Date:    2018-10-10\n * Brief:   Linked list class.\n */\n\n#ifndef _LINKEDLIST_HP"
  },
  {
    "path": "c-cpp/06_linkedlist/palindromeList/ListNode.hpp",
    "chars": 211,
    "preview": "/**\n * Author:  TripleZ<me@triplez.cn>\n * Date:    2018-10-10\n * Brief:   ListNode class.\n */\n\n#ifndef _LISTNODE_HPP_\n#d"
  },
  {
    "path": "c-cpp/06_linkedlist/palindromeList/palindromeList.cpp",
    "chars": 2210,
    "preview": "/**\n * Author:  TripleZ<me@triplez.cn>\n * Date:    2018-10-10\n * Brief:   Check a list whether is palindrome.\n */\n\n#incl"
  },
  {
    "path": "c-cpp/06_linkedlist/single_list.c",
    "chars": 3101,
    "preview": "#include <stdio.h>\n#include <stdbool.h>\n\nstruct single_list {\n\tstruct single_list *next;\n\tint val;\n};\n\nstruct single_lis"
  },
  {
    "path": "c-cpp/06_linkedlist/singlelist_gc/singleList.c",
    "chars": 4494,
    "preview": "#include \"singleList.h\"\n\n#include <string.h>\n\nlinkedList * listCreate()\n{\n    linkedList *list = NULL;\n    list = malloc"
  },
  {
    "path": "c-cpp/06_linkedlist/singlelist_gc/singleList.h",
    "chars": 1200,
    "preview": "#ifndef __SINGLELIST_H__\n#define __SINGLELIST_H__\n\n#include <stdlib.h>\n#include <stdbool.h>\n\ntypedef struct listNode\n{\n "
  },
  {
    "path": "c-cpp/07_linkedlist/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "c-cpp/07_linkedlist/LinkedListAlgo.c",
    "chars": 5871,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n\n/**\n * 1) 单链表反转\n * 2) 链表中环的检测\n * 3) 两个有序的链表合并\n * 4) 删除链表倒数第 n 个结点\n * 5) 求链表的中间结点"
  },
  {
    "path": "c-cpp/07_linkedlist/SingleList.cpp",
    "chars": 12265,
    "preview": "#include <iostream>\r\n#include <string>\r\n#include <functional>\r\nusing namespace std;\r\n\r\n\r\nclass CElement;\r\n/***\r\n * @brie"
  },
  {
    "path": "c-cpp/07_linkedlist/linked_list.h",
    "chars": 374,
    "preview": "/**\n * 单链表\n *\n * Author: Liam Huang (Liam0205)\n */\n\n#ifndef LINKEDLIST_LINKED_LIST_H_\n#define LINKEDLIST_LINKED_LIST_H_\n"
  },
  {
    "path": "c-cpp/07_linkedlist/linked_list_algo.hpp",
    "chars": 3308,
    "preview": "/**\n * 0) 遍历单链表\n * 1) 单链表反转\n * 2) 链表中环的检测\n * 3) 两个有序的链表合并\n * 4) 删除链表倒数第n个结点\n * 5) 求链表的中间结点\n *\n * Author: Liam Huang (Lia"
  },
  {
    "path": "c-cpp/07_linkedlist/linklist_jinshaohui.c",
    "chars": 1914,
    "preview": "/*************************************************************************\n > File Name: lisklist.c\n > Author:  jinshaoh"
  },
  {
    "path": "c-cpp/08_stack/StackBasedOnArray/StackBasedOnArray.cpp",
    "chars": 2825,
    "preview": "/**\n * 1)顺序栈的操作:入栈和出栈;\n * 2)采用模板的方法实现存储任意类型的数据\n * 3)采用数组的栈,支持动态扩容,每次扩容1.5 倍,初始栈的大小是 10 。\n * \n * Author:caozx\n * time ;20"
  },
  {
    "path": "c-cpp/08_stack/StackBasedOnArray/StackBasedOnArray.h",
    "chars": 433,
    "preview": "\n// 类模板的声明(line 3),类模板实例化后就是模板类\n// 类模板声明的写法   template <class T> class 类名{}\ntemplate <class T> class ArrayStack\n{\npublic"
  },
  {
    "path": "c-cpp/08_stack/StackBasedOnLinkedList/StackBasedOnLinkedList.cpp",
    "chars": 3589,
    "preview": "/**\n * 1)链式栈的操作:入栈,出栈以及返回栈的大小;\n * 2)采用模板的方法实现存储任意类型的数据\n * 3)采用单链表实现栈\n * 4)pop和peek 出栈的返回值稍微有点问题,当栈为空的时候,返回null,cpp默认返回的是"
  },
  {
    "path": "c-cpp/08_stack/StackBasedOnLinkedList/StackBasedOnLinkedList.h",
    "chars": 514,
    "preview": "// 类模板的声明,关键字 class 也可以更换成 typename\ntemplate<class T> class LinkedListStack\n{\npublic:\n    LinkedListStack();\n    ~Linked"
  },
  {
    "path": "c-cpp/08_stack/arrayStack/arrayStack.c",
    "chars": 2847,
    "preview": "/*************************************************************************\n > File Name: arrayStack.c\n > Author:  jinsha"
  },
  {
    "path": "c-cpp/08_stack/arrayStack/arrayStack.h",
    "chars": 641,
    "preview": "/*************************************************************************\n > File Name: arrayStack.h\n > Author:  jinsha"
  },
  {
    "path": "c-cpp/08_stack/linkList/linklist_stack.c",
    "chars": 2079,
    "preview": "/*************************************************************************\n > File Name: linklist_stack.c\n > Author:  ji"
  },
  {
    "path": "c-cpp/08_stack/linkList/linklist_stack.h",
    "chars": 487,
    "preview": "/*************************************************************************\n > File Name: linklist_stack.h\n > Author:  ji"
  },
  {
    "path": "c-cpp/08_stack/linked_list.h",
    "chars": 342,
    "preview": "/**\n * C++ 版本单链表结点\n *\n * Author: Liam Huang (Liam0205)\n */\n\n#ifndef STACK_LINKED_LIST_H_\n#define STACK_LINKED_LIST_H_\n\n#"
  },
  {
    "path": "c-cpp/08_stack/stack_based_on_linked_list.hpp",
    "chars": 1058,
    "preview": "/**\n * 基于链表实现的栈。\n *\n * Author: Liam Huang (Liam0205)\n */\n\n#ifndef STACK_STACK_BASED_ON_LINKED_LIST_HPP_\n#define STACK_ST"
  },
  {
    "path": "c-cpp/09_queue/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "c-cpp/09_queue/array_queue/array_queue.c",
    "chars": 2852,
    "preview": "/*************************************************************************\n > File Name: array_queue.c\n > Author:  jinsh"
  },
  {
    "path": "c-cpp/09_queue/array_queue/array_queue.h",
    "chars": 624,
    "preview": "/*************************************************************************\n > File Name: array_queue.h\n > Author:  jinsh"
  },
  {
    "path": "c-cpp/09_queue/array_queue.hpp",
    "chars": 2553,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/10.\n */\n\n#ifndef QUEUE_ARRAY_QUEUE_HPP_\n#define QUEUE_ARRAY_QUEUE_HPP"
  },
  {
    "path": "c-cpp/09_queue/array_queue_test.cc",
    "chars": 1859,
    "preview": "#include <iostream>\n#include \"array_queue.hpp\"\n\nint main() {\n    auto do_traverse = [&](auto item){ std::cout << item <<"
  },
  {
    "path": "c-cpp/09_queue/block_queue.hpp",
    "chars": 2323,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/11.\n */\n\n#ifndef QUEUE_BLOCK_QUEUE_HPP_\n#define QUEUE_BLOCK_QUEUE_HPP"
  },
  {
    "path": "c-cpp/09_queue/circular_queue.hpp",
    "chars": 2735,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/10.\n */\n\n#ifndef QUEUE_CIRCULAR_QUEUE_HPP_\n#define QUEUE_CIRCULAR_QUE"
  },
  {
    "path": "c-cpp/09_queue/circular_queue_test.cc",
    "chars": 2192,
    "preview": "#include <iostream>\n#include \"circular_queue.hpp\"\n\nint main() {\n    auto do_traverse = [&](auto item){ std::cout << item"
  },
  {
    "path": "c-cpp/09_queue/concurrency_queue.hpp",
    "chars": 2361,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/11.\n */\n\n#ifndef QUEUE_CONCURRENCY_QUEUE_HPP_\n#define QUEUE_CONCURREN"
  },
  {
    "path": "c-cpp/09_queue/dynamic_array_queue.hpp",
    "chars": 2916,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/10.\n */\n\n#ifndef QUEUE_DYNAMIC_ARRAY_QUEUE_HPP_\n#define QUEUE_DYNAMIC"
  },
  {
    "path": "c-cpp/09_queue/dynamic_array_queue_test.cc",
    "chars": 2422,
    "preview": "#include <iostream>\n#include \"dynamic_array_queue.hpp\"\n\nint main() {\n    auto do_traverse = [&](auto item){ std::cout <<"
  },
  {
    "path": "c-cpp/09_queue/linked_queue.hpp",
    "chars": 1850,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/10.\n */\n\n#ifndef QUEUE_LINKED_QUEUE_HPP_\n#define QUEUE_LINKED_QUEUE_H"
  },
  {
    "path": "c-cpp/09_queue/linked_queue_test.cc",
    "chars": 1848,
    "preview": "#include <iostream>\n#include \"linked_queue.hpp\"\n\nint main() {\n    auto do_traverse = [&](auto item){ std::cout << item <"
  },
  {
    "path": "c-cpp/09_queue/list_queue/list_queue.c",
    "chars": 2822,
    "preview": "/*************************************************************************\n > File Name: list_queue.c\n > Author:  jinsha"
  },
  {
    "path": "c-cpp/09_queue/list_queue/list_queue.h",
    "chars": 567,
    "preview": "/*************************************************************************\n > File Name: list_queue.h\n > Author:  jinsha"
  },
  {
    "path": "c-cpp/09_queue/lock_free_queue.hpp",
    "chars": 2166,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/11.\n */\n\n#ifndef QUEUE_LOCK_FREE_QUEUE_HPP_\n#define QUEUE_LOCK_FREE_Q"
  },
  {
    "path": "c-cpp/09_queue/ring_queue.c",
    "chars": 2527,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdbool.h>\n\nstruct ring_queue {\n\tint cap;\n\tint head"
  },
  {
    "path": "c-cpp/10_recursive/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "c-cpp/10_recursive/one_two_step.c",
    "chars": 960,
    "preview": "/*************************************************************************\n > File Name: one_two_step.c\n > Author:  jins"
  },
  {
    "path": "c-cpp/10_recursive/one_two_step.cc",
    "chars": 2074,
    "preview": "#include <iostream>\n#include <unordered_map>\n\nclass SolutionOFOneTwoStep {\n  private:\n    static std::unordered_map<size"
  },
  {
    "path": "c-cpp/11_sorts/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "c-cpp/11_sorts/sorts.c",
    "chars": 2243,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <stdbool.h>\n\nstruct array {\n\tint size;\n\tint used;\n\tint *arr;\n};\n\nvoid du"
  },
  {
    "path": "c-cpp/11_sorts/sorts.cpp",
    "chars": 922,
    "preview": "// C program for implementation of selection sort \n#include <stdio.h> \n\nvoid swap(int *xp, int *yp) \n{ \n\tint temp = *xp;"
  },
  {
    "path": "c-cpp/11_sorts/sorts.hpp",
    "chars": 2976,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/16.\n */\n\n#ifndef SORTS_SORTS_HPP_\n#define SORTS_SORTS_HPP_\n\n#include "
  },
  {
    "path": "c-cpp/11_sorts/sorts_jinshaohui.c",
    "chars": 1837,
    "preview": "/*************************************************************************\n > File Name: sorts_jinshaohui.c\n > Author:  "
  },
  {
    "path": "c-cpp/11_sorts/sorts_test.cc",
    "chars": 1056,
    "preview": "#include <iostream>\n#include <vector>\n\n#include \"sorts.hpp\"\n\nint main() {\n    const std::vector<int> test_data{1, 2, 3, "
  },
  {
    "path": "c-cpp/12_sorts/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "c-cpp/12_sorts/merge_sort.c",
    "chars": 1212,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <stdbool.h>\n#include <string.h>\n\nvoid dump(int *arr, int size)\n{\n\tint id"
  },
  {
    "path": "c-cpp/12_sorts/merge_sort.hpp",
    "chars": 2031,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/17.\n */\n\n#ifndef SORTS_MERGE_SORT_HPP_\n#define SORTS_MERGE_SORT_HPP_\n"
  },
  {
    "path": "c-cpp/12_sorts/merge_sort_test.cc",
    "chars": 543,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/17.\n */\n\n#include <iostream>\n#include <vector>\n#include \"merge_sort.h"
  },
  {
    "path": "c-cpp/12_sorts/my12_sorts/merge_sort.c",
    "chars": 2323,
    "preview": "/*************************************************************************\n > File Name: merge_sort.c\n > Author:  jinsha"
  },
  {
    "path": "c-cpp/12_sorts/my12_sorts/quick_sort.c",
    "chars": 1985,
    "preview": "/*************************************************************************\n > File Name: quick_sort.c\n > Author:  jinsha"
  },
  {
    "path": "c-cpp/12_sorts/quick_sort.c",
    "chars": 906,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <stdbool.h>\n#include <string.h>\n\nvoid dump(int *arr, int size)\n{\n\tint id"
  },
  {
    "path": "c-cpp/12_sorts/quick_sort.hpp",
    "chars": 2611,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/17.\n */\n\n#ifndef SORTS_QUICK_SORT_HPP_\n#define SORTS_QUICK_SORT_HPP_\n"
  },
  {
    "path": "c-cpp/12_sorts/quick_sort_test.cc",
    "chars": 599,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/17.\n */\n\n#include <iostream>\n#include <vector>\n#include <algorithm>\n\n"
  },
  {
    "path": "c-cpp/13_sorts/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "c-cpp/13_sorts/bucket_sort.hpp",
    "chars": 1116,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/26.\n */\n\n#ifndef SORTS_BUCKET_SORT_HPP_\n#define SORTS_BUCKET_SORT_HPP"
  },
  {
    "path": "c-cpp/13_sorts/bucket_sort_test.cc",
    "chars": 1015,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/26.\n */\n\n#include <iostream>\n#include <vector>\n#include <functional>\n"
  },
  {
    "path": "c-cpp/13_sorts/counting_sort.hpp",
    "chars": 1100,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/26.\n */\n\n#ifndef SORTS_COUNTING_SORT_HPP_\n#define SORTS_COUNTING_SORT"
  },
  {
    "path": "c-cpp/13_sorts/counting_sort_test.cc",
    "chars": 1264,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/26.\n */\n\n#include <iostream>\n#include <vector>\n#include <functional>\n"
  },
  {
    "path": "c-cpp/13_sorts/sort.c",
    "chars": 4668,
    "preview": "/*************************************************************************\n > File Name: sort.c\n > Author:  jinshaohui\n "
  },
  {
    "path": "c-cpp/14_sorts/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "c-cpp/14_sorts/analytics_of_std_sort.md",
    "chars": 314,
    "preview": "# C++ STL 中的 std::sort 分析\n\n参见 [Liam Huang 的博客](https://liam.page/)中的 3 篇文章:\n\n* [谈谈基于比较的排序算法的复杂度下界](https://liam.page/201"
  },
  {
    "path": "c-cpp/14_sorts/counting_sort.c",
    "chars": 1167,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <stdbool.h>\n#include <string.h>\n\nvoid dump(int *arr, int size)\n{\n\tint i;"
  },
  {
    "path": "c-cpp/15_bsearch/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "c-cpp/15_bsearch/binary_search.c",
    "chars": 1706,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <stdbool.h>\n#include <string.h>\n\ntypedef int(*bs)(int *arr, int size, in"
  },
  {
    "path": "c-cpp/15_bsearch/bsearch.hpp",
    "chars": 1081,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/24.\n */\n\n#ifndef BSEARCH_BSEARCH_HPP_\n#define BSEARCH_BSEARCH_HPP_\n\n#"
  },
  {
    "path": "c-cpp/15_bsearch/bsearch_c/bsearch.c",
    "chars": 1514,
    "preview": "/*************************************************************************\n > File Name: bsearch.c\n > Author:  jinshaohu"
  },
  {
    "path": "c-cpp/15_bsearch/bsearch_c/sqrt.c",
    "chars": 835,
    "preview": "/*************************************************************************\n > File Name: sqrt.c\n > Author:  jinshaohui\n "
  },
  {
    "path": "c-cpp/15_bsearch/bsearch_test.cc",
    "chars": 834,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/24.\n */\n\n#include <iostream>\n#include <vector>\n\n#include \"bsearch.hpp"
  },
  {
    "path": "c-cpp/16_bsearch/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "c-cpp/16_bsearch/bsearch.c",
    "chars": 3133,
    "preview": "/*************************************************************************\n > File Name: bsearch.c\n > Author:  jinshaohu"
  },
  {
    "path": "c-cpp/16_bsearch/bsearch_variant.c",
    "chars": 5308,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <stdbool.h>\n#include <string.h>\n\n\nint binary_search(int *arr, int size, "
  },
  {
    "path": "c-cpp/16_bsearch/bsearch_varients.hpp",
    "chars": 3057,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/26.\n */\n\n#ifndef BSEARCH_BSEARCH_VARIENTS_HPP_\n#define BSEARCH_BSEARC"
  },
  {
    "path": "c-cpp/16_bsearch/bsearch_varients_test.cc",
    "chars": 1744,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/26.\n */\n\n#include <iostream>\n#include <vector>\n\n#include \"bsearch_var"
  },
  {
    "path": "c-cpp/17_skiplist/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "c-cpp/17_skiplist/SkipList.cpp",
    "chars": 7188,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <iostream>\n#include <string>\n#include <cstring>\n#include <random>\n#inclu"
  },
  {
    "path": "c-cpp/17_skiplist/skiplist.c",
    "chars": 3911,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <stdbool.h>\n#include <string.h>\n#include <time.h>\n\n// https://www.youtub"
  },
  {
    "path": "c-cpp/17_skiplist/skiplist.hpp",
    "chars": 6385,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/29.\n */\n\n#ifndef SKIPLIST_SKIPLIST_HPP_\n#define SKIPLIST_SKIPLIST_HPP"
  },
  {
    "path": "c-cpp/17_skiplist/skiplist_c/skiplist.c",
    "chars": 5856,
    "preview": "/*************************************************************************\n > File Name: skiplist.c\n > Author:  jinshaoh"
  },
  {
    "path": "c-cpp/17_skiplist/skiplist_c/skiplist.h",
    "chars": 785,
    "preview": "/*************************************************************************\n > File Name: skiplist.h\n > Author:  jinshaoh"
  },
  {
    "path": "c-cpp/17_skiplist/skiplist_test.cc",
    "chars": 1343,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/30.\n */\n\n#include <iostream>\n#include <string>\n\n#include \"skiplist.hp"
  },
  {
    "path": "c-cpp/17_skiplist/skiplist_tr.hpp",
    "chars": 12416,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/30.\n */\n\n#ifndef SKIPLIST_SKIPLIST_TR_HPP_\n#define SKIPLIST_SKIPLIST_"
  },
  {
    "path": "c-cpp/17_skiplist/skiplist_tr_test.cc",
    "chars": 3153,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/10/30.\n */\n#include <assert.h>\n\n#include <iostream>\n#include <map>\n#incl"
  },
  {
    "path": "c-cpp/18_hashtable/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "c-cpp/18_hashtable/hash_map.cc",
    "chars": 3025,
    "preview": "/**\n * Created by Liam Huang (Liam0205) on 2018/08/14.\n * This is an old test file for hash_map, created by Liam.\n * Jus"
  },
  {
    "path": "c-cpp/18_hashtable/hashtable.c",
    "chars": 3448,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <stdbool.h>\n#include <string.h>\n#include <time.h>\n\n/* One implementation"
  },
  {
    "path": "c-cpp/18_hashtable/listhash/listhash.c",
    "chars": 6324,
    "preview": "/*************************************************************************\n > File Name: listhash.c\n > Author:  jinshaoh"
  },
  {
    "path": "c-cpp/18_hashtable/listhash/listhash.h",
    "chars": 1736,
    "preview": "/*************************************************************************\n > File Name: listhash.h\n > Author:  jinshaoh"
  },
  {
    "path": "c-cpp/19_Dlisthash/Dlist.h",
    "chars": 2912,
    "preview": "/*************************************************************************\n > File Name: Dlist.h\n > Author:  jinshaohui\n"
  },
  {
    "path": "c-cpp/19_Dlisthash/LinkedHashMap.c",
    "chars": 7119,
    "preview": "/*************************************************************************\n > File Name: LinkedHashMap.c\n > Author:  jin"
  },
  {
    "path": "c-cpp/19_Dlisthash/LinkedHashMap.h",
    "chars": 1328,
    "preview": "/*************************************************************************\n > File Name: LinkedHashMap.h\n > Author:  jin"
  },
  {
    "path": "c-cpp/23_binarytree/binarytree.c",
    "chars": 1254,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <stdbool.h>\n#include <string.h>\n#include <time.h>\n\n/* Implement binary t"
  },
  {
    "path": "c-cpp/23_binarytree/tree/binarytree.c",
    "chars": 3588,
    "preview": "/*************************************************************************\n > File Name: binarytree.c\n > Author:  jinsha"
  },
  {
    "path": "c-cpp/23_binarytree/tree/list_queue.c",
    "chars": 1358,
    "preview": "/*************************************************************************\n > File Name: list_queue.c\n > Author:  jinsha"
  },
  {
    "path": "c-cpp/23_binarytree/tree/list_queue.h",
    "chars": 711,
    "preview": "/*************************************************************************\n > File Name: list_queue.h\n > Author:  jinsha"
  },
  {
    "path": "c-cpp/24_binarysearchtree/binary_search_tree.cpp",
    "chars": 7426,
    "preview": "/*\r\n * Filename: /home/zwk/code/data_structrue/c++/tree/binary_search_tree/main.cpp\r\n * Path: /home/zwk/code/data_struct"
  },
  {
    "path": "c-cpp/24_binarysearchtree/binarysearchtree.c",
    "chars": 5313,
    "preview": "/*************************************************************************\n > File Name: binarysearchtree.c\n > Author:  "
  },
  {
    "path": "c-cpp/24_binarysearchtree/binarysearchtree.h",
    "chars": 837,
    "preview": "/*************************************************************************\n > File Name: binarysearchtree.h\n > Author:  "
  },
  {
    "path": "c-cpp/24_binarysearchtree/bst.c",
    "chars": 2967,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <stdbool.h>\n#include <string.h>\n#include <time.h>\n\nenum child_dir {\n\tlef"
  },
  {
    "path": "c-cpp/24_tree/Trie.c",
    "chars": 1694,
    "preview": "/*************************************************************************\r\n > Author:  Liu Zhang\r\n > Mail:    lz-850610"
  },
  {
    "path": "c-cpp/24_tree/binarysearchtree.c",
    "chars": 4270,
    "preview": "/*************************************************************************\n > Author:  Liu Zhang\n > Mail:    lz-850610@1"
  },
  {
    "path": "c-cpp/28_heap/heap.c",
    "chars": 2539,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <stdbool.h>\n#include <string.h>\n#include <time.h>\n\n/* Implement heap */\n"
  },
  {
    "path": "c-cpp/30_Graph/graph.c",
    "chars": 2482,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <stdbool.h>\n#include <string.h>\n#include <time.h>\n\nstruct vertex;\nstruct"
  },
  {
    "path": "c-cpp/bst.c",
    "chars": 2967,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <stdbool.h>\n#include <string.h>\n#include <time.h>\n\nenum child_dir {\n\tlef"
  },
  {
    "path": "csharp/05-array/Array.cs",
    "chars": 3003,
    "preview": "using System;\n\nnamespace algo05_array\n{\n    public sealed class Array<T> where T : IComparable<T>\n    {\n        private "
  },
  {
    "path": "csharp/05-array/algo05_array.csproj",
    "chars": 173,
    "preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n  <PropertyGroup>\n    <TargetFramework>netcoreapp2.2</TargetFramework>\n    <IsPackab"
  },
  {
    "path": "csharp/06-linkedlist/LRUWithArray.cs",
    "chars": 962,
    "preview": "using algo05_array;\n\nnamespace algo06_linked_list\n{\n    /// <summary>\n    /// 使用数组实现LRU缓存淘汰算法\n    /// </summary>\n    pub"
  },
  {
    "path": "csharp/06-linkedlist/LRUWithLinkedList.cs",
    "chars": 1171,
    "preview": "namespace algo06_linked_list\n{\n    /// <summary>\n    /// 使用单链表实现LRU缓存淘汰算法\n    /// </summary>\n    public class LRUWithLin"
  },
  {
    "path": "csharp/06-linkedlist/LRU缓存实现思路.txt",
    "chars": 160,
    "preview": "实现LRU缓存淘汰算法思路:\n\n维护一个有序单链表,越靠近链尾的数据是最早访问的。\n当有一个新的数据被访问时,\n1. 如果数据在缓存中,则将其从原位置删除,然后插入到表头;\n2. 如果数据不在缓存中,有两种情况:\n    1) 链表未满,则"
  },
  {
    "path": "csharp/06-linkedlist/SingleLinkedList.cs",
    "chars": 3424,
    "preview": "using System;\n\nnamespace algo06_linked_list\n{\n    /// <summary>\n    /// 单链表的插入、删除、清空、查找\n    /// </summary>\n    /// <type"
  },
  {
    "path": "csharp/06-linkedlist/algo06_linked_list.csproj",
    "chars": 271,
    "preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n  <PropertyGroup>\n    <TargetFramework>netcoreapp2.2</TargetFramework>\n\n    <IsPacka"
  },
  {
    "path": "csharp/07-linkedlist/_07_linkedlist/SingleLinkedListAlgo.cs",
    "chars": 4216,
    "preview": "using System;\nusing algo06_linked_list;\n\nnamespace algo07_linkedlist\n{\n    /// <summary>\n    /// 单链表常用算法操作\n    /// 1. 链"
  },
  {
    "path": "csharp/07-linkedlist/_07_linkedlist/algo07_linkedlist.csproj",
    "chars": 263,
    "preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n    <PropertyGroup>\n        <TargetFramework>netcoreapp2.2</TargetFramework>\n    </P"
  },
  {
    "path": "csharp/08-stack/algo08_stack/ArrayStack.cs",
    "chars": 785,
    "preview": "using System;\n\nnamespace algo08_stack\n{\n    public class ArrayStack<T>\n    {\n        private readonly int _capacity;\n\n "
  },
  {
    "path": "csharp/08-stack/algo08_stack/LinkedStack.cs",
    "chars": 957,
    "preview": "using System;\n\nnamespace algo08_stack\n{\n    public class LinkedStack<T>\n    {\n        private StackListNode<T> _top;\n\n "
  },
  {
    "path": "csharp/08-stack/algo08_stack/LinkedStackBrowser.cs",
    "chars": 878,
    "preview": "namespace algo08_stack\n{\n    /// <summary>\n    /// 利用链栈实现浏览器怎么进后退\n    /// </summary>\n    public class LinkedStackBrowser"
  },
  {
    "path": "csharp/08-stack/algo08_stack/algo08_stack.csproj",
    "chars": 146,
    "preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n    <PropertyGroup>\n        <TargetFramework>netcoreapp2.2</TargetFramework>\n    </P"
  },
  {
    "path": "csharp/Tests/_05_array_tests/Array.Tests.cs",
    "chars": 6425,
    "preview": "using System;\nusing algo05_array;\nusing Xunit;\nusing Xunit.Abstractions;\n\nnamespace _05_array_tests\n{\n    public class A"
  },
  {
    "path": "csharp/Tests/_05_array_tests/algo05_array_tests.csproj",
    "chars": 562,
    "preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n  <PropertyGroup>\n    <TargetFramework>netcoreapp2.2</TargetFramework>\n\n    <IsPacka"
  },
  {
    "path": "csharp/Tests/_06_linkedlist_tests/BaseLinkedListTests.cs",
    "chars": 450,
    "preview": "using System;\nusing algo06_linked_list;\n\nnamespace algo06_linkedlist_tests\n{\n    public class BaseLinkedListTests\n    {\n"
  },
  {
    "path": "csharp/Tests/_06_linkedlist_tests/LRUWithArray.Tests.cs",
    "chars": 1691,
    "preview": "using algo05_array;\nusing algo06_linked_list;\nusing Xunit;\nusing Xunit.Abstractions;\n\nnamespace algo06_linkedlist_tests\n"
  },
  {
    "path": "csharp/Tests/_06_linkedlist_tests/LRUWithLinkedList.Tests.cs",
    "chars": 1333,
    "preview": "using Xunit;\nusing Xunit.Abstractions;\nusing algo06_linked_list;\n\nnamespace algo06_linkedlist_tests\n{\n    public class L"
  },
  {
    "path": "csharp/Tests/_06_linkedlist_tests/SingleLinkedList.Tests.cs",
    "chars": 4707,
    "preview": "using System;\nusing Xunit;\nusing Xunit.Abstractions;\nusing algo06_linked_list;\n\nnamespace algo06_linkedlist_tests\n{\n    "
  },
  {
    "path": "csharp/Tests/_06_linkedlist_tests/algo06_linkedlist_tests.csproj",
    "chars": 594,
    "preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n  <PropertyGroup>\n    <TargetFramework>netcoreapp2.2</TargetFramework>\n\n    <IsPacka"
  },
  {
    "path": "csharp/Tests/_07_linkedlist_tests/SingleLinkedListAlgo.Tests.cs",
    "chars": 3817,
    "preview": "using System;\nusing Xunit;\nusing algo06_linkedlist_tests;\nusing algo06_linked_list;\nusing algo07_linkedlist;\n\nnamespace "
  },
  {
    "path": "csharp/Tests/_07_linkedlist_tests/algo07_linkedlist_tests.csproj",
    "chars": 747,
    "preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n    <PropertyGroup>\n        <TargetFramework>netcoreapp2.2</TargetFramework>\n\n      "
  },
  {
    "path": "csharp/Tests/algo08_stack_tests/ArrayStack.Tests.cs",
    "chars": 2012,
    "preview": "using System;\nusing algo08_stack;\nusing Xunit;\nusing Xunit.Abstractions;\n\nnamespace algo08_stack_tests\n{\n    public clas"
  },
  {
    "path": "csharp/Tests/algo08_stack_tests/LinkedStack.Tests.cs",
    "chars": 1561,
    "preview": "using System;\nusing algo08_stack;\nusing Xunit;\nusing Xunit.Abstractions;\n\nnamespace algo08_stack_tests\n{\n    public clas"
  },
  {
    "path": "csharp/Tests/algo08_stack_tests/LinkedStackBrowser.Tests.cs",
    "chars": 2917,
    "preview": "using algo08_stack;\nusing Xunit;\nusing Xunit.Abstractions;\n\nnamespace algo08_stack_tests\n{\n    public class LinkedStackB"
  },
  {
    "path": "csharp/Tests/algo08_stack_tests/algo08_stack_tests.csproj",
    "chars": 560,
    "preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n    <PropertyGroup>\n        <TargetFramework>netcoreapp2.2</TargetFramework>\n\n      "
  },
  {
    "path": "csharp/csharp.sln",
    "chars": 10137,
    "preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio 15\nVisualStudioVersion = 15.0.26124.0\nMini"
  },
  {
    "path": "csharp/csharp.sln.DotSettings.user",
    "chars": 1867,
    "preview": "<wpf:ResourceDictionary xml:space=\"preserve\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" xmlns:s=\"clr-namesp"
  },
  {
    "path": "f21",
    "chars": 1357,
    "preview": "// A Stack based C++ program to find next \n// greater element for all array elements \n// in same order as input. \n#inclu"
  },
  {
    "path": "go/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "go/05_array/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "go/05_array/array.go",
    "chars": 1634,
    "preview": "package _5_array\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n)\n\n/**\n * 1) 数组的插入、删除、按照下标随机访问操作;\n * 2)数组中的数据是int类型的;\n *\n * Author: leo\n */\n"
  },
  {
    "path": "go/05_array/array_test.go",
    "chars": 933,
    "preview": "package _5_array\n\nimport (\n\t\"testing\"\n)\n\nfunc TestInsert(t *testing.T) {\n\tcapacity := 10\n\tarr := NewArray(uint(capacity)"
  },
  {
    "path": "go/06_linkedlist/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "go/06_linkedlist/palindrome-linked-list.go",
    "chars": 799,
    "preview": "/**\n * Definition for singly-linked list.\n * type ListNode struct {\n *     Val int\n *     Next *ListNode\n * }\n */\nfunc i"
  },
  {
    "path": "go/06_linkedlist/palindrome.go",
    "chars": 1440,
    "preview": "package _6_linkedlist\n\n/*\n思路1:开一个栈存放链表前半段\n时间复杂度:O(N)\n空间复杂度:O(N)\n*/\nfunc isPalindrome1(l *LinkedList) bool {\n\tlLen := l.l"
  },
  {
    "path": "go/06_linkedlist/palindrome_test.go",
    "chars": 548,
    "preview": "package _6_linkedlist\n\nimport \"testing\"\n\nfunc TestPalindrome1(t *testing.T) {\n\tstrs := []string{\"heooeh\", \"hello\", \"heoe"
  },
  {
    "path": "go/06_linkedlist/singlelinkedlist.go",
    "chars": 2126,
    "preview": "package _6_linkedlist\n\nimport \"fmt\"\n\n/*\n单链表基本操作\nauthor:leo\n*/\n\ntype ListNode struct {\n\tnext  *ListNode\n\tvalue interface{"
  },
  {
    "path": "go/06_linkedlist/singlelinkedlist_test.go",
    "chars": 735,
    "preview": "package _6_linkedlist\n\nimport \"testing\"\n\nfunc TestInsertToHead(t *testing.T) {\n\tl := NewLinkedList()\n\tfor i := 0; i < 10"
  },
  {
    "path": "go/07_linkedlist/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "go/07_linkedlist/main.go",
    "chars": 2261,
    "preview": "package _7_linkedlist\n\nimport \"fmt\"\n\n//单链表节点\ntype ListNode struct {\n\tnext  *ListNode\n\tvalue interface{}\n}\n\n//单链表\ntype Li"
  },
  {
    "path": "go/07_linkedlist/main_test.go",
    "chars": 1276,
    "preview": "package _7_linkedlist\n\nimport \"testing\"\n\nvar l *LinkedList\n\nfunc init() {\n\tn5 := &ListNode{value: 5}\n\tn4 := &ListNode{va"
  },
  {
    "path": "go/08_stack/SimpleBrowser.go",
    "chars": 964,
    "preview": "package _8_stack\n\nimport \"fmt\"\n\ntype Browser struct {\n\tforwardStack Stack\n\tbackStack    Stack\n}\n\nfunc NewBrowser() *Brow"
  },
  {
    "path": "go/08_stack/SimpleBrowser_test.go",
    "chars": 403,
    "preview": "package _8_stack\n\nimport \"testing\"\n\nfunc TestBrowser(t *testing.T) {\n\tb := NewBrowser()\n\tb.PushBack(\"www.qq.com\")\n\tb.Pus"
  },
  {
    "path": "go/08_stack/StackBasedOnArray.go",
    "chars": 1011,
    "preview": "package _8_stack\n\nimport \"fmt\"\n\n/*\n基于数组实现的栈\n*/\n\ntype ArrayStack struct {\n\t//数据\n\tdata []interface{}\n\t//栈顶指针\n\ttop int\n}\n\nf"
  },
  {
    "path": "go/08_stack/StackBasedOnArray_test.go",
    "chars": 604,
    "preview": "package _8_stack\n\nimport \"testing\"\n\nfunc TestArrayStack_Push(t *testing.T) {\n\ts := NewArrayStack()\n\ts.Push(1)\n\ts.Push(2)"
  },
  {
    "path": "go/08_stack/StackBasedOnLinkedList.go",
    "chars": 937,
    "preview": "package _8_stack\n\nimport \"fmt\"\n\n/*\n基于链表实现的栈\n*/\ntype node struct {\n\tnext *node\n\tval  interface{}\n}\n\ntype LinkedListStack "
  },
  {
    "path": "go/08_stack/StackBasedOnLinkedList_test.go",
    "chars": 559,
    "preview": "package _8_stack\n\nimport \"testing\"\n\nfunc TestLinkedListStack_Push(t *testing.T) {\n\ts := NewLinkedListStack()\n\ts.Push(1)\n"
  },
  {
    "path": "go/08_stack/StatckInterface.go",
    "chars": 127,
    "preview": "package _8_stack\n\ntype Stack interface {\n\tPush(v interface{})\n\tPop() interface{}\n\tIsEmpty() bool\n\tTop() interface{}\n\tFlu"
  },
  {
    "path": "go/09_queue/CircularQueue.go",
    "chars": 1200,
    "preview": "package _9_queue\n\nimport \"fmt\"\n\ntype CircularQueue struct {\n\tq        []interface{}\n\tcapacity int\n\thead     int\n\ttail   "
  },
  {
    "path": "go/09_queue/CircularQueue_test.go",
    "chars": 521,
    "preview": "package _9_queue\n\nimport \"testing\"\n\nfunc TestCircularQueue_EnQueue(t *testing.T) {\n\tq := NewCircularQueue(5)\n\tq.EnQueue("
  },
  {
    "path": "go/09_queue/QueueBasedOnArray.go",
    "chars": 766,
    "preview": "package _9_queue\n\nimport \"fmt\"\n\ntype ArrayQueue struct {\n\tq        []interface{}\n\tcapacity int\n\thead     int\n\ttail     i"
  },
  {
    "path": "go/09_queue/QueueBasedOnArray_test.go",
    "chars": 478,
    "preview": "package _9_queue\n\nimport \"testing\"\n\nfunc TestArrayQueue_EnQueue(t *testing.T) {\n\tq := NewArrayQueue(5)\n\tq.EnQueue(1)\n\tq."
  },
  {
    "path": "go/09_queue/QueueBasedOnLinkedList.go",
    "chars": 893,
    "preview": "package _9_queue\n\nimport \"fmt\"\n\ntype ListNode struct {\n\tval  interface{}\n\tnext *ListNode\n}\n\ntype LinkedListQueue struct "
  },
  {
    "path": "go/09_queue/QueueBasedOnLinkedList_test.go",
    "chars": 484,
    "preview": "package _9_queue\n\nimport \"testing\"\n\nfunc TestListQueue_EnQueue(t *testing.T) {\n\tq := NewLinkedListQueue()\n\tq.EnQueue(1)\n"
  },
  {
    "path": "go/10_recursion/Factorial.go",
    "chars": 402,
    "preview": "package Recursion\n\n// 迭代实现阶乘\ntype Fac struct {\n\tval map[int]int\n}\n\nfunc  NewFactorial(n int) *Fac {\n\treturn &Fac{\n\t\tmake"
  },
  {
    "path": "go/10_recursion/Factorial_test.go",
    "chars": 162,
    "preview": "package Recursion\n\nimport \"testing\"\n\nfunc TestFac_Factorial(t *testing.T) {\n\tfac := NewFactorial(10)\n\tfor i:=1; i<15; i+"
  },
  {
    "path": "go/10_recursion/Fibonacci.go",
    "chars": 497,
    "preview": "package Recursion\n\nimport \"fmt\"\n\n// 递归实现斐波那契数列\ntype Fibs struct {\n\tval map[int]int  // 使用字典存储结果\n}\n\nfunc NewFibs(n int) *"
  },
  {
    "path": "go/10_recursion/Fibonacci_test.go",
    "chars": 157,
    "preview": "package Recursion\n\nimport \"testing\"\n\nfunc TestFibs_Fibonacci(t *testing.T) {\n\tfib := NewFibs(10)\n\tfor i:=1; i<15; i++{\n\t"
  },
  {
    "path": "go/10_recursion/RangAll.go",
    "chars": 730,
    "preview": "package Recursion\n\nimport (\n\t\"fmt\"\n)\n// 实现一组数据集合的全排列\ntype RangeType struct {\n\tvalue []interface{}\n}\n\nfunc NewRangeArray("
  },
  {
    "path": "go/10_recursion/RangAll_test.go",
    "chars": 288,
    "preview": "package Recursion\n\nimport \"testing\"\n\nfunc TestRangeALL(t *testing.T) {\n\tslice1 := NewRangeArray(4)\n\tfor i:=0; i<4; i++{\n"
  },
  {
    "path": "go/11_sorts/Sort.go",
    "chars": 897,
    "preview": "package _1_sorts\n\n/*\n冒泡排序、插入排序、选择排序\n */\n\n//冒泡排序,a是数组,n表示数组大小\nfunc BubbleSort(a []int, n int) {\n\tif n <= 1 {\n\t\treturn\n\t}\n"
  },
  {
    "path": "go/11_sorts/Sort_test.go",
    "chars": 500,
    "preview": "package _1_sorts\n\nimport (\n\t\"fmt\"\n\t\"testing\"\n)\n\nfunc TestBubbleSort(t *testing.T) {\n\tarr := []int{1,5,9,6,3,7,5,10}\n\tfmt"
  },
  {
    "path": "go/12_sorts/MergeSort.go",
    "chars": 711,
    "preview": "package _2_sorts\n\nfunc MergeSort(arr []int) {\n\tarrLen := len(arr)\n\tif arrLen <= 1 {\n\t\treturn\n\t}\n\n\tmergeSort(arr, 0, arrL"
  },
  {
    "path": "go/12_sorts/MergeSort_test.go",
    "chars": 178,
    "preview": "package _2_sorts\n\nimport \"testing\"\n\nfunc TestMergeSort(t *testing.T) {\n\tarr := []int{5, 4}\n\tMergeSort(arr)\n\tt.Log(arr)\n\n"
  },
  {
    "path": "go/12_sorts/QuickSort.go",
    "chars": 591,
    "preview": "package _2_sorts\n\n// QuickSort is quicksort methods for golang\nfunc QuickSort(arr []int) {\n\tseparateSort(arr, 0, len(arr"
  },
  {
    "path": "go/12_sorts/QuickSort_test.go",
    "chars": 348,
    "preview": "package _2_sorts\n\nimport (\n\t\"math/rand\"\n\t\"testing\"\n)\n\nfunc createRandomArr(length int) []int {\n\tarr := make([]int, lengt"
  },
  {
    "path": "go/13_sorts/BucketSort.go",
    "chars": 1018,
    "preview": "package LinearSort\n\nimport (\n\t\"algorithm/Sort\"\n\t\"fmt\"\n)\n\n// 桶排序\n\n// 获取待排序数组中的最大值\nfunc getMax(a []int)int{\n\tmax := a[0]\n\t"
  },
  {
    "path": "go/13_sorts/BucketSort_test.go",
    "chars": 231,
    "preview": "package LinearSort\n\nimport \"testing\"\n\nfunc TestBucketSort(t *testing.T) {\n\ta := []int{1,6,3,5,8,6,4}\n\tBucketSort(a)\n\tt.L"
  },
  {
    "path": "go/14_sorts/CountingSort.go",
    "chars": 417,
    "preview": "package _4_sorts\n\nimport \"math\"\n\nfunc CountingSort(a []int, n int) {\n\tif n <= 1 {\n\t\treturn\n\t}\n\n\tvar max int = math.MinIn"
  },
  {
    "path": "go/14_sorts/CountingSort_test.go",
    "chars": 207,
    "preview": "package _4_sorts\n\nimport \"testing\"\n\nfunc TestCountingSort(t *testing.T) {\n\tarr := []int{5, 4}\n\tCountingSort(arr, len(arr"
  },
  {
    "path": "go/15_binarysearch/binarysearch.go",
    "chars": 2153,
    "preview": "package _5_binarysearch\n\nfunc BinarySearch(a []int, v int) int {\n\tn := len(a)\n\tif n == 0 {\n\t\treturn -1\n\t}\n\n\tlow := 0\n\thi"
  },
  {
    "path": "go/15_binarysearch/binarysearch_test.go",
    "chars": 1981,
    "preview": "package _5_binarysearch\n\nimport \"testing\"\n\nfunc TestBinarySearch(t *testing.T) {\n\tvar a []int\n\n\ta = []int{1, 3, 5, 6, 8}"
  },
  {
    "path": "go/17_skiplist/skiplist.go",
    "chars": 2900,
    "preview": "package _7_skiplist\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"math/rand\"\n)\n\nconst (\n\t//最高层数\n\tMAX_LEVEL = 16\n)\n\n//跳表节点结构体\ntype skipListN"
  },
  {
    "path": "go/17_skiplist/skiplist_test.go",
    "chars": 956,
    "preview": "package _7_skiplist\n\nimport \"testing\"\n\nfunc TestSkipList(t *testing.T) {\n\tsl := NewSkipList()\n\n\tsl.Insert(\"leo\", 95)\n\tt."
  },
  {
    "path": "go/20_lru/lru_cache.go",
    "chars": 2398,
    "preview": "package lru_cache\n\nconst (\n\thostbit = uint64(^uint(0)) == ^uint64(0)\n\tLENGTH  = 100\n)\n\ntype lruNode struct {\n\tprev *lruN"
  }
]

// ... and 422 more files (download for full content)

About this extraction

This page contains the full source code of the wangzheng0822/algo GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 622 files (1.0 MB), approximately 341.3k tokens, and a symbol index with 2401 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!