示例#1
0
	//debugging purpose
	void toString(){
		cerr << "Call name: " << call_fun_name << " | Functions: ";
		for(vs::iterator i = function_uses.begin(); i != function_uses.end(); i++){
			cerr << *i << " ";
		}
		cerr << "| Pairs Size " << pairs.size() << endl;
	}
示例#2
0
//----------------------------------------------------------------------------
// Returns true if a given vector<string> contains given string
//----------------------------------------------------------------------------
bool containsElem(vs list, string value) {
	for (vs::iterator it = list.begin(); it != list.end(); it++) {
		if (*it == value) {
			return true;
		}
	}
	return false;
}
示例#3
0
string newMemberTwo(vs existingNames, string newName)
{
	set<string> names(existingNames.begin(), existingNames.end());

	if(names.count(newName) == 0 )
		return newName;

	char testName[1024];
	int currentInt = 1;

	while(1)
	{

		sprintf(testName, "%s%d", newName.c_str(), currentInt);

		if(names.count(testName) == 0)
			return testName;
		else
			currentInt++;
	}
}
示例#4
0
void foo(const vs &lines)
{
    for (vs::const_iterator i(lines.begin()); i != lines.end(); ++i) {
        cout << **i << endl;
    }
}
示例#5
0
string newMember(vs existingNames, string newName)
{

	bool match = true;
	int newSize = newName.size();
	vector<int> numberList;

	for(vs::iterator it = existingNames.begin(); it != existingNames.end(); it++)
	{
		match = true;
		int stringSize = it->size();

		if(stringSize >= newSize)
		{
			for(int i = 0; i < newSize; i++)
			{
				if(it->at(i) != newName[i])
				{
					match = false;
					//cout << "Match not found\n";
					break;
				}
			}

			if(match)
			{
				//FoundString
				//Number at end
				int numberInt;
				if(stringSize == newSize)
				{
					numberInt = 0;
				}
				else
				{
					string number = it->substr(newSize, stringSize-1);
					numberInt = atoi(number.c_str());
				}

				numberList.push_back(numberInt);

				//cout << "Match found - int = " << numberInt << "\n";
			}
		}
		else
		{
			//cout << "Match not found\n";
		}

	}

	if(!numberList.empty())
	{
		sort(numberList.begin(), numberList.end());

		int lowestNumber = 0;
		for(vector<int>::iterator it = numberList.begin(); it != numberList.end(); it++)
		{
			if(*it == lowestNumber)
			{
				lowestNumber++;
			}
			else
			{
				break;
			}
		}

		if(lowestNumber > 0)
		{
			stringstream ss;
			ss << newName << lowestNumber;
			return ss.str();
		}
		else
		{
			return newName;
		}
	}
	else
	{
		return newName;
	}
}