本文整理汇总了C++中StringSet::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ StringSet::Add方法的具体用法?C++ StringSet::Add怎么用?C++ StringSet::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringSet
的用法示例。
在下文中一共展示了StringSet::Add方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Union
// Takes two string sets and returns the union set.
StringSet StringSet::Union(StringSet in_set) {
StringSet result;
for (int i = 0; i < this->Count(); ++i)
result.Add(this->GetString(i));
for (int i = 0; i < in_set.Count(); ++i)
if (!result.Contains(in_set.GetString(i)))
result.Add(in_set.GetString(i));
return result;
}
示例2: Intersection
// Takes two string sets and returns the intersection set.
StringSet StringSet::Intersection(StringSet in_set) {
StringSet result;
for (int i = 0; i < this->Count(); ++i)
if (in_set.Contains(this->GetString(i)))
result.Add(this->GetString(i));
return result;
}
示例3: CheckClassAd
bool ClassAdCollection::CheckClassAd(BaseCollection* Coll,const MyString& OID, ClassAd* Ad)
{
if (Coll->Type()==PartitionParent_e) {
PartitionParent* ParentColl=(PartitionParent*) Coll;
StringSet Values;
MyString AttrName;
MyString AttrValue;
ParentColl->Attributes.StartIterations();
// printf("Checking OID %s\n",OID.Value());
while (ParentColl->Attributes.Iterate(AttrName)) {
ExprTree* expr=Ad->LookupExpr(AttrName.Value());
if (expr) {
AttrValue = ExprTreeToString( expr );
} else {
AttrValue = "";
}
Values.Add(AttrValue);
}
// Values.StartIterations(); while (Values.Iterate(AttrValue)) { printf("Val: AttrValue=%s\n",AttrValue.Value()); }
int CoID;
PartitionChild* ChildColl=NULL;
ParentColl->Children.StartIterations();
while (ParentColl->Children.Iterate(CoID)) {
if (Collections.lookup(CoID,Coll)==-1) continue;
ChildColl=(PartitionChild*) Coll;
// ChildColl->Values.StartIterations(); while (ChildColl->Values.Iterate(AttrValue)) { printf("ChildVal: AttrValue=%s\n",AttrValue.Value()); }
if (EqualSets(ChildColl->Values,Values)) break;
ChildColl=NULL;
}
if (ChildColl==NULL) {
// Create a new child collection
ChildColl=new PartitionChild(ParentColl->Rank,Values);
CoID=LastCoID+1;
if (Collections.insert(CoID,ChildColl)==-1) return false;
LastCoID=CoID;
// Add to parent's children
ParentColl->Children.Add(CoID);
}
// Add to child
AddClassAd(CoID,OID,Ad);
return false;
}
else {
return Coll->CheckClassAd(Ad);
}
}
示例4: CheckRoms
// Check the roms to see if they code, graphics etc are complete
static int CheckRoms()
{
nBzipError = 0; // Assume romset is fine
for (int i = 0; i < nRomCount; i++) {
struct BurnRomInfo ri;
memset(&ri, 0, sizeof(ri));
BurnDrvGetRomInfo(&ri, i); // Find information about the wanted rom
if (ri.nCrc && (ri.nType & BRF_OPT) == 0 && (ri.nType & BRF_NODUMP)) {
int nState = RomFind[i].nState; // Get the state of the rom in the zip file
int nError = GetBZipError(nState);
if (nState == 0 && ri.nType) { // (A type of 0 means empty slot - no rom)
char* szName = "Unknown";
RomDescribe(&BzipDetail, &ri);
BurnDrvGetRomName(&szName, i, 0);
BzipDetail.Add(_T("%hs was not found.\n"), szName);
}
if (nError == 0) {
nBzipError |= 0x2000;
}
if (ri.nType & BRF_ESS) { // essential rom - without it the game may not run at all
nBzipError |= nError << 0;
}
if (ri.nType & BRF_PRG) { // rom which contains program information
nBzipError |= nError << 1;
}
if (ri.nType & BRF_GRA) { // rom which contains graphics information
nBzipError |= nError << 2;
}
if (ri.nType & BRF_SND) { // rom which contains sound information
nBzipError |= nError << 3;
}
}
}
if (nBzipError & 0x0F0F) {
nBzipError |= 0x4000;
}
return 0;
}
示例5: TS_PutCString
// ZZZ: Set up a C-string in the repository; a repeated call will replace an old string
void TS_PutCString(short ID, short Index, const char *String)
{
// Search for string set: (FindStringSet() creates a new one if necessary)
StringSet *CurrStringSet = FindStringSet(ID);
// Create a PString of the incoming CString, truncate to fit
unsigned char thePStringStagingBuffer[256];
size_t theStringLength = strlen(String);
if(theStringLength > 255)
theStringLength = 255;
// Fill in the string length.
thePStringStagingBuffer[0] = (char)theStringLength;
// Copy exactly the string bytes (no termination etc.)
memcpy(&(thePStringStagingBuffer[1]), String, theStringLength);
// Add() copies the string, so using the stack here is OK.
CurrStringSet->Add(Index,thePStringStagingBuffer);
}
示例6: CheckRoms
// Check the roms to see if they code, graphics etc are complete
static int CheckRoms()
{
nBzipError = 0; // Assume romset is fine
for (int i = 0; i < nRomCount; i++) {
struct BurnRomInfo ri;
memset(&ri, 0, sizeof(ri));
BurnDrvGetRomInfo(&ri, i); // Find information about the wanted rom
if (ri.nCrc && (ri.nType & 0x80) == 0) {
int nState = RomFind[i].nState; // Get the state of the rom in the zip file
if (nState == 0 && ri.nType) { // (A type of 0 means empty slot - no rom)
char* szName = "Unknown";
RomDescribe(&BzipDetail, &ri);
BurnDrvGetRomName(&szName, i, 0);
BzipDetail.Add(_T("%hs was not found.\n"), szName);
}
if (ri.nType & 0x90) { // essential rom - without it the game may not run at all
nBzipError |= GetBZipError(nState) << 0;
}
if (ri.nType & 0x01) { // rom which contains graphics information
nBzipError |= GetBZipError(nState) << 1;
}
if (ri.nType & 0x02) { // rom which contains sound information
nBzipError |= GetBZipError(nState) << 2;
}
}
}
if (!nZipsFound) {
nBzipError |= 0x08; // No data at all!
}
return 0;
}
示例7: BzipOpen
int BzipOpen(bool bootApp)
{
int nMemLen; // Zip name number
nZipsFound = 0; // Haven't found zips yet
nTotalSize = 0;
if (szBzipName == NULL) {
return 1;
}
BzipClose(); // Make sure nothing is open
if(!bootApp) { // reset information strings
BzipText.Reset();
BzipDetail.Reset();
}
// Count the number of roms needed
for (nRomCount = 0; ; nRomCount++) {
if (BurnDrvGetRomInfo(NULL, nRomCount)) {
break;
}
}
if (nRomCount <= 0) {
return 1;
}
// Create an array for holding lookups for each rom -> zip entries
nMemLen = nRomCount * sizeof(struct RomFind);
RomFind = (struct RomFind*)malloc(nMemLen);
if (RomFind == NULL) {
return 1;
}
memset(RomFind, 0, nMemLen);
for (int z = 0; z < BZIP_MAX; z++) {
char* szName = NULL;
if (BurnDrvGetZipName(&szName, z)) {
break;
}
for (int d = 0; d < DIRS_MAX; d++) {
free(szBzipName[z]);
szBzipName[z] = (TCHAR*)malloc(MAX_PATH * sizeof(TCHAR));
_stprintf(szBzipName[z], _T("%s%hs"), szAppRomPaths[d], szName);
if (ZipOpen(TCHARToANSI(szBzipName[z], NULL, 0)) == 0) { // Open the rom zip file
nZipsFound++;
nCurrentZip = z;
break;
}
}
if (nCurrentZip >= 0) {
if (!bootApp) {
BzipText.Add(_T("Found %s;\n"), szBzipName[z]);
}
ZipGetList(&List, &nListCount); // Get the list of entries
for (int i = 0; i < nRomCount; i++) {
struct BurnRomInfo ri;
int nFind;
if (RomFind[i].nState == 1) { // Already found this and it's okay
continue;
}
memset(&ri, 0, sizeof(ri));
nFind = FindRom(i);
if (nFind < 0) { // Couldn't find this rom at all
continue;
}
RomFind[i].nZip = z; // Remember which zip file it is in
RomFind[i].nPos = nFind;
RomFind[i].nState = 1; // Set to found okay
BurnDrvGetRomInfo(&ri, i); // Get info about the rom
if ((ri.nType & BRF_OPT) == 0 && (ri.nType & BRF_NODUMP) == 0) {
nTotalSize += ri.nLen;
}
if (List[nFind].nLen == ri.nLen) {
if (ri.nCrc) { // If we know the CRC
if (List[nFind].nCrc != ri.nCrc) { // Length okay, but CRC wrong
RomFind[i].nState = 2;
}
}
} else {
if (List[nFind].nLen < ri.nLen) {
RomFind[i].nState = 3; // Too small
} else {
RomFind[i].nState = 4; // Too big
}
//.........这里部分代码省略.........
示例8: TS_PutString
// Set up a string in the repository; a repeated call will replace an old string
void TS_PutString(short ID, short Index, unsigned char *String)
{
// Search for string set:
StringSet *CurrStringSet = FindStringSet(ID);
CurrStringSet->Add(Index,String);
}
示例9:
TEST(StringSetTest, Count3Strings) {
// Tests the count function.
set.Add("String number 2.");
set.Add("String number 3.");
EXPECT_EQ(3, set.Count());
}
示例10: AddOsModule
void AddOsModule(wxString mod)
{
osModules.Add(mod);
theDatabase->reload(true);
theMainWin->Reset();
}
示例11: AddOsFunction
void AddOsFunction(wxString function)
{
osFunctions.Add(function);
theDatabase->reload(true);
theMainWin->Reset();
}