Skip to content

Instantly share code, notes, and snippets.

View jiaguofang's full-sized avatar

Jiaguo Fang jiaguofang

  • Uber
  • San Francisco, CA
View GitHub Profile
@jiaguofang
jiaguofang / SimpleFileSystem.java
Created January 21, 2015 08:05
Simulation of a file system
package filesystem;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
class BitArray {
public:
BitArray(unsigned capacity) {
bit_capacity = capacity;
byte_capacity = capacity / 8 + 1;
data = new char[capacity];
memset(data, 0, byte_capacity);
}
~BitArray() {
template<typename K, typename V, typename HashFunc = std::hash<K>>
class HashTable {
public:
HashTable() {
curr_size = 0;
load_factor = 1.0;
capacity = 101;
slots = new Slot[capacity];
}
#include "ProcessInfo.h"
#ifdef _WIN32
#include "psapi.h"
#pragma comment(lib, "psapi.lib")
#include "tlhelp32.h"
#endif
#ifdef linux
#include <sys/sysinfo.h>