Skip to content

Instantly share code, notes, and snippets.

View jweinst1's full-sized avatar
🎯
Focusing

Josh Weinstein jweinst1

🎯
Focusing
View GitHub Profile
@jweinst1
jweinst1 / hash bench.rs
Created March 11, 2025 23:06
hash map rust bench
use std::collections::HashMap;
fn add_rand_strings(keys:&mut Vec<String>, amnt:usize, l:usize) {
const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
let mut rnd = 548324;
for i in 0..amnt {
let mut s = String::new();
for j in 0..l {
#include <string>
#include <cstring>
#include <filesystem>
#include <string>
#include <iostream>
#include <regex>
#include <vector>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
@jweinst1
jweinst1 / hash_merge_tree.cpp
Last active March 10, 2025 02:07
hash merge tree
#include <map>
#include <unordered_map>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cstdint>
#include <ctime>
#include <optional>
@jweinst1
jweinst1 / unordered_map_bucket.cpp
Last active February 24, 2025 10:25
playing with unordered buckets in c++
int main(int argc, char const *argv[])
{
std::unordered_map<std::string, std::string> fooMap;
const std::string s1 = "foobar";
const std::string s2 = "doobar";
const std::string s3 = "loobar";
const std::string s4 = "4oobar";
const std::string s5 = "77oobar";
std::printf("Bucket count is %zu\n", fooMap.bucket_count());
@jweinst1
jweinst1 / bloom_hash.cpp
Created February 22, 2025 09:50
A hash map that doesn't resolve collisions and tries to be a bloom filter but gives location and membership info
#include <map>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <ctime>
#include <optional>
#include <chrono>
#include <memory>
@jweinst1
jweinst1 / sorted_string.cpp
Last active February 22, 2025 07:24
a sorted string table in C++
#include <map>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <ctime>
#include <optional>
#include <chrono>
@jweinst1
jweinst1 / bad_disk_skiplist.c
Created February 20, 2025 16:57
very slow skip list with free list
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <time.h>
#include <assert.h>
#include <sys/time.h>
// storage format
// [off][size]
@jweinst1
jweinst1 / skiplist.c
Last active February 20, 2025 10:05
skiplist implementation in C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <time.h>
#include <assert.h>
#include <sys/time.h>
// storage format
// [off][size]
@jweinst1
jweinst1 / ptr_store_counter.cpp
Created February 10, 2025 23:21
map to store pointers with hazard RC
#include <atomic>
#include <thread>
#include <chrono>
#include <cstdint>
#include <limits>
#include <cstdio>
#include <string>
#include <memory>
#include <vector>
#include <atomic>
#include <cstdlib>
#include <cstdio>
#include <ctime>
#include <thread>
#include <chrono>
#include <assert.h>
#include <vector>
static size_t randomLeveLGen() {