vector -> set

This commit is contained in:
Elnur Ismailzada 2019-05-17 00:36:58 +02:00
parent 49b0e85227
commit 82d4407c78
5 changed files with 18 additions and 13 deletions

View File

@ -112,9 +112,9 @@ bool QZXing::getTryHarder()
}
void QZXing::setAllowedExtensions(const QVariantList& extensions)
{
std::vector<int> allowedExtensions;
std::set<int> allowedExtensions;
for (const QVariant& extension: extensions) {
allowedExtensions.push_back(extension.toInt());
allowedExtensions.insert(extension.toInt());
}
allowedExtensions_ = allowedExtensions;

View File

@ -24,6 +24,8 @@
#include <QImage>
#include <QVariantList>
#include <set>
#if QT_VERSION >= 0x050000
class QQmlEngine;
#endif
@ -220,7 +222,7 @@ private:
QString charSet_;
bool tryHarder_;
bool lastDecodeOperationSucceded_;
std::vector<int> allowedExtensions_;
std::set<int> allowedExtensions_;
/**
* If true, the decoding operation will take place at a different thread.

View File

@ -77,6 +77,7 @@ const zxing::DecodeHints DecodeHints::DEFAULT_HINT(
DecodeHints::DecodeHints() {
hints = 0;
allowedEanExtensions = {};
}
DecodeHints::DecodeHints(const zxing::DecodeHintType &init) {
@ -151,11 +152,11 @@ bool DecodeHints::getTryHarder() const {
return (hints & TRYHARDER_HINT) != 0;
}
void DecodeHints::setAllowedEanExtensions(std::vector<int> toset) {
void DecodeHints::setAllowedEanExtensions(std::set<int> toset) {
allowedEanExtensions = toset;
}
std::vector<int> DecodeHints::getAllowedEanExtensions() const {
std::set<int> DecodeHints::getAllowedEanExtensions() const {
return allowedEanExtensions;
}
@ -181,8 +182,10 @@ zxing::DecodeHints zxing::operator | (DecodeHints const& l, DecodeHints const& r
if (!result.callback) {
result.callback = r.callback;
}
if (result.allowedEanExtensions.empty()) {
result.allowedEanExtensions = r.allowedEanExtensions;
}
result.allowedEanExtensions = l.allowedEanExtensions;
result.allowedEanExtensions.insert(r.allowedEanExtensions.begin(),
r.allowedEanExtensions.end());
return result;
}

View File

@ -23,7 +23,7 @@
#include <zxing/BarcodeFormat.h>
#include <zxing/ResultPointCallback.h>
#include <vector>
#include <set>
namespace zxing {
@ -35,7 +35,7 @@ class DecodeHints {
private:
DecodeHintType hints;
Ref<ResultPointCallback> callback;
std::vector<int> allowedEanExtensions;
std::set<int> allowedEanExtensions;
public:
static const DecodeHintType AZTEC_HINT;
@ -78,8 +78,8 @@ class DecodeHints {
void setTryHarder(bool toset);
bool getTryHarder() const;
void setAllowedEanExtensions(std::vector<int> toset);
std::vector<int> getAllowedEanExtensions() const;
void setAllowedEanExtensions(std::set<int> toset);
std::set<int> getAllowedEanExtensions() const;
void setResultPointCallback(Ref<ResultPointCallback> const&);
Ref<ResultPointCallback> getResultPointCallback() const;

View File

@ -177,7 +177,7 @@ Ref<Result> UPCEANReader::decodeRow(int rowNumber,
// continue
}
std::vector<int> allowedExtensions = hints.getAllowedEanExtensions();
std::set<int> allowedExtensions = hints.getAllowedEanExtensions();
if (allowedExtensions.size() > 0) {
bool valid = false;
for (int length: allowedExtensions) {