Python-Algorithm-pyal


NamePython-Algorithm-pyal JSON
Version 1.2.3 PyPI version JSON
download
home_pagehttps://github.com/SummerRainET2008/PYthon_Algorithms_Library
SummaryPYthon Algorithm Library (pyal) targets at providing a python version substitue of STL in C++, such as linked list, tree map, and other data structures and popular algorithms.
upload_time2024-08-30 07:49:57
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PYthon Algorithms Library (pyal)

Python does not have some useful or important data structures, like `linked list`, `tree map`, just like STL in C++. 
This library aims to provide a python counterpart of C++ STL.

# 1. Install 
 ```bash
 python3 -m pip install Python-Algorithm-pyal
 ```

# 2. Examples [github](https://github.com/SummerRainET2008/PYthon_Algorithms_Library)

Balanced search tree based map, ```TreeMap```

```python
import pyal

def main():
  tree_map = pyal.TreeMap()
  data = [(0, "a"), (1, "b"), (2, "c"), (3, "d"), (4, "e"), (5, "f")]
  for key, value in data:
    tree_map[key] = value

  key = -1
  value = tree_map.get(key)
  if value is None:
    print(f"key={key} does not exist")

  key = 0
  print(f"key={key}, value={tree_map[key]}")

  key = 1
  node = tree_map.lower_bound(key)
  print(f"lower_bound({key=}): {node.get()=}")

  node = tree_map.upper_bound(key)
  print(f"upper_bound({key=}): {node.get()=}")

  print(f"min key: {tree_map.key_list_begin().get()}")
  print(f"max key: {tree_map.key_list_end().prev().get()}")
```

Output
```
key=-1 does not exist
key=0, value=a
lower_bound(key=1): node.get()=1
upper_bound(key=1): node.get()=2
min key: 0
max key: 5
```


