本文整理汇总了C++中MapVector::size方法的典型用法代码示例。如果您正苦于以下问题:C++ MapVector::size方法的具体用法?C++ MapVector::size怎么用?C++ MapVector::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapVector
的用法示例。
在下文中一共展示了MapVector::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadAndFillTDC
int IniFile::ReadAndFillTDC(){
std::ifstream ini( sFileName.c_str() );
std::stringstream parser;
std::string token, value, line, group;
iError = INI_OK;
// Loading the file into the parser
if( ini ){
parser << ini.rdbuf();
ini.close();
} else {
iError = INI_ERROR_CANNOT_OPEN_READ_FILE;
return iError;
}
group = "";
TdcMap mapTDC;
MapVector mapVector;
while( std::getline( parser, line ) && ( iError == INI_OK ) ){
// Check if the line is comment
if( !CheckIfComment( line ) ){
// Check for group
if( !CheckIfGroup( line, group ) ){
// Check for token
if( CheckIfToken( line, token, value ) ){
// Make the key in format group.key if the group is not empty
//if( group.size() > 1 ) token = group + "." + token;
mData[ token ] = value;
} else {
iError = INI_ERROR_WRONG_FORMAT;
return iError;
}
}
else{
mapVector.push_back(mData);
mData.clear();
}
}
}
mapVector.push_back(mData);
for(int i=3 ; i<mapVector.size() ; i++){
TDC tempTDC;
tempTDC.SetName(mapVector[i]["Name"]);
//std::cout<<"TriggerWindowWidth : "<<mapVector[i]["TriggerWindowWidth"]<<std::endl;
tempTDC.SetTriggerWindowWidth(std::stoi(mapVector[i]["TriggerWindowWidth"], nullptr,10 ));
tempTDC.SetTriggerWindowOffset(std::stoi(mapVector[i]["TriggerWindowOffset"], nullptr,10 ));
tempTDC.SetTriggerExtraSearchMargin(std::stoi(mapVector[i]["TriggerExtraSearchMargin"], nullptr,10 ));
tempTDC.SetTriggerRejectMargin(std::stoi(mapVector[i]["TriggerRejectMargin"], nullptr,10 ));
tempTDC.SetEnableTriggerTimeSubstraction(std::stoi(mapVector[i]["EnableTriggerTimeSubstraction"], nullptr,10 ));
tempTDC.SetIndividualLSB(std::stoi(mapVector[i]["IndividualLSB"], nullptr,10 ));
fTdcVector.push_back(tempTDC);
//std::cout<<"Tdc-NName : "<<mapVector[i]["Name"]<<std::endl;
//std::cout<<"TDC-NAME : "<<mapVector[i]["Name"]<<std::endl;
}
std::cout<<"Num of Groups in INI file : "<<mapVector.size()<<std::endl;
}
示例2: Buckets
static void
writeIndex(MCStreamer &Out, MCSection *Section,
ArrayRef<unsigned> ContributionOffsets,
const MapVector<uint64_t, UnitIndexEntry> &IndexEntries) {
if (IndexEntries.empty())
return;
unsigned Columns = 0;
for (auto &C : ContributionOffsets)
if (C)
++Columns;
std::vector<unsigned> Buckets(NextPowerOf2(3 * IndexEntries.size() / 2));
uint64_t Mask = Buckets.size() - 1;
size_t i = 0;
for (const auto &P : IndexEntries) {
auto S = P.first;
auto H = S & Mask;
auto HP = ((S >> 32) & Mask) | 1;
while (Buckets[H]) {
assert(S != IndexEntries.begin()[Buckets[H] - 1].first &&
"Duplicate unit");
H = (H + HP) & Mask;
}
Buckets[H] = i + 1;
++i;
}
Out.SwitchSection(Section);
Out.EmitIntValue(2, 4); // Version
Out.EmitIntValue(Columns, 4); // Columns
Out.EmitIntValue(IndexEntries.size(), 4); // Num Units
Out.EmitIntValue(Buckets.size(), 4); // Num Buckets
// Write the signatures.
for (const auto &I : Buckets)
Out.EmitIntValue(I ? IndexEntries.begin()[I - 1].first : 0, 8);
// Write the indexes.
for (const auto &I : Buckets)
Out.EmitIntValue(I, 4);
// Write the column headers (which sections will appear in the table)
for (size_t i = 0; i != ContributionOffsets.size(); ++i)
if (ContributionOffsets[i])
Out.EmitIntValue(i + DW_SECT_INFO, 4);
// Write the offsets.
writeIndexTable(Out, ContributionOffsets, IndexEntries,
&DWARFUnitIndex::Entry::SectionContribution::Offset);
// Write the lengths.
writeIndexTable(Out, ContributionOffsets, IndexEntries,
&DWARFUnitIndex::Entry::SectionContribution::Length);
}
示例3:
TEST(MapVectorTest, erase) {
MapVector<int, int> MV;
MV.insert(std::make_pair(1, 2));
MV.insert(std::make_pair(3, 4));
MV.insert(std::make_pair(5, 6));
ASSERT_EQ(MV.size(), 3u);
MV.erase(MV.find(1));
ASSERT_EQ(MV.size(), 2u);
ASSERT_EQ(MV.find(1), MV.end());
ASSERT_EQ(MV[3], 4);
ASSERT_EQ(MV[5], 6);
}
示例4:
TEST(MapVectorTest, insert) {
MapVector<int, int> MV;
std::pair<MapVector<int, int>::iterator, bool> R;
R = MV.insert(std::make_pair(1, 2));
ASSERT_EQ(R.first, MV.begin());
EXPECT_EQ(R.first->first, 1);
EXPECT_EQ(R.first->second, 2);
EXPECT_TRUE(R.second);
R = MV.insert(std::make_pair(1, 3));
ASSERT_EQ(R.first, MV.begin());
EXPECT_EQ(R.first->first, 1);
EXPECT_EQ(R.first->second, 2);
EXPECT_FALSE(R.second);
R = MV.insert(std::make_pair(4, 5));
ASSERT_NE(R.first, MV.end());
EXPECT_EQ(R.first->first, 4);
EXPECT_EQ(R.first->second, 5);
EXPECT_TRUE(R.second);
EXPECT_EQ(MV.size(), 2u);
EXPECT_EQ(MV[1], 2);
EXPECT_EQ(MV[4], 5);
}
示例5: MapMemberName
int DialogReaderWriter::MapMemberName(MapVector& aVector, string& aName)
{
int wId;
CaseValues* wCase;
for(int i = 0; i < aVector.size(); i++)
{
wCase = aVector[i];
wId = aVector[i]->isMatch(aName);
if(wId > -1)
return wId;
}
return -1;
}