本文整理汇总了C++中Index::end方法的典型用法代码示例。如果您正苦于以下问题:C++ Index::end方法的具体用法?C++ Index::end怎么用?C++ Index::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Index
的用法示例。
在下文中一共展示了Index::end方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_const_iterators
void test_const_iterators(const Index& i,int target)
{
typedef typename Index::const_iterator const_iterator;
typedef typename Index::const_reverse_iterator const_reverse_iterator;
int n=0;
for(const_iterator it=i.begin();it!=i.end();++it){
n+=it->id;
}
int m=0;
for(const_reverse_iterator rit=i.rbegin();rit!=i.rend();++rit){
m+=rit->id;
}
int p=0;
for(const_iterator it2=i.end();it2!=i.begin();){
--it2;
p+=it2->id;
}
int q=0;
for(const_reverse_iterator rit2=i.rend();rit2!=i.rbegin();){
--rit2;
q+=rit2->id;
}
BOOST_CHECK(n==target&&n==m&&n==p&&n==q);
}
示例2: test_non_const_iterators
void test_non_const_iterators(Index& i,int target)
{
typedef typename Index::iterator iterator;
typedef typename Index::reverse_iterator reverse_iterator;
int n=0;
for(iterator it=i.begin();it!=i.end();++it){
BOOST_TEST(i.iterator_to(*it)==it);
n+=it->id;
}
int m=0;
for(reverse_iterator rit=i.rbegin();rit!=i.rend();++rit){
m+=rit->id;
}
int p=0;
for(iterator it2=i.end();it2!=i.begin();){
--it2;
p+=it2->id;
}
int q=0;
for(reverse_iterator rit2=i.rend();rit2!=i.rbegin();){
--rit2;
q+=rit2->id;
}
BOOST_TEST(n==target&&n==m&&n==p&&n==q);
}
示例3: test_const_hashed_iterators
void test_const_hashed_iterators(const Index& i,int target)
{
typedef typename Index::const_iterator const_iterator;
typedef typename Index::const_local_iterator const_local_iterator;
typedef typename Index::size_type size_type;
BOOST_TEST(i.cbegin()==i.begin());
BOOST_TEST(i.cend()==i.end());
int n=0;
for(const_iterator it=i.begin();it!=i.end();++it){
BOOST_TEST(i.iterator_to(*it)==it);
n+=it->id;
}
int m=0;
for(size_type buc=0;buc<i.bucket_count();++buc){
BOOST_TEST(i.cbegin(buc)==i.begin(buc));
BOOST_TEST(i.cend(buc)==i.end(buc));
for(const_local_iterator it=i.begin(buc);it!=i.end(buc);++it){
BOOST_TEST(i.local_iterator_to(*it)==it);
m+=it->id;
}
}
BOOST_TEST(n==target&&n==m);
}
示例4:
static std::vector<GLuint> _adapt(const Index& index)
{
return std::vector<GLuint>(
index.begin(),
index.end()
);
}
示例5: all_in_range
bool all_in_range (const Index& ind, const T& left, const T& right)
{
for(typename Index::const_pointer i = ind.begin(); i != ind.end(); ++i)
if(!(*i >= left && *i <= right))
return false;
return true;
}
示例6: test_const_rnd_iterators
void test_const_rnd_iterators(const Index& i,int target)
{
typedef typename Index::const_iterator const_iterator;
typedef typename Index::const_reverse_iterator const_reverse_iterator;
typedef typename Index::difference_type difference_type;
BOOST_TEST(i.cbegin()==i.begin());
BOOST_TEST(i.cend()==i.end());
BOOST_TEST(i.crbegin()==i.rbegin());
BOOST_TEST(i.crend()==i.rend());
const_iterator middle=i.begin()+(i.end()-i.begin())/2;
difference_type off=middle-i.begin();
const_reverse_iterator rmiddle=i.rbegin()+off;
bool odd=((i.end()-i.begin())%2)!=0;
int n=0;
for(const_iterator it=i.begin();it!=middle;++it){
BOOST_TEST(i.iterator_to(*it)==it);
n+=it->id;
n+=it[off].id;
}
if(odd)n+=(boost::prior(i.end()))->id;
int m=0;
for(const_reverse_iterator rit=i.rbegin();rit!=rmiddle;++rit){
m+=rit->id;
m+=(rit+off)->id;
}
if(odd)m+=(boost::prior(i.rend()))->id;
int p=0;
for(const_iterator it2=i.end();it2!=middle;){
--it2;
p+=it2->id;
p+=(it2-off)->id;
}
if(odd)p-=middle->id;
int q=0;
for(const_reverse_iterator rit2=i.rend();rit2!=rmiddle;){
--rit2;
q+=rit2->id;
q+=(rit2-off)->id;
}
if(odd)q-=rmiddle->id;
BOOST_TEST(n==target&&n==m&&n==p&&n==q);
}
示例7: test_const_hashed_iterators
void test_const_hashed_iterators(const Index& i,int target)
{
typedef typename Index::const_iterator const_iterator;
typedef typename Index::const_local_iterator const_local_iterator;
typedef typename Index::size_type size_type;
int n=0;
for(const_iterator it=i.begin();it!=i.end();++it){
n+=it->id;
}
int m=0;
for(size_type buc=0;buc<i.bucket_count();++buc){
for(const_local_iterator it=i.begin(buc);it!=i.end(buc);++it){
m+=it->id;
}
}
BOOST_CHECK(n==target&&n==m);
}
示例8: test_non_const_rnd_iterators
void test_non_const_rnd_iterators(Index& i,int target)
{
typedef typename Index::iterator iterator;
typedef typename Index::reverse_iterator reverse_iterator;
typedef typename Index::difference_type difference_type;
iterator middle=i.begin()+(i.end()-i.begin())/2;
difference_type off=middle-i.begin();
reverse_iterator rmiddle=i.rbegin()+off;
bool odd=((i.end()-i.begin())%2)!=0;
int n=0;
for(iterator it=i.begin();it!=middle;++it){
n+=it->id;
n+=it[off].id;
}
if(odd)n+=(--i.end())->id;
int m=0;
for(reverse_iterator rit=i.rbegin();rit!=rmiddle;++rit){
m+=rit->id;
m+=(rit+off)->id;
}
if(odd)m+=(--i.rend())->id;
int p=0;
for(iterator it2=i.end();it2!=middle;){
--it2;
p+=it2->id;
p+=(it2-off)->id;
}
if(odd)p-=middle->id;
int q=0;
for(reverse_iterator rit2=i.rend();rit2!=rmiddle;){
--rit2;
q+=rit2->id;
q+=(rit2-off)->id;
}
if(odd)q-=rmiddle->id;
BOOST_CHECK(n==target&&n==m&&n==p&&n==q);
}
示例9: py_add_bud
void py_add_bud(size_t pid, const Index& attractors, real_t level){
add_bud(pid, AttractorList(attractors.begin(),attractors.end()),level);
}
示例10: build_index
void build_index(void)
{
IndexSort _sort(distances);
std::sort<Index::iterator,IndexSort>(index.begin(), index.end(), _sort);
}
示例11: CreateResource
bool CreateResource(DcmDirectoryRecord*& target,
ResourceType level,
DcmFileFormat& dicom,
const char* filename,
const char* path)
{
DcmDataset& dataset = *dicom.getDataset();
OFCondition result;
OFString id;
E_DirRecType type;
switch (level)
{
case ResourceType_Patient:
result = dataset.findAndGetOFString(DCM_PatientID, id);
type = ERT_Patient;
break;
case ResourceType_Study:
result = dataset.findAndGetOFString(DCM_StudyInstanceUID, id);
type = ERT_Study;
break;
case ResourceType_Series:
result = dataset.findAndGetOFString(DCM_SeriesInstanceUID, id);
type = ERT_Series;
break;
case ResourceType_Instance:
result = dataset.findAndGetOFString(DCM_SOPInstanceUID, id);
type = ERT_Image;
break;
default:
throw OrthancException(ErrorCode_InternalError);
}
if (!result.good())
{
throw OrthancException(ErrorCode_InternalError);
}
IndexKey key = std::make_pair(level, std::string(id.c_str()));
Index::iterator it = index_.find(key);
if (it != index_.end())
{
target = it->second;
return false; // Already existing
}
std::auto_ptr<DcmDirectoryRecord> record(new DcmDirectoryRecord(type, NULL, filename));
switch (level)
{
case ResourceType_Patient:
FillPatient(*record, dataset);
break;
case ResourceType_Study:
FillStudy(*record, dataset);
break;
case ResourceType_Series:
FillSeries(*record, dataset);
break;
case ResourceType_Instance:
FillInstance(*record, dataset, *dicom.getMetaInfo(), path);
break;
default:
throw OrthancException(ErrorCode_InternalError);
}
if (record->isAffectedBySpecificCharacterSet())
{
copyElementType1C(dataset, DCM_SpecificCharacterSet, *record);
}
target = record.get();
GetRoot().insertSub(record.release());
index_[key] = target;
return true; // Newly created
}
示例12: getById
EntityHandle getById(const std::string & idString) const {
Impl::Index::const_iterator i = m_index.find(idString);
return (i != m_index.end()) ? i->second->index() : EntityHandle::Invalid;
}
示例13: infer
// infer until fixpoint, which may not be appropriate in the presence of retraction
void infer(vector<Rule> &rules) {
bool changed = true;
map<constint_t, size_t> sizes;
map<constint_t, Index>::const_iterator atomit = atoms.begin();
for (; atomit != atoms.end(); ++atomit) {
sizes[atomit->first] = atomit->second.size();
}
size_t ncycles = 0;
while (changed) {
cerr << " Cycle " << ++ncycles << "..." << endl;
changed = false;
#ifndef ANY_ORDER
Index assertions (Order(0, 1, 2));
Index retractions (Order(0, 1, 2));
#endif
int rulecount = 0;
vector<Rule>::iterator rule = rules.begin();
for (; rule != rules.end(); ++rule) {
cerr << " Rule " << (rule - rules.begin()) + 1 << "..." << endl;
#ifdef ANY_ORDER
Index assertions (Order(0, 1, 2));
Index retractions (Order(0, 1, 2));
#endif
Relation results;
set<varint_t> allvars;
query(rule->condition, allvars, results);
act(rule->action_block, results, assertions, retractions);
#ifndef ANY_ORDER
}
#endif
size_t nretractions = 0;
Index::iterator it = retractions.begin();
for (; it != retractions.end(); ++it) {
if (idxspo.erase(*it) > 0) {
idxpos.erase(*it);
idxosp.erase(*it);
changed = true;
++nretractions;
}
}
cerr << " " << nretractions << " retractions, ";
size_t nassertions = 0;
it = assertions.begin();
for (; it != assertions.end(); ++it) {
if (idxspo.insert(*it).second) {
idxpos.insert(*it);
idxosp.insert(*it);
changed = true;
++nassertions;
}
}
cerr << nassertions << " assertions." << endl;
#ifdef ANY_ORDER
}
#endif
atomit = atoms.begin();
for (; atomit != atoms.end(); ++atomit) {
changed = changed || sizes[atomit->first] != atomit->second.size();
sizes[atomit->first] = atomit->second.size();
}
}