This file contains hidden or 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
| use std::{cmp::Ordering, ops::Not}; | |
| pub struct RBTree<K> | |
| where | |
| K: Ord, | |
| { | |
| root: Option<Box<Node<K>>>, | |
| } | |
| impl<K> RBTree<K> |
This file contains hidden or 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
| #!/bin/bash | |
| echo "Install packages" | |
| yay -Syu \ | |
| --needed \ | |
| --norebuild \ | |
| --noredownload \ | |
| --answerclean None \ | |
| --answerdiff None \ | |
| --answeredit None \ |
This file contains hidden or 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
| #!/usr/bin/env bash | |
| kubenv () { | |
| if [[ -z "$1" ]]; then | |
| cat <<EOF >/dev/stderr | |
| Usage: kubenv CONTEXT_NAME | |
| EOF | |
| return 1 | |
| fi |
This file contains hidden or 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" | |
| ) | |
| func prefixTable(p string) []int { | |
| f := make([]int, len(p)) | |
| i, j := 1, 0 | |
| for i < len(p) { |
This file contains hidden or 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
| #ifdef GL_ES | |
| precision mediump float; | |
| #endif | |
| uniform vec2 u_resolution; | |
| uniform float u_time; | |
| #define PI 3.14159265358979323846 | |
| vec2 rotate2D(vec2 _st, float _angle){ |
This file contains hidden or 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
| class Node: | |
| def __init__(self, t, is_leaf=True): | |
| self.t = t | |
| self.is_leaf = is_leaf | |
| self.keys = [] | |
| self.children = [] | |
| def is_full(self): | |
| return len(self.keys) == 2 * self.t - 1 |
This file contains hidden or 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
| import random | |
| class Node: | |
| def __init__(self, key, priority): | |
| self.key = key | |
| self.priority = priority | |
| self.parent = None | |
| self.left = None | |
| self.right = None |
This file contains hidden or 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 enum import Enum, auto | |
| class Color(Enum): | |
| RED = auto() | |
| BLACK = auto() | |
| class Node: | |
| def __init__(self, key): |
This file contains hidden or 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
| use rand; | |
| fn fisher_yates_shuffle<T: PartialOrd>(v: &mut [T]) { | |
| let len = v.len(); | |
| for i in (1..v.len()).rev() { | |
| let j = rand::random::<usize>() % (i + 1); | |
| v.swap(i, j); | |
| } | |
| } |
This file contains hidden or 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
| fn binary_search<T: PartialOrd>(v: &[T], x: &T) -> usize { | |
| let mut l = 0; | |
| let mut r = v.len(); | |
| while l < r { | |
| let mid = (l + r) / 2; | |
| if *x < v[mid] { | |
| r = mid | |
| } else { | |
| l = mid + 1 | |
| } |
NewerOlder