本文整理汇总了C++中int_vector::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ int_vector::begin方法的具体用法?C++ int_vector::begin怎么用?C++ int_vector::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类int_vector
的用法示例。
在下文中一共展示了int_vector::begin方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/*! \param i Index of the value. \f$ i \in [0..size()-1]\f$.
* Time complexity: O(1) for small and O(log n) for large values
*/
inline value_type operator[](size_type i)const {
if (m_small_lcp[i]!=255) {
return m_small_lcp[i];
} else {
size_type idx = lower_bound(m_big_lcp_idx.begin(),
m_big_lcp_idx.end(),i)
- m_big_lcp_idx.begin();
return m_big_lcp[idx];
}
}
示例2: addKeywordsImg
bool addKeywordsImg(const int dbId, const int id, int_vector hashes){
if (!validate_imgid(dbId, id)) { cerr << "ERROR: image id (" << id << ") not found on given dbid (" << dbId << ") or dbid not existant" << endl ; return false;};
// populate keyword postings
for (intVectorIterator it = hashes.begin(); it != hashes.end(); it++) {
getKwdPostings(*it)->imgIdsFilter->insert(id);
}
// populate image kwds
int_hashset& imgKwds = dbSpace[dbId]->sigs[id]->keywords;
imgKwds.insert(hashes.begin(),hashes.end());
return true;
}
示例3: queryImgIDFiltered
// query by keywords
std::vector<double> queryImgIDKeywords(const int dbId, long int id, int numres, int kwJoinType, int_vector keywords, bool colorOnly){
if (!validate_dbid(dbId)) { cerr << "ERROR: database space not found (" << dbId << ")" << endl; return std::vector<double>();}
if ((id != 0) && !validate_imgid(dbId, id)) { // not search random and image doesnt exist
cerr << "ERROR: image id (" << id << ") not found on given dbid (" << dbId << ") or dbid not existant" << endl ;
return std::vector<double>();
}
if (keywords.size() < 1) {
cerr << "ERROR: At least one keyword must be supplied" << endl ;
return std::vector<double>();
}
// populate filter
intVectorIterator it = keywords.begin();
bloom_filter* bf = 0;
// OR or AND each kwd postings filter to get final filter
// start with the first one
bf = new bloom_filter(*(getKwdPostings(*it)->imgIdsFilter));
it++;
for (; it != keywords.end(); it++) { // iterate the rest
if (kwJoinType) { // and'd
(*bf) &= *(getKwdPostings(*it)->imgIdsFilter);
} else { // or'd
(*bf) |= *(getKwdPostings(*it)->imgIdsFilter);
}
}
if (id == 0) { // random images with these kwds
vector<double> V; // select all images with the desired keywords
for (sigIterator sit = dbSpace[dbId]->sigs.begin(); sit != dbSpace[dbId]->sigs.end(); sit++) {
if (V.size() > 20*numres) break;
if ((bf == 0) || (bf->contains((*sit).first))) { // image has desired keyword or we're querying random
V.insert(V.end(), (*sit).first);
V.insert(V.end(), 0);
}
}
vector<double> Vres;
for (int var = 0; var < min(V.size()/2, numres); ) { // var goes from 0 to numres
int rint = rand()%(V.size()/2);
if (V[rint*2] > 0) { // havent added this random result yet
Vres.insert(Vres.end(), V[rint*2] );
Vres.insert(Vres.end(), 0 );
V[rint*2] = 0;
++var;
}
++var;
}
return Vres;
}
return queryImgIDFiltered(dbId, id, numres, bf, colorOnly);
}
示例4: encode
bool ternary::encode(const int_vector &v, int_vector &z){
z.setIntWidth( v.getIntWidth() );
size_t z_bit_size = 0;
for(typename int_vector::const_iterator it = v.begin(), end = v.end(); it != end; ++it){
z_bit_size += encoding_length(*it);
}
z.bit_resize( z_bit_size ); // Initial size of z
if( z_bit_size & 0x3F ){ // if z_bit_size % 64 != 0
*(z.m_data + (z_bit_size>>6)) = 0; // initialize last word
}
示例5:
std::vector<int> const build_vector()
{
typedef std::vector<int> int_vector;
static int_vector data = init_vector();
int_vector::size_type const size = data.size();
int_vector::iterator it = data.begin();
int_vector::iterator const end = data.end();
for (; it != end; ++it)
*it += size;
return data;
}
示例6:
std::unordered_set<int> const build_unordered_set()
{
typedef std::unordered_set<int> int_set;
typedef std::vector<int> int_vector;
int_set result;
int_vector const data = build_vector();
int_vector::const_iterator it = data.begin();
int_vector::const_iterator const end = data.end();
result.insert(it, end);
return result;
}
示例7:
std::map<int, int> const build_map()
{
typedef std::map<int, int> int_map;
typedef std::vector<int> int_vector;
int_map result;
int_vector const data = build_vector();
int_vector::const_iterator it = data.begin();
int_vector::const_iterator const end = data.end();
for (; it != end; ++it) {
int const value = *it;
result[value] = 100 * value;
}
return result;
}
示例8: encode
bool elias_delta::encode(const int_vector& v, int_vector& z)
{
typedef typename int_vector::size_type size_type;
z.width(v.width());
size_type z_bit_size = 0;
uint64_t w;
const uint64_t zero_val = v.width() < 64 ? (1ULL)<<v.width() : 0;
for (typename int_vector::const_iterator it = v.begin(), end = v.end(); it != end; ++it) {
if ((w=*it) == 0) {
w = zero_val;
}
z_bit_size += encoding_length(w);
}
z.bit_resize(z_bit_size); // Initial size of z
if (z_bit_size & 0x3F) { // if z_bit_size % 64 != 0
*(z.m_data + (z_bit_size>>6)) = 0; // initialize last word
}
示例9: index
/*!
* Constructor for building the Index
* \param[in] str C-string of the text
*/
index_sa_text_occ(const unsigned char* str) : index() {
size_t n = strlen((const char*)str);
sa = int_vector<>(n+1, 0, bit_magic::l1BP(n+1)+1);
algorithm::calculate_sa(str, n+1, sa); // calculate the suffix array sa of str
setText(str, n+1);
text = int_vector<>(sa.size(), 0, bit_magic::l1BP(sigma)+1);
for (size_t i=0; i<sa.size(); i++) text[i] = char2comp[str[i]];
unsigned char *bwt = new unsigned char[n+1];
{ /* Calculate Burrows-Wheeler-Transform */
size_t i = 0;
for(int_vector<>::const_iterator it = sa.begin(), end = sa.end(); it != end; ++it, ++i){
bwt[i] = m_char2comp[str[(*it+n)%(n+1)]];
}
}
occ = Occ(bwt, n+1, m_sigma);
delete[] bwt;
}
示例10:
{
typedef
std::vector<
int
>
int_vector;
int_vector const vec1{
1,
2
};
CHECK(
fcppt::range::size(
fcppt::iterator::make_range(
vec1.begin(),
vec1.begin()
)
)
==
0u
);
CHECK(
fcppt::range::size(
fcppt::iterator::make_range(
vec1.begin(),
std::next(
vec1.begin()
)
)
示例11:
>
int_vector;
int_vector const vec{
2,
5,
7
};
CHECK_FALSE(
fcppt::algorithm::binary_search(
vec,
3
).has_value()
);
CHECK(
fcppt::algorithm::binary_search(
vec,
5
)
==
fcppt::optional::make(
std::next(
vec.begin(),
1
)
)
);
}