本文整理汇总了C++中array::Ptr::Begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::Begin方法的具体用法?C++ Ptr::Begin怎么用?C++ Ptr::Begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类array::Ptr
的用法示例。
在下文中一共展示了Ptr::Begin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: olock
char *ConsoleCommand::ConsoleCompleteHelper(const char *word, int state)
{
static std::vector<String> matches;
if (state == 0) {
if (!l_Url)
matches = ConsoleHandler::GetAutocompletionSuggestions(word, *l_ScriptFrame);
else {
Array::Ptr suggestions;
/* Remote debug console. */
try {
suggestions = AutoCompleteScript(l_Session, word, l_ScriptFrame->Sandboxed);
} catch (...) {
return nullptr; //Errors are just ignored here.
}
matches.clear();
ObjectLock olock(suggestions);
std::copy(suggestions->Begin(), suggestions->End(), std::back_inserter(matches));
}
}
if (state >= static_cast<int>(matches.size()))
return nullptr;
return strdup(matches[state].CStr());
}
示例2: olock
static Array::Ptr ArraySort(const std::vector<Value>& args)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
Array::Ptr arr = self->ShallowClone();
if (args.empty()) {
ObjectLock olock(arr);
std::sort(arr->Begin(), arr->End());
} else {
Function::Ptr function = args[0];
if (vframe->Sandboxed && !function->IsSideEffectFree())
BOOST_THROW_EXCEPTION(ScriptError("Sort function must be side-effect free."));
ObjectLock olock(arr);
std::sort(arr->Begin(), arr->End(), boost::bind(ArraySortCmp, args[0], _1, _2));
}
return arr;
}
示例3: FunctionCallV
static Value FunctionCallV(const Value& thisArg, const Array::Ptr& args)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Function::Ptr self = static_cast<Function::Ptr>(vframe->Self);
REQUIRE_NOT_NULL(self);
std::vector<Value> uargs;
{
ObjectLock olock(args);
uargs = std::vector<Value>(args->Begin(), args->End());
}
return self->InvokeThis(thisArg, uargs);
}
示例4: Intersection
Array::Ptr ScriptUtils::Intersection(const std::vector<Value>& arguments)
{
if (arguments.size() == 0)
return new Array();
Array::Ptr result = new Array();
Array::Ptr arg1 = arguments[0];
if (!arg1)
return result;
Array::Ptr arr1 = arg1->ShallowClone();
for (std::vector<Value>::size_type i = 1; i < arguments.size(); i++) {
{
ObjectLock olock(arr1);
std::sort(arr1->Begin(), arr1->End());
}
Array::Ptr arg2 = arguments[i];
if (!arg2)
return result;
Array::Ptr arr2 = arg2->ShallowClone();
{
ObjectLock olock(arr2);
std::sort(arr2->Begin(), arr2->End());
}
result->Resize(std::max(arr1->GetLength(), arr2->GetLength()));
Array::SizeType len;
{
ObjectLock olock(arr1), xlock(arr2), ylock(result);
Array::Iterator it = std::set_intersection(arr1->Begin(), arr1->End(), arr2->Begin(), arr2->End(), result->Begin());
len = it - result->Begin();
}
result->Resize(len);
arr1 = result;
}
return result;
}
示例5: olock
char *ConsoleCommand::ConsoleCompleteHelper(const char *word, int state)
{
static std::vector<String> matches;
if (state == 0) {
if (!l_ApiClient)
matches = ConsoleHandler::GetAutocompletionSuggestions(word, *l_ScriptFrame);
else {
boost::mutex mutex;
boost::condition_variable cv;
bool ready = false;
Array::Ptr suggestions;
l_ApiClient->AutocompleteScript(l_Session, word, l_ScriptFrame->Sandboxed,
std::bind(&ConsoleCommand::AutocompleteScriptCompletionHandler,
std::ref(mutex), std::ref(cv), std::ref(ready),
_1, _2,
std::ref(suggestions)));
{
boost::mutex::scoped_lock lock(mutex);
while (!ready)
cv.wait(lock);
}
matches.clear();
ObjectLock olock(suggestions);
std::copy(suggestions->Begin(), suggestions->End(), std::back_inserter(matches));
}
}
if (state >= static_cast<int>(matches.size()))
return nullptr;
return strdup(matches[state].CStr());
}