本文整理汇总了C++中DataList::size方法的典型用法代码示例。如果您正苦于以下问题:C++ DataList::size方法的具体用法?C++ DataList::size怎么用?C++ DataList::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataList
的用法示例。
在下文中一共展示了DataList::size方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startChunks
//=============================================================================
// METHOD: SPELLipcDataChunk::
//=============================================================================
int SPELLipcDataChunk::startChunks( const std::string& id, const DataList& data )
{
SPELLmonitor m(m_lock);
if (data.size()<=m_chunkSize) return 0;
ListOfDataList* chunks = new ListOfDataList();
DataList::const_iterator it;
DataList::const_iterator end = data.end();
unsigned int lineCount = 0;
DataList* chunk = new DataList();
for( it = data.begin(); it != end; it++)
{
chunk->push_back( (*it) );
lineCount++;
if (lineCount==m_chunkSize)
{
chunks->push_back( chunk );
chunk = new DataList();
lineCount = 0;
}
}
// Add the last partial chunk if any
if (chunk->size()>0)
{
chunks->push_back( chunk );
}
m_chunks[id] = chunks;
int totalChunks = chunks->size();
return totalChunks;
}
示例2: convolve
static DataList convolve(const DataList &f1, const DataList &f2,
const float dt = 1.0f) {
const unsigned int f1size = f1.size();
const unsigned int f2size = f2.size();
DataList toReturn = DataList(f1size + f2size - 1, 0);
for (unsigned int i = 0; i < f1size; ++i) {
for (unsigned int j = 0; j < f2size; ++j) {
toReturn[i+j] += f1[i] * f2[j] * dt;
}
}
return toReturn;
}
示例3: sendSumwz
void ParallelInfo::sendSumwz(const DataList &toSend)
{
int P_Tag = 0;
// P_Info points to the info struct for the neigbor under consideration
ParallelInfo *P_Info;
#if defined(TIMING_MODE)
long long start, elapsed;
start = rdtsc();
#endif
P_Info = &P_Nodes[0];
// send sumwz to the root node
for (unsigned int i = 0; i < toSend.size(); i++)
P_Info->P_sumwz[i] = toSend.at(i);
#if defined(RNG_BUCKET)
P_RandComm->Send(&P_Info->P_sumwz[0], totalNumNrns, MPI_DOUBLE,
P_ROOT_NODE_NUM, P_Tag, MPI_COMM_WORLD);
#else
MPI_Send(&P_Info->P_sumwz[0], totalNumNrns, MPI_DOUBLE, P_ROOT_NODE_NUM,
P_Tag, MPI_COMM_WORLD);
#endif
#if defined(TIMING_MODE)
elapsed = rdtsc() - start;
Output::Out() << MSG << "Elapsed nonroot_snd time = "
<< elapsed * 1.0 / TICKS_PER_SEC << " seconds" << endl;
#endif
}
示例4: fillDataLists
void fillDataLists(const vector<FrameEnhanced> &frames,
DataList& redChannels, DataList& greenChannels, DataList& blueChannels)
{
assert(frames.size() == redChannels.size());
assert(frames.size() == greenChannels.size());
assert(frames.size() == blueChannels.size());
// build temporary data structure
for ( size_t exp = 0; exp < frames.size(); ++exp )
{
Channel* red;
Channel* green;
Channel* blue;
frames[exp].frame()->getXYZChannels(red, green, blue);
redChannels[exp] = red->data();
greenChannels[exp] = green->data();
blueChannels[exp] = blue->data();
}
}
示例5: nCycles
Combo::Combo(Layer::Molecule* molecule, DataList const& frames, int const interpolationFrames,
double const speed) : Base(1.0, speed, Ramp), m_molecule(molecule), m_frames(frames),
m_bounce(false), m_loop(false), m_interpolationFrames(interpolationFrames),
m_currentIndex(-1)
{
m_referenceFrames = 1 + (frames.size()-1)/(m_interpolationFrames+1);
int nCycles(m_bounce ? 2*m_referenceFrames-1 : m_referenceFrames-1);
setCycles(nCycles);
DataList::iterator iter;
for (iter = m_frames.begin(); iter != m_frames.end(); ++iter) {
(*iter)->m_surface->setCheckState(Qt::Unchecked);
}
setCurrentIndex(0);
}
示例6: makeNode
void makeNode(DataList& in)
{
for(int i = 0; i< in.size(); i++)
{
Node* temp = new Node(i+1);
stringstream left1,down1,top1,right1;
int left2,down2,top2,right2;
if(in[i][0][0] == '-')
{
string temp0 = in[i][0];
temp0.erase(temp0.begin());
left1<<temp0;
left1>>left2;
left2 = (-1)*left2;
}
else
{
示例7: Read
void ScrDB::Read(TARGETING::TargetHandle_t i_ptargetHandle,
BitString & bs,
uint64_t registerId)
{
//PRDF_DENTER( "ScrDB::Read() huid: 0x%X, addr: 0x%016X",
// getHuid(i_ptargetHandle), registerId );
DataList data;
unsigned int dataWordSize = bs.getBitLen()/32;
dataWordSize += (bs.getBitLen() % 32) ? 1 : 0;
// if the register has a predetermined value than get it
if(pChipset.find(i_ptargetHandle) != pChipset.end())
{
PreScrMap pscrmap = pChipset[i_ptargetHandle];
if(pscrmap.find(registerId) != pscrmap.end()) // we must have a predetermined value
{
SimScrDataSet pValues = pscrmap[registerId];
data = pValues.GetData(); // get next set of values
// pValues has changed - copy it back
pscrmap[registerId] = pValues;
pChipset[i_ptargetHandle] = pscrmap;
}
}
if(data.size() == 0) // use the last value written to this reg
{
// get a copy of the scrMap for this chip - if one does not exist it will be created
ScrMap scrMap = chipset[i_ptargetHandle];
// get a copy of the data for this address from the scrMap for this chip
// if data structure does not exist, it will be created, but will be empty
data = scrMap[registerId];
if(data.size() == 0) // This is the first time this register has been accessed
{
while(data.size() < dataWordSize) data.push_back(0); // zero fill
scrMap[registerId] = data;
chipset[i_ptargetHandle] = scrMap; // update the persistent copy of the scrMap
}
}
if(0 != data.size())
{
for(unsigned int i = 0; i < data.size(); ++i)
{
bs.setFieldJustify((i*32), 32, data[i]);
}
PRDF_TRAC( "ScrDB::Read() huid: %X, addr: %016X, data: %08X %08X",
getHuid(i_ptargetHandle), registerId, data[0],
2 == data.size() ? data[1] : 0 );
}
//PRDF_DEXIT( "ScrDB::Read()" );
}
示例8: GetColData
void DBDictionary::GetColData( int colNum, const DataList & dataList, std::vector<std::string> & outList )
{
if( colNum < 0 )
{
printf( "read error" );
return;
}
int size = dataList.size();
for( int num = 0; num < size; num++ )
{
std::string data = dataList[num]._data[colNum];
if( IsSameData( data, outList ) == false )
{
printf( "%s \n", data.c_str() );
outList.push_back( data );
}
}
}
示例9: Write
void ScrDB::Write(TARGETING::TargetHandle_t i_ptargetHandle,
BitString & bs,
uint64_t registerId)
{
PRDF_TRAC( "ScrDB::Write() huid: %X, addr: %016X, data: %08X %08X",
getHuid(i_ptargetHandle), registerId,
bs.getFieldJustify(0,32), bs.getFieldJustify(32,32) );
unsigned int dataWordSize = bs.getBitLen()/32;
// PRDF_TRAC("dataWordSize1: %d", dataWordSize);
dataWordSize += (bs.getBitLen() % 32) ? 1 : 0;
// PRDF_TRAC("dataWordSize2: %d", dataWordSize);
DataList data;
// parse all data given
data.push_back(bs.getFieldJustify(0,32));
data.push_back(bs.getFieldJustify(32,32));
// PRDF_TRAC("parse all data given");
// look for expected data
DataList expectedData;
if(eChipset.find(i_ptargetHandle) != eChipset.end())
{
PRDF_TRAC("found target");
PreScrMap escrmap = eChipset[i_ptargetHandle];
if(escrmap.find(registerId) != escrmap.end()) // we have expected data value
{
PRDF_TRAC("found scom reg");
SimScrDataSet eValues = escrmap[registerId];
expectedData = eValues.GetData(); // get next set of values
escrmap[registerId] = eValues;
eChipset[i_ptargetHandle] = escrmap;
}
}
if(expectedData.size() > 0)
{
if((expectedData[0] != data[0]) || (expectedData[1] != data[1]))
{
PRDF_ERR("Verify SC register: %p", i_ptargetHandle);
PRDF_ERR(" Address: 0x%016X", registerId);
PRDF_ERR("SCR write Actual : %08X %08X", data[0], data[1]);
PRDF_ERR("SCR write Expected: %08X %08X", expectedData[0], expectedData[1]);
}
else
{
PRDF_TRAC("Verify SC register: %p", i_ptargetHandle);
PRDF_TRAC(" Address: 0x%016X", registerId);
PRDF_TRAC("SCR write Actual: %08X %08X", data[0], data[1]);
}
}
// PRDF_TRAC("get a copy");
// get a copy of the scrMap for this chip - if one does not exist it will be created
ScrMap scrMap = chipset[i_ptargetHandle];
// PRDF_TRAC("update register value");
// update register value
scrMap[registerId] = data; // copy the supplied value to the register
// PRDF_TRAC("update the master");
chipset[i_ptargetHandle] = scrMap; // scrMap is only a copy so must update the master
//PRDF_EXIT( "ScrDB::Write()" );
}
示例10: main
int main(int argc, char* argv[])
{
int capacity;
int NumOfFood;
fstream fin(argv[1]);
fstream fout;
fout.open(argv[2],ios::out);
fin>>capacity;
fin>>NumOfFood;
int x;
int y;
int weight;
DataList FoodInfo;
vector<int>aa(4,0);
FoodInfo.push_back(aa);
while(fin>>x>>y>>weight)
{
Data temp(3);
temp[0] = x;
temp[1] = y;
temp[2] = weight;
FoodInfo.push_back(temp);
}
//test
cout<<capacity<<endl;
cout<<NumOfFood<<endl;
//cout<<x<<" "<<y<<" "<<weight<<endl;
for(int i=0;i<FoodInfo.size();i++)
{
for(int j=0;j<3;j++)
{
cout<<FoodInfo[i][j]<<" ";
}
cout<<endl;
}
//cout<<"capacity="<<capacity<<endl;
//cout<<"size:"<<FoodInfo.size()<<endl;
int *minimalDist = new int[FoodInfo.size()];
//int* position = new int[FoodInfo.size()];
vector<int> position;
ShortestPath(FoodInfo.size()-1,capacity,FoodInfo,minimalDist,position);
for(int i=1;i<=NumOfFood;i++)
{
cout<<minimalDist[i]<<endl;
}
cout<<"postition"<<endl;
for(int i=position.size()-1;i>=0;i--)
{
cout<<position[i]<<endl;
}
//cout<<FoodInfo.size()-1<<endl;
cout<<"GREEDY!"<<endl;
int distance = 0;
Data position1;
Greedy(FoodInfo,FoodInfo.size()-1,capacity,position1,distance);
for(int i=0;i<position1.size();i++)
{
cout<<position1[i]<<endl;
}
cout<<"distance"<<distance<<endl;
cout<<"end"<<endl;
/*
cout<<CapacityCheck(0 , 3 , capacity ,FoodInfo);
cout<<CapacityCheck(1 , 3 , capacity ,FoodInfo);
cout<<CapacityCheck(2 , 3 , capacity ,FoodInfo);
cout<<CapacityCheck(3 , 3 , capacity ,FoodInfo);
cout<<endl;
cout<<dist2origin(0, FoodInfo)<<endl;
cout<<dist2origin(1, FoodInfo)<<endl;
cout<<dist2origin(2, FoodInfo)<<endl;
cout<<dist2origin(3, FoodInfo)<<endl;
cout<<endl;
//cout<<dist(0, 0, FoodInfo)<<endl;
//c//out<<dist(0, 1, FoodInfo)<<endl;
//cout<<dist(1, 2, FoodInfo)<<endl;
//cout<<"asd"<<dist(0, 1, FoodInfo)+dist(1, 2, FoodInfo)+dist(2, 3, FoodInfo)<<endl;
//.........这里部分代码省略.........
示例11: if
bool
FreezeScript::invokeMemberFunction(const string& name, const DataPtr& target, const DataList& args, DataPtr& result,
const DataFactoryPtr& factory, const ErrorReporterPtr& errorReporter)
{
//
// string
//
StringDataPtr targetStr = StringDataPtr::dynamicCast(target);
if(targetStr)
{
if(name == "find")
{
StringDataPtr argData;
IntegerDataPtr startData;
if(args.size() > 0)
{
argData = StringDataPtr::dynamicCast(args[0]);
}
if(args.size() > 1)
{
startData = IntegerDataPtr::dynamicCast(args[1]);
}
if(args.size() == 0 || args.size() > 2 || !argData || (args.size() == 2 && !startData))
{
errorReporter->error("invalid arguments to find(string str[, int len])");
}
string targ = targetStr->stringValue();
string arg = argData->stringValue();
string::size_type pos;
if(startData)
{
string::size_type start = static_cast<string::size_type>(startData->integerValue());
pos = targ.find(arg, start);
}
else
{
pos = targ.find(arg);
}
result = factory->createInteger(pos == string::npos ? -1 : static_cast<Ice::Long>(pos), false);
return true;
}
else if(name == "substr")
{
IntegerDataPtr startData;
IntegerDataPtr lenData;
if(args.size() > 0)
{
startData = IntegerDataPtr::dynamicCast(args[0]);
}
if(args.size() > 1)
{
lenData = IntegerDataPtr::dynamicCast(args[1]);
}
if(args.size() == 0 || args.size() > 2 || !startData || (args.size() == 2 && !lenData))
{
errorReporter->error("invalid arguments to substr(int start[, int len])");
}
string targ = targetStr->stringValue();
string::size_type start = static_cast<string::size_type>(startData->integerValue());
string::size_type len = string::npos;
if(lenData)
{
len = static_cast<string::size_type>(lenData->integerValue());
}
if(start > targ.size())
{
ostringstream ostr;
ostr << "substr() starting position (" << start << ") is greater than string length ("
<< targ.size() << ")";
errorReporter->error(ostr.str());
}
result = factory->createString(targ.substr(start, len), false);
return true;
}
else if(name == "replace")
{
IntegerDataPtr startData;
IntegerDataPtr lenData;
StringDataPtr strData;
if(args.size() == 3)
{
startData = IntegerDataPtr::dynamicCast(args[0]);
lenData = IntegerDataPtr::dynamicCast(args[1]);
strData = StringDataPtr::dynamicCast(args[2]);
}
if(args.size() != 3 || !startData || !lenData || !strData)
{
errorReporter->error("invalid arguments to replace(int start, int len, string val)");
}
string targ = targetStr->stringValue();
string::size_type start = static_cast<string::size_type>(startData->integerValue());
string::size_type len = static_cast<string::size_type>(lenData->integerValue());
string str = strData->stringValue();
if(start > targ.size())
{
ostringstream ostr;
ostr << "replace() starting position (" << start << ") is greater than string length ("
<< targ.size() << ")";
errorReporter->error(ostr.str());
}
//.........这里部分代码省略.........