本文整理汇总了C++中UIntVector::pop_back方法的典型用法代码示例。如果您正苦于以下问题:C++ UIntVector::pop_back方法的具体用法?C++ UIntVector::pop_back怎么用?C++ UIntVector::pop_back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIntVector
的用法示例。
在下文中一共展示了UIntVector::pop_back方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Nearest
UIntVector KNearest::Nearest(const RealCoord &state,
const RealCoordVector &state_set) const {
UIntVector neighbors;
std::size_t state_num = state_set.size();
if (state_num <= k_) {
for (unsigned i = 0; i < state_num; ++i) {
neighbors.push_back(i);
}
} else {
double *dist = new double[state_num];
for (unsigned i = 0; i < state_num; ++i) {
dist[i] = metric_->Distance(state, state_set[i]);
}
for (unsigned i = 0; i <= k_; ++i) {
neighbors.push_back(i);
}
for (unsigned i = 1; i < k_; ++i) {
double di = dist[i];
unsigned j = i - 1;
while (j != std::numeric_limits<unsigned>::max() && dist[i] < dist[j]) {
dist[j + 1] = dist[j];
neighbors[j + 1] = neighbors[j];
--j;
}
dist[j + 1] = di;
neighbors[j + 1] = i;
}
for (unsigned i = k_; i < state_num; ++i) {
double di = dist[i];
unsigned j = k_ - 1;
while (j != std::numeric_limits<unsigned>::max() && dist[i] < dist[j]) {
dist[j + 1] = dist[j];
neighbors[j + 1] = neighbors[j];
--j;
}
neighbors[j + 1] = i;
}
delete[] dist;
}
neighbors.pop_back();
return neighbors;
}
示例2: LSLOC
/*!
* Extracts and stores logical lines of code.
* Determines and extract logical SLOC to place in the result variable
* using addSLOC function. Each time the addSLOC function is called,
* a new logical SLOC is added. This function assumes that the directive
* is handled before it is called.
*
* \param result counter results
* \param line processed physical line of code
* \param lineBak original physical line of code
* \param strLSLOC processed logical string
* \param strLSLOCBak original logical string
* \param paren_cnt count of parenthesis
* \param loopWhiteSpace count of white space to determine loop ends
*/
void CPythonCounter::LSLOC(results* result, string line, size_t lineNumber, string lineBak, string &strLSLOC, string &strLSLOCBak,
unsigned int &paren_cnt, UIntVector &loopWhiteSpace)
{
#define CONT_STR_LENGTH 18
string continuation_str[] = {"is", "in", "not", "+", "-", "*", "/", "=", "<", ">", "|", "&", "%", "^", "\\", "~", ",", "$"};
size_t start = 0; // starting index of the working string
size_t i = 0, idx, strSize;
int n;
bool trunc_flag = false;
unsigned int cnt = 0, numWS;
string exclude = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_$";
string tmp;
// process:
// paren_cnt is used with {} [] ()
// 1. check if the current char is in one of the parentheses
// 2. if no, check if the line has : or ; (statement separators), except else:
// 3. if yes, count and put the statement in the result
// 4. if the line does not ends with a continuation string or a statement separator (handled)
// and the line is not in one of the parentheses
// then count and put the statement in the result
// 5. physical count considers all lines executables (or directives, no declarations)
// check for loop ends, new loops, and record white space in order to determine ends
if (print_cmplx)
{
// check white space for loop ends
if (loopWhiteSpace.size() > 0)
{
// get white space
tmp = line;
tmp = CUtil::TrimString(tmp, -1);
numWS = (unsigned)(line.length() - tmp.length());
// check for loop ends
for (n = (int)loopWhiteSpace.size() - 1; n >= 0; n--)
{
if (loopWhiteSpace.at(n) != numWS)
break;
else
loopWhiteSpace.pop_back();
}
}
// check for loop keywords (for, while)
cnt = 0;
CUtil::CountTally(line, loop_keywords, cnt, 1, exclude, "", "", NULL);
if (cnt > 0)
{
if (loopWhiteSpace.size() < 1)
{
// get white space
tmp = line;
tmp = CUtil::TrimString(tmp, -1);
numWS = (unsigned)(line.length() - tmp.length());
}
// add nested loop white space and record nested loop level
for (i = 0; i < cnt; i++)
{
loopWhiteSpace.push_back(numWS);
if ((unsigned int)result->cmplx_nestloop_count.size() < loopWhiteSpace.size())
result->cmplx_nestloop_count.push_back(1);
else
result->cmplx_nestloop_count[loopWhiteSpace.size()-1]++;
}
}
}
line = CUtil::TrimString(line);
lineBak = CUtil::TrimString(lineBak);
size_t line_length = line.length();
bool lineContinued = false;
while (i < line_length)
{
switch (line[i])
{
case '{': case '[': case '(': // parentheses opener
paren_cnt++;
break;
case '}': case ']': case ')': // parentheses closer
//.........这里部分代码省略.........