Skip to content

Instantly share code, notes, and snippets.

Santoso Wijaya santa4nt

Block or report user

Report or block santa4nt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@santa4nt
santa4nt / HeapSort.java
Last active Aug 29, 2015
HeapSort implementations.
View HeapSort.java
public class HeapSort {
private static int parent(int idx) {
return (idx - 1) / 2;
}
private static int left(int idx) {
return 2 * idx + 1;
}
@santa4nt
santa4nt / traversal.cc
Last active Aug 29, 2015
Binary tree traversal algorithms, without recursion.
View traversal.cc
#include <stack>
#include <vector>
#include <memory>
#include <functional>
#include <iostream>
#include "tree.hpp"
using namespace std;
@santa4nt
santa4nt / toposort-ex.cc
Last active Aug 29, 2015
Topological Sort on a DAG
View toposort-ex.cc
#include <set>
#include <stack>
#include <vector>
#include <memory>
#include <iostream>
#include <exception>
#include <cassert>
using namespace std;
@santa4nt
santa4nt / inorder-rank.cpp
Last active Aug 29, 2015
In-order traversal on a BST without recursion.
View inorder-rank.cpp
#include <stack>
#include <vector>
#include <memory>
#include <functional>
#include <exception>
#include <iostream>
#include <cassert>
template <typename T>
@santa4nt
santa4nt / InOrder.java
Last active Aug 29, 2015
In-order traversal on a BST without recursion.
View InOrder.java
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);
@santa4nt
santa4nt / Makefile
Last active Aug 29, 2015
Various implementations of string manipulations in C++.
View Makefile
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
View LoGrid.cpp
#include "LoGrid.hpp"
#if _DEBUG
void PrintLoGrid(const LoGrid &g)
{
// TODO
}
#endif
@santa4nt
santa4nt / logrid.py
Last active Aug 29, 2015
A Simple LightsOut Grid in Python.
View logrid.py
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.
@santa4nt
santa4nt / Makefile
Created Jun 2, 2015
Sample SFML app (Linux-based)
View Makefile
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 $@
@santa4nt
santa4nt / HelloJNI.java
Last active Feb 15, 2020
Sample JNI/C++ HelloWorld
View HelloJNI.java
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");
}
You can’t perform that action at this time.