本文整理汇总了C++中Array1D::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ Array1D::empty方法的具体用法?C++ Array1D::empty怎么用?C++ Array1D::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array1D
的用法示例。
在下文中一共展示了Array1D::empty方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CombinationWithDuplicatedElementsByNonRecursion
Array2D CombinationWithDuplicatedElementsByNonRecursion(Array1D array, int K)
{
Array2D result;
if (array.empty() || K <= 0) { return result; }
if (array.size() < K) {
result.push_back(array); /** @warning maybe exclude it */
return result;
}
std::sort(array.begin(), array.end());
result.push_back(Array1D());
int last = array[0], opt_result_num = 1;
for (int i = 0; i < array.size(); i++) {
if (array[i] != last) {
last = array[i];
opt_result_num = result.size();
}
Array2D::size_type result_size = result.size();
for (int j = result_size - 1; j >= result_size - opt_result_num; j--) {
result.push_back(result[j]);
result.back().push_back(array[i]);
}
}
return result;
}
示例2: temp
vector<Mat> SegmentDataByIDX(const Mat& data, const Mat& idx)
{
assert(data.type() == CV_32F || data.type() == CV_64F);
assert(data.rows > 0 && data.cols > 0 && idx.rows > 0 && idx.cols > 0);
assert(data.cols == idx.cols);
Array2D idx_hash;
if (idx.type() != CV_32S) {
Mat idx_tmp = idx;
Mat_<int> tmp;
idx_tmp.convertTo(tmp, CV_32S);
idx_hash = ComputeIDX(tmp);
} else{
idx_hash = ComputeIDX(idx);
}
if (idx_hash.empty()) { return vector<Mat>(); }
vector<Mat> result(idx_hash.size());
for (int i = 0; i < idx_hash.size(); i++) {
Array1D cur = idx_hash[i];
if (cur.empty()) { return vector<Mat>(); }
Mat temp(data.rows, cur.size(), data.type());
Mat col(data.rows, 1, data.type());
for (int j = 0; j < cur.size(); j++) {
col = temp(Range(0, data.rows), Range(j, j + 1));
data(Range(0, data.rows), Range(cur[j] - 1, cur[j])).copyTo(col);
}
result[i] = temp;
}
return result;
}
示例3: PermutationUnique
/**
* @brief find all permutation of array
* @brief array has some repeating elements
*/
Array2D PermutationUnique(Array1D array)
{
Array2D result;
if (array.empty()) { return result; }
if (array.size() == 1) {
result.push_back(array);
return result;
}
PermutationUniqueHelper(array, 0, result);
return result;
}
示例4:
Array2D CombinationVer2(Array1D array, int K)
{
Array2D result;
if (array.empty() || K <= 0) { return result; }
if (array.size() < K) {
result.push_back(array); /** @warning maybe exclude it */
return result;
}
Array1D temp;
CombinationVer2Helper(array, 0, array.size() - 1, K, temp, result);
}
示例5: Combination
Array2D Combination(Array1D array, int K) {
Array2D result;
if (array.empty() || K <= 0) { return result; }
if (array.size() < K) {
result.push_back(array);
return result;
}
Array1D temp;
CombinationHelper(array, 0, array.size() - 1, K, temp, result);
return result;
}
示例6: CombinationByDecrease
Array2D CombinationByDecrease(Array1D array, int K)
{
Array2D result;
if (array.empty() || K <= 0) { return result; }
if (array.size() < K) {
result.push_back(array); /** @warning maybe exclude it */
return result;
}
Array1D temp(K);
CombinationByDecreaseHelper(array, array.size(), K, temp, result);
}
示例7: Setup
// Analysis_Lifetime::Setup()
Analysis::RetType Analysis_Lifetime::Setup(Array1D const& dsArray, CpptrajFile* outfile) {
if (dsArray.empty()) return Analysis::ERR;
standalone_ = outfile;
inputDsets_ = dsArray;
windowSize_ = -1;
averageonly_ = false;
cumulative_ = false;
deltaAvg_ = false;
normalizeCurves_ = true;
cut_ = 0.5;
fuzzCut_ = -1;
Compare_ = Compare_GreaterThan;
return Analysis::OK;
}
示例8: 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);
}
示例9: 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();
}
}
示例10: CombinationByNonRecursion
Array2D CombinationByNonRecursion(Array1D array, int K)
{
Array2D result;
if (array.empty() || K <= 0) { return result; }
if (array.size() < K) {
result.push_back(array); /** @warning maybe exclude it */
return result;
}
Array1D cur(1);
for (int i = 1; i <= array.size(); i++) {
Array1D::size_type size = cur.size();
Array1D temp;
/** @bug has some problems */
for (int j = 0; j < size; j++) {
temp.push_back(cur[j]);
temp.push_back(array[i]);
if (temp.size() == K) { result.push_back(temp); }
else { cur.push_back(array[i]); }
}
}
return result;
}
示例11: CombinationByBinary
Array2D CombinationByBinary(Array1D array, int K)
{
Array2D result;
if (array.empty() || K <= 0) { return result; }
if (array.size() < K) {
result.push_back(array); /** @warning maybe exclude it */
return result;
}
/** @warning sort or not */
Array1D temp;
int begin = (1 << K) - 1, end = (1 << array.size()) - (1 << (array.size() - K));
for (int bit = begin; bit <= end; bit = NextBit(bit)) {
temp.clear();
for (int i = 0; i < array.size(); i++) {
if (bit & (1 << i)) {
temp.push_back(array[i]);
}
}
result.push_back(temp);
}
return result;
}