コード例 #1
0
void TerminationHelper::runFirstMdrun(const std::string &expectedCptFileName)
{
    CommandLine firstPart(*mdrunCaller_);
    // Stop after 0.036 ms, which should be short enough that
    // numSteps isn't reached first.
    firstPart.addOption("-maxh", 1e-7);
    firstPart.addOption("-nstlist", 1);
    firstPart.addOption("-cpo", runner_->cptFileName_);
    ASSERT_EQ(0, runner_->callMdrun(firstPart));
    EXPECT_EQ(true, File::exists(expectedCptFileName, File::returnFalseOnError)) << expectedCptFileName << " was not found";
}
コード例 #2
0
ファイル: PropertyGroup.cpp プロジェクト: SgtFlame/indiezen
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
const Zen::Studio::Workbench::I_Property*
PropertyGroup::getPropertyByName(const std::string& _fullName)
{
    if (_fullName == getName())
    {
        std::cout << "PropertyGroup::getPropertyByName(): Found it... it's me!" << std::endl;
        return this;
    }
    else
    {
        // Parse the name using "\" as a delimiter.

        const std::string delimiter("\\");
        std::string::const_iterator iter = std::find_first_of(_fullName.begin(), _fullName.end(), delimiter.begin(), delimiter.end());

        // If the delimiter was found...
        if (iter != _fullName.end())
        {
            // Check to make sure the first part is equal to getName(); if it's
            // not then something went wrong.
            std::string firstPart(_fullName.begin(), iter);

            if (firstPart != getName())
            {
                std::cout << "PropertyGroup::getPropertyByName(): Oops, something went wrong." << std::endl;
                return NULL;
            }

            std::string::const_iterator iter2 = std::find_first_of(iter + 1, _fullName.end(), delimiter.begin(), delimiter.end());

            PropertyChildren_type::iterator pChild = m_children.find(std::string(iter + 1, iter2));
            if (pChild != m_children.end())
            {
                return pChild->second->getPropertyByName(std::string(iter + 1, _fullName.end()));
            }
            else
            {
                std::cout << "Child name wasn't in map" << std::endl;
            }
        }
    }

    std::cout << "PropertyGroup::getPropertyByName(): Ooops, didn't find it." << std::endl;
    return NULL;
}
コード例 #3
0
int inversionUsingSort(vector<int>& v) {
  if (v.size() <= 1) {
    return 0;
  }
  int count = 0;

  // Divide the array into two parts.
  vector<int> firstPart(v.begin(), v.begin() + v.size() / 2);
  vector<int> secondPart(v.begin() + v.size() / 2, v.end());

  count += inversionUsingSort(firstPart);
  count += inversionUsingSort(secondPart);

  // Merge the arrays.
  auto first = firstPart.begin();
  auto second = secondPart.begin();

  size_t idx = 0;
  for (; first != firstPart.end() || second != secondPart.end(); ) {
    if (first == firstPart.end()) {
      v[idx++] = *second;
      second++;
    } else if (second == secondPart.end()) {
      v[idx++] = *first;
      first++;
    } else {
      if (*first <= *second) {
        v[idx++] = *first;
        first++;
      } else {
        // This is the inversion case. We are inserting an element from the
        // second vector into the merged vector. All the remaining elements in
        // the first vector are inversions w.r.t. the element being added from
        // the second. Note that this counts duplicates too.
        count += std::distance(first, firstPart.end());
        v[idx++] = *second;
        second++;
      }
    }
  }
  return count;
}
コード例 #4
0
void JpegReceiver::nextStep()
{
	while (bufferLength < headerPrediction)
	{
		receivePacket();
	}
	std::string firstPart((char*)(buffer.get() + bufferStartPoint), headerPrediction);
	std::string lengthBorderBig = "Content-Length: ";
	std::string lengthBorderSmall = "Content-length: ";
	int placeBig = firstPart.find(lengthBorderBig);
	int placeSmall = firstPart.find(lengthBorderSmall);
	int startLen = std::max(placeBig, placeSmall) + lengthBorderBig.length();
	int endLen = startLen;
	while (firstPart.at(endLen) >= '0' && firstPart.at(endLen) <= '9')
	{
		endLen++;
	}
	int jpegLength = atoi(firstPart.substr(startLen, endLen - startLen).c_str());
	while (firstPart.at(endLen) == ' ' || firstPart.at(endLen) == '\n' || firstPart.at(endLen) == '\r')
	{
		++endLen;
	}
	if (placeSmall != -1) endLen += 28;
	while (bufferLength - endLen < jpegLength)
	{
		receivePacket();
	}
	lockImage();
	currentPic = JpegWrap(buffer.get() + (bufferStartPoint + endLen) * sizeof(unsigned char), jpegLength);
//	createNextBmp();
	releaseImage();
//	createNextPicture();

	//jpegWrap.pic = sh_ptr_uch(new unsigned char[jpegWrap.length]);
	//memcpy(jpegWrap.pic.get(), buffer.get() + (bufferStartPoint + endLen) * sizeof(unsigned char), jpegWrap.length * sizeof(unsigned char));
/*	for (int i = 0; i < jpegLength; ++i)
	{
		data.get()[i] = buffer.get()[bufferStartPoint + endLen + i];
	}*/
	shiftBuffer(bufferStartPoint + endLen + jpegLength);
}