programming_languages:basic_data_structures

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
programming_languages:basic_data_structures [2019/10/20 01:51]
phreazer ↷ Page moved from basic_data_structures to programming_languages:basic_data_structures
programming_languages:basic_data_structures [2020/02/15 18:07] (current)
phreazer
Line 1: Line 1:
 ====== Basic data structures in different languages ====== ====== Basic data structures in different languages ======
  
-Having dealt with multiple different programming languages creates some confusion how and in which place the data structures are implemented in each of the languages. This page tries to provide some overview of basic ds. +Having dealt with multiple different programming languages creates some confusion how and in which place the data structures are implemented in each of the languages. This page tries to provide some overview of basic data structures.
  
 ===== Concurrency ===== ===== Concurrency =====
Line 65: Line 64:
 size() size()
 </​code>​ </​code>​
 +
 +
  
 ==== Python 3 ==== ==== Python 3 ====
 +=== collections.deque ===
 <​code>​ <​code>​
 from collections import deque from collections import deque
Line 76: Line 78:
 append, pop, popleft append, pop, popleft
 </​code>​ </​code>​
 +
 +=== Queue ===
 +
 +  * Multiproducer,​ multiconsumer queues
 +  * Queue, SimpleQueue (no task tracking), LifoQueue, PriorityQueue
 +
 +For uncomparable types:
 +
 +<​code>​
 +from dataclasses import dataclass, field
 +from typing import Any
 +
 +@dataclass(order=True)
 +class PrioritizedItem:​
 +    priority: int
 +    item: Any=field(compare=False)
 +</​code>​
 +
 +=== multiprocessing.Queue ===
 +For multi-processing
 +
 +===== Heap =====
 +Heap structure (binary tree with ordering); Priority queue
 +
 +Use cases: ​
 +
 +==== Python ====
 +
 +Minheap implementation
 +
 +<​code>​
 +import heapq
 +
 +heapq.heappush,​ heapq.heapppop
 +heapq.heapify - Transform list to heap
 +</​code>​
 +
 +===== Bisect =====
 +Maintain list in sorted ordered on insertion.
 +
 +===== Array =====
 +array module - "​typed"​ lists
 ===== Math funcs ===== ===== Math funcs =====
  
  • programming_languages/basic_data_structures.txt
  • Last modified: 2020/02/15 18:07
  • by phreazer