本文整理汇总了C++中Array1D::pop_back方法的典型用法代码示例。如果您正苦于以下问题:C++ Array1D::pop_back方法的具体用法?C++ Array1D::pop_back怎么用?C++ Array1D::pop_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array1D
的用法示例。
在下文中一共展示了Array1D::pop_back方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static void CombinationWithDuplicatedElementsVer2Helper(Array1D &array, int left,
int k, int times,
Array1D &temp,
Array2D &result)
{
if (array.size() - left < k) { return; }
if (k == 0) {
result.push_back(temp);
return;
}
for (int i = left; i <= array.size(); i++) {
if (i == 0 || array[i] != array[i - 1]) {
times = 1;
temp.push_back(array[i]);
CombinationWithDuplicatedElementsVer2Helper(array, i + 1, k - 1, 1, temp, result);
temp.pop_back();
}
else {
times++;
if (temp.size() >= times - 1 && temp[temp.size() - times + 1] == array[i]) {
temp.push_back(array[i]);
CombinationWithDuplicatedElementsVer2Helper(array, i + 1, k - 1, times, temp, result);
temp.pop_back();
}
}
}
}
示例2: CombinationWithDuplicatedElementsHelper
static void CombinationWithDuplicatedElementsHelper(Array1D &array, int left, int k,
int times, Array1D &temp, Array2D &result)
{
assert(left >= 0);
if (array.size() - left < k) { return; }
if (k == 0) {
result.push_back(temp);
return;
}
if (left == 0 || array[left] != array[left - 1]) {
temp.push_back(array[left]);
CombinationWithDuplicatedElementsHelper(array, left + 1, k - 1, 1, temp, result);
temp.pop_back();
CombinationWithDuplicatedElementsHelper(array, left + 1, k, 1, temp, result);
}
else {
if (temp.size() >= times && temp[temp.size() - times] == array[left]) {
temp.push_back(array[left]);
CombinationWithDuplicatedElementsHelper(array, left + 1, k - 1, times + 1, temp, result);
temp.pop_back();
}
CombinationWithDuplicatedElementsHelper(array, left + 1, k, times + 1, temp, result);
}
}
示例3: CombinationHelper
static void CombinationHelper(Array1D &array, int left, int right, int k,
Array1D &temp, Array2D &result)
{
assert(!array.empty());
assert(left >= 0 && right >= 0);
if (right - left + 1 < k) { return; }
if (k == 0) {
result.push_back(temp);
return;
}
temp.push_back(array[left]);
CombinationHelper(array, left + 1, right, k - 1, temp, result);
temp.pop_back();
CombinationHelper(array, left + 1, right, k, temp, result);
}
示例4: assert
static void CombinationVer2Helper(Array1D &array, int left, int right, int k,
Array1D &temp, Array2D &result)
{
assert(!array.empty());
assert(left >= 0 && right >= 0);
if (k == 0) {
result.push_back(temp);
return;
}
for (int i = left; i <= right - k + 1; i++) {
temp.push_back(array[i]);
CombinationVer2Helper(array, i + 1, right, k - 1, temp, result);
temp.pop_back();
}
}