This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Connection] | |
brew install pgcli | |
pgcli -h localhost -p 5432 -U postgres isolation_levels # password postgres | |
[Preparation] | |
DROP TABLE IF EXISTS accounts; | |
CREATE TABLE accounts ( | |
id SERIAL PRIMARY KEY, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
postgres: | |
image: 'postgres:14.5' | |
container_name: "postgres_isolation" | |
restart: always | |
environment: | |
- POSTGRES_DB=isolation_levels |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdexcept> | |
#include <type_traits> | |
#include <unordered_map> | |
#include <unordered_set> | |
#include <optional> | |
#include <cassert> | |
using namespace std; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type Set[T comparable] struct { | |
items map[T]struct{} | |
} | |
func NewSet[T comparable]() *Set[T] { | |
return &Set[T]{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import TypeAlias, Tuple, Hashable, TypeVar, Generic | |
FrequencyT: TypeAlias = int | |
ValueT = TypeVar("ValueT") | |
ValueFrequencyT: TypeAlias = tuple[ValueT, FrequencyT] | |
KeyT = TypeVar("KeyT", bound=Hashable) | |
KeysT: TypeAlias = set[KeyT] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <unordered_map> | |
#include <list> | |
#include <optional> | |
using namespace std; | |
template <class T> | |
concept Hashable = requires(T param) { std::hash<T>()(param); }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
type Node[KeyT comparable, ValueT any] struct { | |
key KeyT | |
value ValueT | |
prev *Node[KeyT, ValueT] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import TypeVar, Generic, Optional, Hashable, TypeAlias | |
from icecream import ic # type: ignore | |
KeyT = TypeVar("KeyT", bound=Hashable) | |
ValueT = TypeVar("ValueT") | |
class Node(Generic[KeyT, ValueT]): | |
def __init__(self, key: Optional[KeyT], value: Optional[ValueT]): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <initializer_list> | |
#include <iostream> | |
#include <memory> | |
#include <cassert> | |
template<class T> | |
struct Node { | |
using LPtr = std::weak_ptr<Node>; | |
using RPtr = std::shared_ptr<Node>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Any | |
from icecream import ic # type: ignore # pip install icecream | |
class Node: | |
def __init__(self, data: Any): | |
self.data: Any = data | |
self.prev: Node | |
self.next: Node |
NewerOlder