This file contains hidden or 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.*; | |
public class Limiton { | |
private static int limit = 3; | |
private static Limiton[] instances = new Limiton[3]; | |
private static Random r = new Random(); | |
static { | |
for (int i = 0; i < limit; i++) { | |
instances[i] = new Limiton(); | |
} | |
} |
This file contains hidden or 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
// Problem | |
abstract class VisualComponent { | |
void draw(); | |
void resize(); | |
} | |
class TextView extends VisualComponent { | |
void draw() {...} | |
void resize() {...} | |
} |
This file contains hidden or 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.*; | |
public class Proxy { | |
public static void main(String[] args) { | |
} | |
} | |
class ThreeD<T, V, W> { | |
private T t; |
This file contains hidden or 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.*; | |
public class Iter { | |
public static void main(String[] args) { | |
Aggregate<Integer, Integer, Integer> ag = new DataList<Integer, Integer, Integer>(); | |
((DataList)ag).add(new ThreeD<Integer, Integer, Integer>(1, 2, 3)); | |
((DataList)ag).add(new ThreeD<Integer, Integer, Integer>(1, 2, 3)); | |
((DataList)ag).add(new ThreeD<Integer, Integer, Integer>(1, 2, 3)); | |
Iterator<Integer> ia = ag.createIteratorA(); | |
while (ia.next() != null) { |
This file contains hidden or 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
jbyteArray result = env->NewByteArray(imageDesV.size()); |
This file contains hidden or 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
g++ -m64 -shared -fPIC cvjni.cpp /usr/local/lib/libopencv_core.so \ | |
/usr/local/lib/libopencv_highgui.so -o libcvjni.so \ | |
-I/usr/local/include -I/usr/lib/jvm/jdk1.6.0_35/include \ | |
-I/usr/lib/jvm/jdk1.6.0_35/include/linux |
This file contains hidden or 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
# Makefile | |
# FOR MAC | |
CC=g++ | |
SEARCH_LIB=-lopencv_core -lopencv_highgui | |
INCLUDE=-I/usr/local/include -I$(JAVA_INCLUDE) | |
LIBRARY=-L/usr/local/lib | |
FLAGS= -m64 -dynamiclib -fPIC | |
OUT=libcvjni.jnilib | |
SRC=cvjni.cpp |
This file contains hidden or 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
//cvjni.cpp | |
#include "cvjni.h" | |
#include <opencv2/opencv.hpp> | |
#include <vector> | |
#include <iostream> | |
using namespace std; | |
using namespace cv; | |
/* |
This file contains hidden or 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
// CVJNI.java | |
import java.io.*; | |
public class CVJNI { | |
//Load jni library | |
static { | |
try { | |
System.loadLibrary("cvjni"); | |
} catch (Exception e) { | |
e.printStackTrace(); |
This file contains hidden or 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 static void install(JobConf job, Path crawlDb) throws IOException { | |
Path newCrawlDb = FileOutputFormat.getOutputPath(job); | |
FileSystem fs = new JobClient(job).getFs(); | |
Path old = new Path(crawlDb, "old"); | |
Path current = new Path(crawlDb, CURRENT_NAME); | |
if (fs.exists(current)) { | |
if (fs.exists(old)) fs.delete(old, true); | |
fs.rename(current, old); | |
} | |
fs.mkdirs(crawlDb); |
NewerOlder