当前位置: 首页>>代码示例>>C++>>正文


C++ DataContainer::end方法代码示例

本文整理汇总了C++中DataContainer::end方法的典型用法代码示例。如果您正苦于以下问题:C++ DataContainer::end方法的具体用法?C++ DataContainer::end怎么用?C++ DataContainer::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataContainer的用法示例。


在下文中一共展示了DataContainer::end方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: test_contain_assign

void CSTLMemoryTester::test_contain_assign()
{
#ifdef NEED_OPERATOR_FUNC
    typedef std::vector<CMyTestData> DataContainer;
    DataContainer srcDataContainer;
    
    //除了一开始的时候是构造函数,其他时候都是调用拷贝构造
    DECLARE_MYTEST_DATA_COUNT_CHECKER(ConstructCheck,ctConstructCount, 5, __FILE__, __LINE__);
    {
        for (long i = 0; i < 5; i++)
        {
            srcDataContainer.push_back(CMyTestData(i, 0));
        }

        {
            DECLARE_MYTEST_DATA_COUNT_CHECKER(ConstructCheck,ctConstructCount, 0, __FILE__, __LINE__);
            //赋值时会对容器中的每一个元素调用拷贝构造函数 -- 
            DECLARE_MYTEST_DATA_COUNT_CHECKER(CopyConstructCheck,ctCopyConstructCount, 5, __FILE__, __LINE__);
            //超出dstDataContainer的生存周期后释放
            DECLARE_MYTEST_DATA_COUNT_CHECKER(DestructCheck,ctDestructCount, 5, __FILE__, __LINE__);
            DataContainer dstDataContainer;
            dstDataContainer = srcDataContainer;
        }

        {
            DECLARE_MYTEST_DATA_COUNT_CHECKER(ConstructCheck,ctConstructCount, 0, __FILE__, __LINE__);
            //assign时会对容器中的每一个元素调用拷贝构造函数 -- 
            DECLARE_MYTEST_DATA_COUNT_CHECKER(CopyConstructCheck,ctCopyConstructCount, 5, __FILE__, __LINE__);
            //超出dstDataContainer的生存周期后释放
            DECLARE_MYTEST_DATA_COUNT_CHECKER(DestructCheck,ctDestructCount, 5, __FILE__, __LINE__);
            DataContainer dstDataContainer;
            dstDataContainer.assign(srcDataContainer.begin(), srcDataContainer.end());
        }

        {
            DECLARE_MYTEST_DATA_COUNT_CHECKER(ConstructCheck,ctConstructCount, 0, __FILE__, __LINE__);
            DECLARE_MYTEST_DATA_COUNT_CHECKER(CopyConstructCheck,ctCopyConstructCount, 5, __FILE__, __LINE__);
            DECLARE_MYTEST_DATA_COUNT_CHECKER(DestructCheck,ctDestructCount, 5, __FILE__, __LINE__);

            DataContainer dstDataContainer;
            dstDataContainer.reserve(srcDataContainer.size());
            std::copy(srcDataContainer.begin(), srcDataContainer.end(), 
                std::back_insert_iterator<DataContainer>(dstDataContainer));
        }
    }
#endif
}
开发者ID:moon-sky,项目名称:fishjam-template-library,代码行数:47,代码来源:STLMemoryTester.cpp

示例2: operator

  // insert new column if necessary
  T& operator() (size_type row, size_type col)
  {
    size_type const sr = size(row);
    if (col < sr)
      return m_data[ m_offsets[row] + col];
    else
    {
      Int const n_new = col - sr + 1;
      typename std::vector<T>::iterator pos = m_data.begin() + m_offsets[row+1];
      
      if (m_data.end()-pos < 0) // pos never can be greater than m_data.end(), otherwise m_offsets is wrong
        throw;
      m_data.insert(pos, n_new, T());

      for (size_type k = row+1; k < m_offsets.size(); ++k)
        m_offsets[k] += n_new;
      return m_data[ m_offsets[row] + col];
    }
  }
开发者ID:felipemontefuscolo,项目名称:ale-lib,代码行数:20,代码来源:sparse_table.hpp

示例3:

int
CXMLDb::Insert(DataContainerList &DataList)
{
	pthread_mutex_lock(&FileMutex);

	if(!LoadBackupFile())
	{
		Log.error("Unable to Load XML file\n");
		pthread_mutex_unlock(&FileMutex);
		return false;
	}

	while (!DataList.empty())
	{
		DataContainer Data = DataList.front();

		XMLNode *ProbeData = m_BackupFile->NewElement("pd");

		for( DataContainer::iterator ii=Data.begin(); ii!=Data.end(); ++ii)
		{
			string name = (*ii).first;
			string value = (*ii).second;
			ProbeData->ToElement()->SetAttribute(name.c_str(),value.c_str());
		}

		m_BackupFile->FirstChildElement()->InsertEndChild(ProbeData);
		DataList.pop_front();
	}

	if(!SaveBackupFile())
	{
		Log.error("Unable to save XML file\n");
		pthread_mutex_unlock(&FileMutex);
		return false;
	}

	pthread_mutex_unlock(&FileMutex);
	return true;
}
开发者ID:alxnik,项目名称:fpd,代码行数:39,代码来源:CXMLDb.cpp

示例4: Error

int
CMysqlDb::Insert(DataContainerList &DataList)
{
	if(DataList.size() == 0)
		return true;

	while (!DataList.empty())
	{
		string ColumnsString = "(";
		string ValuesString = "(";
		DataContainer Data = DataList.front();
		DataContainer::iterator LastElement = Data.end();
		--LastElement;

		for( DataContainer::iterator ii=Data.begin(); ii!=Data.end(); ++ii)
		{
			ColumnsString += (*ii).first;
			ValuesString += (*ii).second;

			if(ii == LastElement)
			{
				ColumnsString += ")";
				ValuesString += ")";
			}
			else
			{
				ColumnsString += ",";
				ValuesString += ",";
			}
		}

		string query = "INSERT IGNORE INTO " + m_table + " " + ColumnsString + " VALUES " + ValuesString + ";";
		pthread_mutex_lock(&queryMutex);

		/* send SQL query */
		if (mysql_query(&m_conn, query.c_str()))
		{
			int error = mysql_errno(&m_conn);
			pthread_mutex_unlock(&queryMutex);
			Log.log("MySQL Error (%d): %s", error, mysql_error(&m_conn));

			// Server error (fatal). Most probably because of a bug or something like that
			// Discard the entry so the program doesn't stop sending data because of it
			if(error >= 1000 && error < 2000)
			{
				Log.log("[%s]\n", query.c_str());
				DataList.pop_front();
				continue;
			}
			// Client error (transient). Do not delete the results and retry sending them
			else
				return false;
		}
		else
			pthread_mutex_unlock(&queryMutex);

		DataList.pop_front();
	}

	return true;
}
开发者ID:alxnik,项目名称:fpd,代码行数:61,代码来源:CMysqlDb.cpp


注:本文中的DataContainer::end方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。