# 3. Popular data structures and algorithms.
  Please check [github](https://github.com/SummerRainET2008/PYthon_Algorithms_Library) for all examples.
  * ### Tree
    >* TreeMap [example](doc/example_TreeMap.md)
    >   * ___Balanced___ binary search tree.
    >   * ___insert___ & ___delete___: O(log N)
    >   * ___get___:  O(1)
    >* DynamicHeap [example](doc/example_DynamicHeap.md)
    >   * ___update___ & ___deletion___: O(log N)
    >* MinHeap, MaxHeap [example](doc/example_MinHeap.md)
    >* DisjointSet [example](doc/example_DisjointSet.md)
  * ### List
    > * LinkedList [example](doc/example_LinkedList.md)
    > * Queue [example](doc/example_Queue.md)
    > * Dequeue [example](doc/example_Deque.md)
    > * Stack [example](doc/example_Stack.md)
    > * LRUCache [example](doc/example_LRUCache.md)
    >   * ___get___ & ___set___: O(1)
    > * LFUCache [example](doc/example_LFUCache.md)
    >   * `get` & `set`: O(1) 
  * ### String
    >* search_KMP
    >* search_multipatterns
    >  * todo
  * ### Graph
    > * Graph
    > * Dijkstra
    > * topological_traversal
  * ### Common useful functions
    > * `is_none_or_empty`
    > * `histogram_ascii`
    > * `is_sorted` 
    > * `unique` 
    > * `cmp`
    > * `split_data_by_func` 
    > * `eq`
    > * `discrete_sample` 
    > * `group_by_key_fun` 
    > * `top_n`
    > * `clamp`
    > * `argmax`
    > * `argmin`
    > * `make_list`
    > * `swap`
    > * `rotate`
    > * `copy_to`
    > * `kth_smallest_element`
    > * `lower_bound`
    > * `upper_bound`
    > * `reverse_in_place`
    > * `sort_in_place`
    > * `find_first_if`
    > * `find_last_if`
    > * `next_permutation`
    > * `prev_permutation`
    > * `factorial`
    > * `combinatorial_number`
    > * `permutation_number`
    > * `combinations_with_duplicate`
    > * `longest_common_substr`
    > * `top_k_similar`

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/SummerRainET2008/PYthon_Algorithms_Library",
    "name": "Python-Algorithm-pyal",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "tianxia0209@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ae/15/6decc727d0cf8d98759069f407baf4148a72f154e7f420052aaab8332d0b/python_algorithm_pyal-1.2.3.tar.gz",
    "platform": null,
    "description": "# PYthon Algorithms Library (pyal)\n\nPython does not have some useful or important data structures, like `linked list`, `tree map`, just like STL in C++. \nThis library aims to provide a python counterpart of C++ STL.\n\n# 1. Install \n ```bash\n python3 -m pip install Python-Algorithm-pyal\n ```\n\n# 2. Examples [github](https://github.com/SummerRainET2008/PYthon_Algorithms_Library)\n\nBalanced search tree based map, ```TreeMap```\n\n```python\nimport pyal\n\ndef main():\n  tree_map = pyal.TreeMap()\n  data = [(0, \"a\"), (1, \"b\"), (2, \"c\"), (3, \"d\"), (4, \"e\"), (5, \"f\")]\n  for key, value in data:\n    tree_map[key] = value\n\n  key = -1\n  value = tree_map.get(key)\n  if value is None:\n    print(f\"key={key} does not exist\")\n\n  key = 0\n  print(f\"key={key}, value={tree_map[key]}\")\n\n  key = 1\n  node = tree_map.lower_bound(key)\n  print(f\"lower_bound({key=}): {node.get()=}\")\n\n  node = tree_map.upper_bound(key)\n  print(f\"upper_bound({key=}): {node.get()=}\")\n\n  print(f\"min key: {tree_map.key_list_begin().get()}\")\n  print(f\"max key: {tree_map.key_list_end().prev().get()}\")\n```\n\nOutput\n```\nkey=-1 does not exist\nkey=0, value=a\nlower_bound(key=1): node.get()=1\nupper_bound(key=1): node.get()=2\nmin key: 0\nmax key: 5\n```\n\n\n# 3. Popular data structures and algorithms.\n  Please check [github](https://github.com/SummerRainET2008/PYthon_Algorithms_Library) for all examples.\n  * ### Tree\n    >* TreeMap [example](doc/example_TreeMap.md)\n    >   * ___Balanced___ binary search tree.\n    >   * ___insert___ & ___delete___: O(log N)\n    >   * ___get___:  O(1)\n    >* DynamicHeap [example](doc/example_DynamicHeap.md)\n    >   * ___update___ & ___deletion___: O(log N)\n    >* MinHeap, MaxHeap [example](doc/example_MinHeap.md)\n    >* DisjointSet [example](doc/example_DisjointSet.md)\n  * ### List\n    > * LinkedList [example](doc/example_LinkedList.md)\n    > * Queue [example](doc/example_Queue.md)\n    > * Dequeue [example](doc/example_Deque.md)\n    > * Stack [example](doc/example_Stack.md)\n    > * LRUCache [example](doc/example_LRUCache.md)\n    >   * ___get___ & ___set___: O(1)\n    > * LFUCache [example](doc/example_LFUCache.md)\n    >   * `get` & `set`: O(1) \n  * ### String\n    >* search_KMP\n    >* search_multipatterns\n    >  * todo\n  * ### Graph\n    > * Graph\n    > * Dijkstra\n    > * topological_traversal\n  * ### Common useful functions\n    > * `is_none_or_empty`\n    > * `histogram_ascii`\n    > * `is_sorted` \n    > * `unique` \n    > * `cmp`\n    > * `split_data_by_func` \n    > * `eq`\n    > * `discrete_sample` \n    > * `group_by_key_fun` \n    > * `top_n`\n    > * `clamp`\n    > * `argmax`\n    > * `argmin`\n    > * `make_list`\n    > * `swap`\n    > * `rotate`\n    > * `copy_to`\n    > * `kth_smallest_element`\n    > * `lower_bound`\n    > * `upper_bound`\n    > * `reverse_in_place`\n    > * `sort_in_place`\n    > * `find_first_if`\n    > * `find_last_if`\n    > * `next_permutation`\n    > * `prev_permutation`\n    > * `factorial`\n    > * `combinatorial_number`\n    > * `permutation_number`\n    > * `combinations_with_duplicate`\n    > * `longest_common_substr`\n    > * `top_k_similar`\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "PYthon Algorithm Library (pyal) targets at providing a python version substitue of STL in C++, such as linked list, tree map, and other data structures and popular algorithms.",
    "version": "1.2.3",
    "project_urls": {
        "Homepage": "https://github.com/SummerRainET2008/PYthon_Algorithms_Library"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "380ceb224d09f4f430b321a1d25ae08ebdf4a7dcb392523e7ec2abb4325bfc7f",
                "md5": "fbc062b86a60014489614b9af1e90e59",
                "sha256": "47137c99b6e5dd329ade5e9e36807a18b43167d9dae6dd68e6e6ca47aea61fd1"
            },
            "downloads": -1,
            "filename": "Python_Algorithm_pyal-1.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fbc062b86a60014489614b9af1e90e59",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 23047,
            "upload_time": "2024-08-30T07:49:55",
            "upload_time_iso_8601": "2024-08-30T07:49:55.864999Z",
            "url": "https://files.pythonhosted.org/packages/38/0c/eb224d09f4f430b321a1d25ae08ebdf4a7dcb392523e7ec2abb4325bfc7f/Python_Algorithm_pyal-1.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ae156decc727d0cf8d98759069f407baf4148a72f154e7f420052aaab8332d0b",
                "md5": "b36257f35460010793a4d6a7a1679877",
                "sha256": "97f933f3b3ffb350513092e98de07249f8891ee246d3a83726d6d74ae02f65eb"
            },
            "downloads": -1,
            "filename": "python_algorithm_pyal-1.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "b36257f35460010793a4d6a7a1679877",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 15539,
            "upload_time": "2024-08-30T07:49:57",
            "upload_time_iso_8601": "2024-08-30T07:49:57.309973Z",
            "url": "https://files.pythonhosted.org/packages/ae/15/6decc727d0cf8d98759069f407baf4148a72f154e7f420052aaab8332d0b/python_algorithm_pyal-1.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-30 07:49:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SummerRainET2008",
    "github_project": "PYthon_Algorithms_Library",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "python-algorithm-pyal"
}
        
Elapsed time: 0.52449s