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
public class HeapSort { | |
private static int parent(int idx) { | |
return (idx - 1) / 2; | |
} | |
private static int left(int idx) { | |
return 2 * idx + 1; | |
} |
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 <stack> | |
#include <vector> | |
#include <memory> | |
#include <functional> | |
#include <iostream> | |
#include "tree.hpp" | |
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
#include <set> | |
#include <stack> | |
#include <vector> | |
#include <memory> | |
#include <iostream> | |
#include <exception> | |
#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
#include <stack> | |
#include <vector> | |
#include <memory> | |
#include <functional> | |
#include <exception> | |
#include <iostream> | |
#include <cassert> | |
template <typename 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
import java.util.Stack; | |
public class InOrder { | |
public static class TreeNode<T extends Comparable<T>> { | |
public T data; | |
public TreeNode<T> left, right; | |
public TreeNode(T data) { | |
this(data, null, null); |
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
CC = g++ | |
CFLAGS = -std=c++11 -Wall -g | |
LFLAGS = -lboost_unit_test_framework | |
DEFINES = -D_DEBUG | |
TARGET = stringmisc-test | |
all: $(TARGET) | |
stringmisc-test: stringmisc.o stringmisc-test.o |
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 "LoGrid.hpp" | |
#if _DEBUG | |
void PrintLoGrid(const LoGrid &g) | |
{ | |
// TODO | |
} | |
#endif |
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 cStringIO import StringIO | |
class LoGrid(object): | |
def __init__(self, dim, init_state=[]): | |
"""Set up a square matrix of `dim` by `dim` size. | |
Optionally, provide an initial state in the form of a linear boolean | |
array (list) of length `dim` squared. |
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
CXX = g++ -std=c++11 | |
LIBS = -lsfml-graphics -lsfml-window -lsfml-system | |
all: sample-sfml-app | |
%.o: %.cpp | |
$(CXX) -c $< -o $@ | |
%.o: %.hpp | |
$(CXX) -c $< -o $@ |
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
public class HelloJNI { | |
static { | |
System.loadLibrary("hello"); // loads libhello.so | |
} | |
private native void sayHello(String name); | |
public static void main(String[] args) { | |
new HelloJNI().sayHello("Dave"); | |
} |
NewerOlder