o**2 发帖数: 168 | 1 Give each Predictor object its own thread, and apply producer/consumer
pattern twice: one is from user thread to predictor thread for dropping off
prediction input, and the other one is form predictor thread to user thread
for picking up computed prediction.
public class Predictor implements Runnable {
private String input, prediction;
private boolean stop;
public Predictor () {
new Thread (this).start ();
}
public synchronized boolean isIdle () {
return input... 阅读全帖 |
|
c*****n 发帖数: 96 | 2 Use factory pattern:
//Define a abstract class Cell which the application (Excel) will
//process.
public abstract class Cell {
....
public TValue getValue();
}
// Define concrete cell class
public class LiteralCell : Cell { // '500'
public override TValue getValue() { ... }
}
public class ExpressionCell :Cell { // 'A5 + A10'
public override TValue getValue() { ....}
}
public class FunctionCell : Cell { // 'f(A1, A2, A5)'
public override TValue getValue() { ....}
}
// define ... 阅读全帖 |
|
d***a 发帖数: 316 | 3 declare 一个 C++ string class object,
然后用 .c_str() 将其转换成一个 c string
再用 strcat() 加上一个后缀。
strcat(userinput, "_data_extracted.txt")
这个最后得到的 c string 有时会在原string和新加的后缀之间又加了一些东西,比如
%B 或者 %FF%FF。有时又不出现。请教为什么,如何处理?多谢。 |
|
|
Q**a 发帖数: 406 | 5 贴完整代码,这样说不清楚。看你的意思userinput就是.c_str()转换出来的const
char*,但strcat的第一个参数应该是char*,你中间干啥了?
以及,你要干的这件事情直接让那个string += "..."就行 |
|