本文整理汇总了C++中Array::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ Array::Add方法的具体用法?C++ Array::Add怎么用?C++ Array::Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array
的用法示例。
在下文中一共展示了Array::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Split
void TextComparator::Split(Array<TextSection>& dest, int start1, int end1, int start2, int end2) const
{
ASSERT(start1 <= end1 && start2 <= end2);
while(start1 < end1 && start2 < end2) {
int new1 = -1, new2 = -1, count = 0;
for(int i = start1; i + count < end1; i++)
if(Find(i, end1, start2, end2, new2, count))
new1 = i;
if(count == 0)
break; // no match at all
ASSERT(new1 >= start1 && new1 + count <= end1);
ASSERT(new2 >= start2 && new2 + count <= end2);
dest.Add(TextSection(new1, count, new2, count, true));
if(new1 - start1 >= end1 - new1 - count) { // head is longer - recurse for tail
Split(dest, new1 + count, end1, new2 + count, end2);
end1 = new1;
end2 = new2;
}
else { // tail is longer - recurse for head
Split(dest, start1, new1, start2, new2);
start1 = new1 + count;
start2 = new2 + count;
}
ASSERT(start1 <= end1 && start2 <= end2);
}
if(start1 < end1 || start2 < end2)
dest.Add(TextSection(start1, end1 - start1, start2, end2 - start2, false));
}
示例2: new
Array *Array::SortArrayElementsByKey() {
Array *newARRAY = new(AllocArray(PIF))Array(PIF);
#ifdef STDMAP_KEYS
if (Keys) {
KeyMap::iterator end = Keys->end();
AnsiString key;
ARRAY_COUNT_TYPE i = 0;
for (KeyMap::iterator iter = Keys->begin(); iter != end; ++iter) {
newARRAY->Add(Get(iter->second));
key = (char *)iter->first;
newARRAY->AddKey(&key, i++);
}
}
#else
CleanIndex(true);
for (ARRAY_COUNT_TYPE i = 0; i < KeysCount; i++) {
AnsiString key = Keys [i].KEY;
newARRAY->Add(Get(Keys [i].index));
newARRAY->AddKey(&key, i);
}
#endif
return newARRAY;
}
示例3:
TEST_FIXTURE(ConstructTestArray, Operator_Add_Container_NoResize) {
Arr.Clear();
Arr.SetResizeCount(0U);
Arr.Resize(2U, false, false);
// constructing container for adding
Array<int> AppendArr;
AppendArr.Add(1);
AppendArr.Add(2);
AppendArr.Add(3);
AppendArr.Add(4);
// adds elements until Arr is full
Arr += AppendArr;
CHECK_EQUAL(2U, Arr.GetNumOfElements());
CHECK_EQUAL(1, Arr.Get(0U));
CHECK_EQUAL(2, Arr.Get(1U));
// no elements added, Arr is full
Arr+=AppendArr;
CHECK_EQUAL(2U, Arr.GetNumOfElements());
// set resizecount back to default
Arr.SetResizeCount(10U);
}
示例4: GetAssociatedFilenames
void Script::GetAssociatedFilenames(Array<String> &lstFilenames)
{
// We want to have a list of script filenames which were included within this script
// -> It appears that there's no "easy" way in Lua to get this kind of information :/
// Contains "Application", "Interaction" and so on (no final filenames)
Array<String> lstRequire;
// Get a list of loaded "require"-files
{ // -> The files loaded within a Lua script by using "require" can be accessed by using the
// global control table variable "_LOADED". See http://www.lua.org/pil/8.1.html for details.
lua_getfield(m_pLuaState, LUA_REGISTRYINDEX, "_LOADED");
if (lua_istable(m_pLuaState, -1)) {
lua_pushnil(m_pLuaState);
while (lua_next(m_pLuaState, -2)) {
if (lua_isstring(m_pLuaState, -2))
lstRequire.Add(lua_tostring(m_pLuaState, -2));
lua_pop(m_pLuaState, 1);
}
}
// Pop the table from the Lua stack
lua_pop(m_pLuaState, 1);
}
// Get the content of "package.path" used by "require" to search for a Lua loader
// -> The content looks like "?.lua;C:\SomePath\?.lua;"
const String sPackagePath = GetGlobalVariable("path", "package");
// Iterate over the "require"-list
const String sToReplace = "?.";
for (uint32 i=0; i<lstRequire.GetNumOfElements(); i++) {
// Get the current "require"
const String sRequire = lstRequire[i] + '.';
// Get the index of the first ";" within the package path
int nPreviousIndex = 0;
int nIndex = sPackagePath.IndexOf(';');
while (nIndex>-1) {
// Get current package search path, we now have e.g. "C:\SomePath\?.lua"
String sFilename = sPackagePath.GetSubstring(nPreviousIndex, nIndex-nPreviousIndex);
// Replace "?." with the "require"-name
sFilename.Replace(sToReplace, sRequire);
// Does this file exist?
if (File(sFilename).Exists()) {
// We found a match!
lstFilenames.Add(sFilename);
// Get us out of the while-loop
nIndex = -1;
} else {
// Get the index of the next ";" within the package path
nPreviousIndex = nIndex + 1;
nIndex = sPackagePath.IndexOf(';', nPreviousIndex);
}
}
}
}
示例5: QueryOptions
bool JPCInstance::QueryOptions( Array<ImageOptions>& imageOptions, Array<void*>& formatOptions )
{
m_queriedOptions = true;
// Format-independent options
ImageOptions options;
if ( !imageOptions.IsEmpty() )
options = *imageOptions;
// Format-specific options
JPEG2000FormatOptions* jpc = nullptr;
if ( !formatOptions.IsEmpty() )
{
JPEG2000FormatOptions* o = JPEG2000FormatOptions::FromGenericDataBlock( *formatOptions );
if ( o != nullptr )
jpc = o;
}
bool reusedFormatOptions = jpc != nullptr;
if ( !reusedFormatOptions )
jpc = new JPEG2000FormatOptions( IsCodeStream() );
if ( !IsCodeStream() )
{
// Override embedding options, if requested.
JP2Format::EmbeddingOverrides overrides = JP2Format::DefaultEmbeddingOverrides();
if ( overrides.overrideICCProfileEmbedding )
options.embedICCProfile = overrides.embedICCProfiles;
}
JPEG2000OptionsDialog dlg( options, m_jp2Options, IsCodeStream() );
if ( dlg.Execute() == StdDialogCode::Ok )
{
jpc->options = dlg.jp2Options;
if ( imageOptions.IsEmpty() )
imageOptions.Add( dlg.options );
else
*imageOptions = dlg.options;
if ( formatOptions.IsEmpty() )
formatOptions.Add( (void*)jpc );
else
*formatOptions = (void*)jpc;
return true;
}
if ( !reusedFormatOptions )
delete jpc;
return false;
}
示例6: QueryOptions
bool JPEGInstance::QueryOptions( Array<ImageOptions>& imageOptions, Array<void*>& formatOptions )
{
m_queriedOptions = true;
/*
* Format-independent options
*/
ImageOptions options;
if ( !imageOptions.IsEmpty() )
options = *imageOptions;
/*
* Format-specific options
*/
JPEGFormat::FormatOptions* jpeg = nullptr;
if ( !formatOptions.IsEmpty() )
{
JPEGFormat::FormatOptions* o = JPEGFormat::FormatOptions::FromGenericDataBlock( *formatOptions );
if ( o != nullptr )
jpeg = o;
}
bool reusedFormatOptions = jpeg != nullptr;
if ( !reusedFormatOptions )
jpeg = new JPEGFormat::FormatOptions;
/*
* Override embedding options, if requested.
*/
JPEGFormat::EmbeddingOverrides overrides = JPEGFormat::DefaultEmbeddingOverrides();
if ( overrides.overrideICCProfileEmbedding )
options.embedICCProfile = overrides.embedICCProfiles;
JPEGOptionsDialog dlg( options, jpeg->options );
if ( dlg.Execute() == StdDialogCode::Ok )
{
jpeg->options = dlg.jpegOptions;
if ( imageOptions.IsEmpty() )
imageOptions.Add( dlg.options );
else
*imageOptions = dlg.options;
if ( formatOptions.IsEmpty() )
formatOptions.Add( (void*)jpeg );
else
*formatOptions = (void*)jpeg;
return true;
}
if ( !reusedFormatOptions )
delete jpeg;
return false;
}
示例7: CreateDurations
void CreateDurations(void)
{
if(GlobalRhythmSixteenth) Durations.Add() = Ratio(1, 16);
if(GlobalRhythmTripletEighth) Durations.Add() = Ratio(1, 12);
if(GlobalRhythmEighth) Durations.Add() = Ratio(1, 8);
if(GlobalRhythmTripletQuarter) Durations.Add() = Ratio(1, 6);
if(GlobalRhythmQuarter) Durations.Add() = Ratio(1, 4);
}
示例8: GetResults
void JacobianIKFixedPoint::GetResults(Array<float>& results)
{
// retrieve the node's world position
Vector3 position = mNode->GetWorldPos();
// the constraint result is the node position
results.Add(position.x);
results.Add(position.y); // ahm yes ... (Benny)
results.Add(position.z);
}
示例9: CreateBinkFix
bool CreateBinkFix(BINK* bnk)
{
char Buffer[256];
GothicReadIniString("GAME", "scaleVideos", "1", Buffer, 256, "Gothic.ini");
scaleVideos = atoi(Buffer);
if(!bnk || !scaleVideos)
return false;
POINT GothicWindowSize = { 0, 0 };
if(!GetGothicWindowSize(GothicWindowSize))
return false;
uInt Index = GetBinkIndex(bnk);
if(!Index)
{
BinkFix& Fix = Binks.Add();
Fix.Image = Fix.Resized = NULL;
Fix.Bink = bnk;
Fix.SrcWidth = bnk->Width;
Fix.SrcHeight = bnk->Height;
Fix.DstWidth = GothicWindowSize.x;
Fix.DstHeight = GothicWindowSize.y;
ValidateAspect(Fix, 0, 0);
bnk->Width = Fix.DstWidth;
bnk->Height = Fix.DstHeight;
}
return true;
}
示例10: PackParts
void RichPara::PackParts(Stream& out, const RichPara::CharFormat& chrstyle,
const Array<RichPara::Part>& part, CharFormat& cf,
Array<RichObject>& obj) const
{
for(int i = 0; i < part.GetCount(); i++) {
const Part& p = part[i];
Charformat(out, cf, p.format, chrstyle);
cf = p.format;
if(p.field) {
out.Put(FIELD);
String s = ~p.field;
out % s;
s = p.fieldparam;
out % s;
StringStream oout;
CharFormat subf = cf;
PackParts(oout, chrstyle, p.fieldpart, subf, obj);
s = oout;
out % s;
}
else
if(p.object) {
obj.Add(p.object);
out.Put(OBJECT);
}
else
out.Put(ToUtf8(p.text));
}
}
示例11: GetWorkArea
void Ctrl::GetWorkArea(Array<Rect>& rc)
{
GuiLock __;
GdkScreen *s = gdk_screen_get_default();
int n = gdk_screen_get_n_monitors(s);
rc.Clear();
Vector<int> netwa;
for(int i = 0; i < n; i++) {
GdkRectangle rr;
Rect r;
#if GTK_CHECK_VERSION (3, 3, 5) // U++ does not work with gtk3 yet, but be prepared
gdk_screen_get_monitor_workarea(s, i, &rr);
r = RectC(r.x, r.y, r.width, r.height);
#else
gdk_screen_get_monitor_geometry (s, i, &rr);
r = RectC(rr.x, rr.y, rr.width, rr.height);
#ifdef GDK_WINDOWING_X11
if(i == 0)
netwa = GetPropertyInts(gdk_screen_get_root_window(gdk_screen_get_default()),
"_NET_WORKAREA");
if(netwa.GetCount())
r = r & RectC(netwa[0], netwa[1], netwa[2], netwa[3]);
#endif
#endif
rc.Add(r);
}
}
示例12: SQLDataSources
Array< Tuple2<String, String> > ODBCSession::EnumDSN()
{
Array< Tuple2<String, String> > out;
try {
SQLHENV MIenv;
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &MIenv);
SQLSetEnvAttr(MIenv, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);
SQLRETURN ret;
char l_dsn[256];
char l_desc[256];
short int l_len1,l_len2,l_next;
l_next=SQL_FETCH_FIRST;
while(SQL_SUCCEEDED(ret = SQLDataSources(MIenv, l_next, (SQLCHAR *)l_dsn, sizeof(l_dsn),
&l_len1, (SQLCHAR *)l_desc, sizeof(l_desc), &l_len2))) {
Tuple2<String, String>& listdsn = out.Add();
listdsn.a = l_dsn;
listdsn.b = l_desc;
l_next = SQL_FETCH_NEXT;
}
}
catch(Exc e) {
LLOG("ODBC::GetDSN->" << e);
}
return out;
}
示例13: GetGlobalVariables
void Script::GetGlobalVariables(Array<String> &lstGlobalVariables, const String &sNamespace)
{
// Is there a Lua state? If so, get a nested Lua table
if (m_pLuaState && GetNestedTable(sNamespace)) {
// Push the first key onto the Lua stack
lua_pushnil(m_pLuaState);
// Iterate through the Lua table
while (lua_next(m_pLuaState, 1) != 0) {
// Lua stack content: The 'key' is at index -2 and the 'value' at index -1
// Check the 'key' type (at index -2) - must be a string
if (lua_isstring(m_pLuaState, -2)) {
// Check whether or not the 'value' (at index -1) is a global variable
// (something like "_VERSION" is passing this test as well, but that's probably ok because it's just a Lua build in global variable)
if (lua_isnumber(m_pLuaState, -1) || lua_isstring(m_pLuaState, -1)) {
// Add the global variable to our list
lstGlobalVariables.Add(lua_tostring(m_pLuaState, -2));
}
}
// Next, please (removes 'value'; keeps 'key' for next iteration)
lua_pop(m_pLuaState, 1);
}
// Pop the table from the Lua stack
lua_pop(m_pLuaState, 1);
}
}
示例14: Update
void Emitter::Update(double elapsed)
{
Array<int> deleteParticles;
if (emitting)
{
int nParticles = (minrate + (maxrate - minrate) * (float)rand() / RAND_MAX) * elapsed;
for (int i = 0; i < nParticles; i++)
particles.Add(CreateParticle());
}
for (int i = 0; i < particles.Size(); i++)
{
particles[i]->Update(elapsed);
for (uint8 a = 0; a < affectors.Size(); a++)
if (affectors[a]->IsCollide(particles[i])) affectors[a]->AffectParticle(particles[i]);
if ( particles[i]->GetLifetime() <= 0 )
deleteParticles.Add(i);
}
for (int i = 0; i < deleteParticles.Size(); i++ )
{
for (uint8 a = 0; a < affectors.Size(); a++)
affectors[a]->DeleteAffectedParticle(particles[i]);
particles.RemoveAt(i);
}
}
示例15: while
//----------------------------------------------------------------------------------------------------------------------------------------------------
Array<VirtualMemorySpan> Process::GetMemoryInfo()
{
Array<VirtualMemorySpan> Spans;
MEMORY_BASIC_INFORMATION MemoryInfo;
PVOID pAddress = 0;
TCHAR MappingName[1024];
while (VirtualQueryEx(m_hProcess, pAddress, &MemoryInfo, sizeof(MemoryInfo) ))
{
VirtualMemorySpan S;
S.Offset = MemoryInfo.BaseAddress;
S.Length = MemoryInfo.RegionSize;
S.Access = MemoryInfo.Protect;
S.State = MemoryInfo.State;
S.Type = MemoryInfo.Type;
ZeroMemory(MappingName, 1024*sizeof(TCHAR));
if (GetMappedFileName(m_hProcess, pAddress, MappingName, 1024))
S.Name = MappingName;
Spans.Add(S);
pAddress = (BYTE*)pAddress + MemoryInfo.RegionSize;
}
return Spans;
}