本文整理汇总了C++中ContainerType::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ ContainerType::insert方法的具体用法?C++ ContainerType::insert怎么用?C++ ContainerType::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContainerType
的用法示例。
在下文中一共展示了ContainerType::insert方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Shift
void AlignmentElement::Shift(int shift)
{
ContainerType newColl;
ContainerType::const_iterator iter;
for (iter = m_collection.begin() ; iter != m_collection.end() ; ++iter){
if (*iter!=-1) newColl.insert(*iter + shift);
else newColl.insert(*iter);
}
m_collection = newColl;
}
示例2: loadDataFromStream
void Storage::loadDataFromStream(ContainerType& container, std::istream& stream)
{
std::string line;
while (!stream.eof() && !stream.fail())
{
std::getline( stream, line );
if (!line.empty() && *line.rbegin() == '\r')
line.resize(line.size() - 1);
if (!line.empty())
{
line = mEncoder->getUtf8(line);
size_t tab_pos = line.find('\t');
if (tab_pos != std::string::npos && tab_pos > 0 && tab_pos < line.size() - 1)
{
std::string key = line.substr(0, tab_pos);
std::string value = line.substr(tab_pos + 1);
if (!key.empty() && !value.empty())
container.insert(std::make_pair(key, value));
}
}
}
}
示例3: parse
void parse(std::istream& ) override
{
// ignore istream, just enter something into the map
elements_.insert(std::make_pair("hydrogen", 1.0));
elements_.insert(std::make_pair("oxygen", 16.0));
}
示例4: parseObject
QVariant QJson::parseObject(const QString &json, int &index, DecodeOptions options, bool &success, QString *errorMessage)
{
Q_ASSERT(json[index] == '{');
index++;
skipWhitespace(json, index);
ContainerType object;
while (checkAvailable(json, index, success, errorMessage))
{
if (json[index] == QChar::fromLatin1('}'))
{
index++;
return object;
}
else
{
QString key = QJson::parseValue(json, index, options, success, errorMessage).toString();
if (!success)
return QVariant();
skipWhitespace(json, index);
checkAvailable(json, index, success, errorMessage);
if (json[index] == QChar::fromLatin1(':'))
index++;
else
{
success = false;
if (errorMessage)
*errorMessage = QString("Expected colon at position %1").arg(index);
return QVariant();
}
skipWhitespace(json, index);
QVariant value = QJson::parseValue(json, index, options, success, errorMessage);
if (!success)
return QVariant();
// Add the key / value pair to the object
object.insert(key, value);
int skippedWhitespaces = skipWhitespace(json, index);
checkAvailable(json, index, success, errorMessage);
switch (json[index].toLatin1())
{
case ',':
index++;
skipWhitespace(json, index);
break;
case '}':
//'}' will be processed in the next iteration
break;
default:
// Only allow missing comma if there is at least one whitespace instead of the comma!
if ((options & AllowMissingComma) && skippedWhitespaces > 0)
break;
else
{
success = false;
if (errorMessage)
*errorMessage = QString("Unexpected character at index %1").arg(index);
return QVariant();
}
}
}
}
return QVariant();
}
示例5: parse
virtual void parse(std::istream& )
{
// ignore istream, just enter something into the map
elements_.insert(std::make_pair("A", 71.03711));
elements_.insert(std::make_pair("R", 156.10111));
}
示例6: extractConfigOptionListImpl
TyErrorId
extractConfigOptionListImpl(
const AnnotatorContext& crclConfig,
const UnicodeString* cpclConfigGroup,
const ConfigOptionInfo::StOptionInfo& crclOptionInfo,
ContainerType& rclTargetContainer,
ElementType* /*not used, just for type information since ContainerType::value_type does not work with HP compiler*/
) {
assert(crclOptionInfo.bOptionIsMultiValued);
TyErrorId utErrId = UIMA_ERR_NONE;
size_t i;
#if defined(__HPX_ACC__) || defined(__xlC__) || defined(__GNUC__)
ElementType tTemp;
#else
ContainerType::value_type tTemp;
#endif
#if defined(__SUNPRO_CC)
std::vector<ContainerType::value_type> elements;
#else
std::vector<ElementType> elements;
#endif
if (EXISTS(cpclConfigGroup)) {
crclConfig.extractValue(*cpclConfigGroup, crclOptionInfo.cpszOptionName, elements);
} else {
crclConfig.extractValue(crclOptionInfo.cpszOptionName, elements);
}
for (i = 0; i < elements.size(); ++i) {
rclTargetContainer.insert(rclTargetContainer.end(), elements[i]);
}
if (utErrId != UIMA_ERR_NONE || (elements.size() == 0)) { // could not find option or value(s)
if (crclOptionInfo.uiNbrOfValuesRequired != 0
|| crclOptionInfo.cpszDefaultValueAsString == NULL) {
// required value not there: return error we got from config
return utErrId;
}
std::vector<std::string> vecTmpStrings;
delimitedString2Vector(
vecTmpStrings,
(std::string) crclOptionInfo.cpszDefaultValueAsString,
",",
true, // trim strings
false // insert empty strings
);
// our default value too must have the required nbr of values
assert(vecTmpStrings.size() >= crclOptionInfo.uiNbrOfValuesRequired);
for (i = 0; i < vecTmpStrings.size(); ++i) {
convertFromString(vecTmpStrings[i], tTemp);
// assumes rclTargetContainer to be an STL container
rclTargetContainer.insert(rclTargetContainer.end(), tTemp);
}
}
if (i < crclOptionInfo.uiNbrOfValuesRequired) {
/* taph 8/6/1999: ?? maybe we should have a more precise error id:
UIMA_ERR_CONFIG_REQUIRED_OPTION_HAS_NOT_ENOUGH_VALUES
*/
return UIMA_ERR_CONFIG_REQUIRED_OPTION_IS_EMPTY;
}
return utErrId;
}