Skip to content

Instantly share code, notes, and snippets.

View greyscaled's full-sized avatar
🕹️

Greg greyscaled

🕹️
  • Hamilton, ON
View GitHub Profile
const collect = (node, pre, pattern, q) => {
if (!node) { return }
let d = pre.length
if (d === pattern.length && node.value) { q.push(pre) }
if (d === pattern.length) { return }
let next
pattern[d] === '.'
? next = '.'
: next = Base26.getBase26Digit(pattern[d])
const recursiveInsert = (node, key, val, d) => {
if (!node) node = new Node()
if (d === key.length) {
node.value = val
return node
}
let c = Base26.getBase26Digit(key[d])
node.next[c] = recursiveInsert(node.next[c], key, val, d + 1)
return node
}
class Trie {
constructor () {
this.root = new Node()
}
put (key = '', val = null) {
this.root = recursiveInsert(this.root, key, val, 0)
}
// ...
const R = 26
function Node (value = null) {
this.value = value
this.next = new Array(R)
}
class Trie {
constructor () {
this.root = new Node()
// R defined elsewhere
function Node (value = null) {
this.value = value
this.next = new Array(R)
}
$drawer-width: 80vw;
.navigation {
&__nav {
height: 100%;
position: absolute;
top: 0;
left: 0;
z-index: 1000;
// this hides the navigation drawer
<div class="navigation">
<input class="navigation__cbox"/>
...
<nav class="navigation_nav">
</nav>
</div>
$hamburger-height: 4rem;
.navigation {
&__cbox { display: none; }
&__hamburger-box {
width: $hamburger-height;
height: $hamburger-height;
position: absolute;
top: 3rem;
.navigation {
// ...
&__hamburger {
margin-top: 2rem; // middle line 'meat' of burger
position: relative;
// this sets the style for all 3 lines
&,
&::before,
&::after {
.navigation {
// ...
&__hamburger {
margin-top: 2rem; // middle line 'meat' of burger
position: relative;
// this sets the style for all 3 lines
&,
&::before,
&::after {