本文整理汇总了C++中ke::Vector类的典型用法代码示例。如果您正苦于以下问题:C++ Vector类的具体用法?C++ Vector怎么用?C++ Vector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Vector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ArrayClone
// native Array:ArrayClone(Array:which);
static cell AMX_NATIVE_CALL ArrayClone(AMX* amx, cell* params)
{
CellArray* vec = HandleToVector(amx, params[1]);
if (vec == NULL)
{
return 0;
}
CellArray *clonevec = vec->clone();
// Scan through the vector list to see if any are NULL.
// NULL means the vector was previously destroyed.
for (unsigned int i = 0; i < VectorHolder.length(); ++i)
{
if (VectorHolder[i] == NULL)
{
VectorHolder[i] = clonevec;
return i + 1;
}
}
VectorHolder.append(clonevec);
return VectorHolder.length();
}
示例2: EnterMemoryScope
static void
EnterMemoryScope(ke::Vector<MemoryScope>& frame)
{
if (frame.empty())
frame.append(MemoryScope{0});
else
frame.append(MemoryScope{frame.back().scope_id + 1});
}
示例3:
void CLangMngr::CLang::MergeDefinitions(ke::Vector<sKeyDef> &vec)
{
ke::AutoString *pDef;
int key = -1;
while (!vec.empty())
{
auto keydef = vec.popCopy();
key = keydef.key;
pDef = keydef.definition;
AddEntry(key, pDef->ptr());
delete pDef;
}
}
示例4: ArrayCreate
// Array:ArrayCreate(cellsize=1, reserved=32);
static cell AMX_NATIVE_CALL ArrayCreate(AMX* amx, cell* params)
{
// params[1] (cellsize) is how big in cells each element is.
// this MUST be greater than 0!
int cellsize = params[1];
// params[2] (reserved) is how many elements to allocate
// immediately when the list is created.
int reserved = params[2];
if (cellsize <= 0)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid array size (%d)", cellsize);
return -1;
}
if (reserved < 0)
{
reserved = 0;
}
// Scan through the vector list to see if any are NULL.
// NULL means the vector was previously destroyed.
for (unsigned int i=0; i < VectorHolder.length(); ++i)
{
if (VectorHolder[i]==NULL)
{
VectorHolder[i] = new CellArray(cellsize, reserved);
return i + 1;
}
}
// None are NULL, create a new vector
CellArray* NewVector = new CellArray(cellsize, reserved);
VectorHolder.append(NewVector);
return VectorHolder.length();
}
示例5:
pstruct_t*
pstructs_add(const char *name)
{
auto p = ke::MakeUnique<pstruct_t>(name);
sStructs.append(ke::Move(p));
return sStructs.back().get();
}
示例6: registerSPForwardByName
//Makes a new menu handle (-1 for failure)
//native csdm_makemenu(title[]);
static cell AMX_NATIVE_CALL menu_create(AMX *amx, cell *params)
{
int len;
char *title = get_amxstring(amx, params[1], 0, len);
validate_menu_text(title);
char *handler = get_amxstring(amx, params[2], 1, len);
int func = registerSPForwardByName(amx, handler, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
if (func == -1)
{
LogError(amx, AMX_ERR_NOTFOUND, "Invalid function \"%s\"", handler);
return 0;
}
Menu *pMenu = new Menu(title, amx, func);
if (g_MenuFreeStack.empty())
{
g_NewMenus.append(pMenu);
pMenu->thisId = (int)g_NewMenus.length() - 1;
} else {
int pos = g_MenuFreeStack.front();
g_MenuFreeStack.pop();
g_NewMenus[pos] = pMenu;
pMenu->thisId = pos;
}
return pMenu->thisId;
}
示例7: ClearPluginLibraries
void ClearPluginLibraries()
{
ClearLibraries(LibSource_Plugin);
for (size_t i=0; i<g_RegNatives.length(); i++)
{
delete [] g_RegNatives[i]->pfn;
delete g_RegNatives[i];
}
g_RegNatives.clear();
}
示例8: strcpy
funcenum_t *funcenums_add(const char *name)
{
auto e = ke::MakeUnique<funcenum_t>();
strcpy(e->name, name);
e->tag = gTypes.defineFunction(name, e.get())->tagid();
sFuncEnums.append(ke::Move(e));
return sFuncEnums.back().get();
}
示例9: assert
// Sums up array usage in the current heap tracer and convert it into a dynamic array.
// This is used for the ternary operator, which needs to convert its array usage into
// something dynamically managed.
// !Note:
// This might break if expressions can ever return dynamic arrays.
// Thus, we assert() if something is non-static here.
// Right now, this poses no problem because this type of expression is impossible:
// (a() ? return_array() : return_array()) ? return_array() : return_array()
cell_t
pop_static_heaplist()
{
cell_t total = 0;
for (const auto& use : sHeapScopes.back().usage) {
assert(use.type == MEMUSE_STATIC);
total += use.size;
}
sHeapScopes.pop();
return total;
}
示例10: ClearMenus
void ClearMenus()
{
for (size_t i = 0; i < g_NewMenus.length(); i++)
{
delete g_NewMenus[i];
}
g_NewMenus.clear();
while (!g_MenuFreeStack.empty())
{
g_MenuFreeStack.pop();
}
}
示例11: GetPEL
int GetPEL()
{
for (int i=0; i<(int)PEL.length(); i++)
{
if (PEL[i]->isFree())
return i;
}
RegEx *x = new RegEx();
PEL.append(x);
return (int)PEL.length() - 1;
}
示例12: OnAmxxDetach
void OnAmxxDetach()
{
for (int i = 0; i<(int)PEL.length(); i++)
{
if (PEL[i])
{
delete PEL[i];
PEL[i] = 0;
}
}
PEL.clear();
}
示例13: OnAmxxDetach
void OnAmxxDetach()
{
while (!g_FreeTRs.empty())
{
delete g_FreeTRs.front();
g_FreeTRs.pop();
}
while (!g_KVDWs.empty())
delete g_KVDWs.popCopy();
while (!g_FreeKVDWs.empty())
delete g_FreeKVDWs.popCopy();
}
示例14: defined
//register_native(const name[], const handler[])
static cell AMX_NATIVE_CALL register_native(AMX *amx, cell *params)
{
if (!g_Initialized)
amxx_DynaInit((void *)(amxx_DynaCallback));
g_Initialized = true;
int len;
char *name = get_amxstring(amx, params[1], 0, len);
char *func = get_amxstring(amx, params[2], 1, len);
int idx, err;
if ( (err=amx_FindPublic(amx, func, &idx)) != AMX_ERR_NONE)
{
LogError(amx, err, "Function \"%s\" was not found", func);
return 0;
}
regnative *pNative = new regnative;
pNative->amx = amx;
pNative->func = idx;
//we'll apply a safety buffer too
//make our function
int size = amxx_DynaCodesize();
#if defined(_WIN32)
DWORD temp;
pNative->pfn = new char[size + 10];
VirtualProtect(pNative->pfn, size+10, PAGE_EXECUTE_READWRITE, &temp);
#elif defined(__GNUC__)
# if defined(__APPLE__)
pNative->pfn = (char *)valloc(size+10);
# else
pNative->pfn = (char *)memalign(sysconf(_SC_PAGESIZE), size+10);
# endif
mprotect((void *)pNative->pfn, size+10, PROT_READ|PROT_WRITE|PROT_EXEC);
#endif
int id = (int)g_RegNatives.length();
amxx_DynaMake(pNative->pfn, id);
pNative->func = idx;
pNative->style = params[3];
g_RegNatives.append(pNative);
pNative->name = name;
return 1;
}
示例15:
Menu *get_menu_by_id(int id)
{
if (id < 0 || size_t(id) >= g_NewMenus.length() || !g_NewMenus[id])
return NULL;
return g_NewMenus[id];
}