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
/* | |
* 二次背包问题 | |
* | |
* Created on: 2012-4-19 | |
* Author: Calvin | |
*/ | |
#include <iostream> | |
#include <vector> | |
#include <windows.h> | |
using namespace std; |
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
#解决安装Pygments后出现Liquid error: bad file descriptor的问题 | |
diff --git a/lib/albino.rb b/lib/albino.rb | |
index 387c8e9..b77d55e 100644 | |
--- a/lib/albino.rb | |
+++ b/lib/albino.rb | |
@@ -1,4 +1,5 @@ | |
require 'posix-spawn' | |
+require 'rbconfig' | |
## |
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 static com.mceiba.util.Print.*; | |
class Sun{ | |
//Singleton | |
private Sun(){} | |
private static Sun sun=new Sun(); | |
public static Sun makeSun(){ | |
return sun; | |
} | |
} |
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 static com.mceiba.util.Print.*; | |
class Actor{ | |
public void act() {} | |
} | |
class HappyActor extends Actor{ | |
public void act() { println("HappyActor"); } | |
} | |
class SadActor extends Actor{ | |
public void act() { println("SadActor"); } |
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 static com.mceiba.util.Print.*; | |
import java.util.*; | |
interface Processor{ | |
String name(); | |
Object process(Object input); | |
} | |
class StringProcessor implements Processor{ | |
public String name(){ | |
return getClass().getSimpleName(); |
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 static com.mceiba.util.Print.*; | |
import java.util.*; | |
class Filter{ | |
public String name(){ | |
return getClass().getSimpleName(); | |
} | |
public Wavaform process(Wavaform input) { return input; } | |
} | |
class FilterAdapter implements Processor{ |
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 static com.mceiba.util.Print.*; | |
class Shared{ | |
private int refcount = 0; | |
private static long counter = 0; | |
private final long id = counter++; | |
public void shared(){ | |
println("Creating "+this); | |
} | |
public void addRef() { refcount++; } |
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 static com.mceiba.util.Print.*; | |
import java.util.*; | |
interface Service{ | |
void method1(); | |
void method2(); | |
} | |
interface ServiceFactory{ | |
Service getService(); | |
} |
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 static com.mceiba.util.Print.*; | |
interface Selector{ | |
boolean end(); | |
Object current(); | |
void next(); | |
} | |
public class Iterator{ | |
private Object[] items; | |
private int next = 0; | |
public Iterator(int size) { items = new Object[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
//Template and Command | |
import static com.mceiba.util.Print.*; | |
import java.util.*; | |
abstract class Event{ | |
private long eventTime; | |
protected final long delayTime; | |
public Event(long delayTime){ | |
this.delayTime = delayTime; | |
start(); | |
} |
OlderNewer