我试图通过使用nmap将文件映射到内存来提高我的纯文本阅读器性能.目前我有一个接收const char*和该数组长度的函数.我需要在这个char数组上执行搜索.
这就是我目前所拥有的
void parseVertex(
const char * line,
unsigned int length,
std::vector<glm::vec3> & vertices)
{
if(length == 0)
{
return;
}
char space = ' ';
char * pos = std::find(line, line + length, space);
}
Run Code Online (Sandbox Code Playgroud)
std::find产生错误:类型为const char*的值不能用于初始化char*类型的实体
什么是正确的使用方法std::find?
我有两节课:
class JController{
public static function getInstance()
{
//some source, not important...
self::createFile();//
}
public static function createFile()
{
// this is base class method
}
}
class CustomController extends JController{
public static function createFile()
{
// this is overriden class method
}
}
Run Code Online (Sandbox Code Playgroud)
我试图在派生类上调用静态方法,它调用parent方法而不是覆盖.这是预期的行为吗?
这就是我尝试使用它的方式:
$controllerInstance = CustomController::getInstance();
Run Code Online (Sandbox Code Playgroud)
我的问题是:为什么CustomController :: getInstance()调用CustomController :: createFile()?
我试图创建类似'onFinishTyping'的东西设置3s的超时,如果用户在3秒内写东西我需要销毁该计时器并设置新的..问题是每个按钮点击事件被触发后.
这是我有的:
//setup before functions
var typingTimer; //timer identifier
var doneTypingInterval = 3000; //time in ms
// Notice: jq = jQuery.noConflict();
jq(document).ready(function(){
//on keyup, start the countdown
jq('.table-search-field').keyup(function(event){
var typingTimer = setTimeout(function(){
doneTyping(event.target);
}, doneTypingInterval);
});
//on keydown, clear the countdown
jq('.table-search-field').keydown(function(){
clearTimeout(typingTimer);
});
});
//user is "finished typing," do something
function doneTyping (field) {
var value = jq(field).val().toLowerCase();// lower case
jq.ajax('index.php?option=com_mycomponent&task=player.search&keyword='+value)
.done(function(data){
console.log('ok');
}).fail(function(){
console.log('fail');
});
};
Run Code Online (Sandbox Code Playgroud)