本文整理汇总了C++中Iterator函数的典型用法代码示例。如果您正苦于以下问题:C++ Iterator函数的具体用法?C++ Iterator怎么用?C++ Iterator使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Iterator函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Base_Timer_Queue
ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::ACE_Timer_List_T (FUNCTOR* uf,
FreeList* fl,
TIME_POLICY const & time_policy)
: Base_Timer_Queue (uf, fl, time_policy)
, head_ (new ACE_Timer_Node_T<TYPE>)
, id_counter_ (0)
{
ACE_TRACE ("ACE_Timer_List_T::ACE_Timer_List_T");
this->head_->set_next (this->head_);
this->head_->set_prev (this->head_);
ACE_NEW (iterator_, Iterator(*this));
}
示例2: Find
//non constant version of find
Iterator Find(const T& value)
{
uint32_t hidx=getIndex(&value);
Node** nodePtr=&hash[hidx];
if(!*nodePtr)return Iterator(0);
if(TRAITS::isEqual((*nodePtr),&value))
{
return Iterator(this,hidx,*nodePtr,nodePtr);
}
Node** parentPtr=nodePtr;
Node* node=(Node*)(*nodePtr)->ihsNextNode;
while(node)
{
if(TRAITS::isEqual(node,&value))
{
return Iterator(this,hidx,node,parentPtr);
}
parentPtr=nodePtr;
nodePtr=(Node**)&node->ihsNextNode;
node=(Node*)node->ihsNextNode;
}
return Iterator(0);
}
示例3: make_filter_iterator
filter_iterator<Predicate,Iterator>
make_filter_iterator(
typename iterators::enable_if<
is_class<Predicate>
, Iterator
>::type x
, Iterator end = Iterator()
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
, Predicate* = 0
#endif
)
{
return filter_iterator<Predicate,Iterator>(x,end);
}
示例4: UpdateTimedCallbacks
// Updates the timed callback functions
void _Scripting::UpdateTimedCallbacks() {
for(std::list<TimedCallbackStruct>::iterator Iterator(TimedCallbacks.begin()); Iterator != TimedCallbacks.end(); ++Iterator) {
if(PlayState.GetTimer() >= (*Iterator).TimeStamp) {
Scripting.CallFunction((*Iterator).Function);
// Remove callback
Iterator = TimedCallbacks.erase(Iterator);
if(Iterator == TimedCallbacks.end())
break;
}
else
return;
}
}
示例5: token_
XmlReader::XmlReader(std::string const& filepath) :
token_(token_none), is_empty_element(false)
{
std::ifstream stream(filepath, std::ios::binary);
if (!stream)
{
throw std::runtime_error("cannot open file " + filepath);
}
stream.unsetf(std::ios::skipws);
stream.seekg(0, std::ios::end);
std::size_t size = static_cast<std::size_t>(stream.tellg());
stream.seekg(0);
buffer.resize(size + 1);
cursor = marker = Iterator(buffer.begin());
stream.read(&buffer[0], static_cast<std::streamsize>(size));
buffer[size] = 0;
}
示例6: test
void test() {
NodePtr hello = new Leaf("hello");
NodePtr world = new Leaf("world");
//check_node(hello);
NodePtr hw = hello->concat_with(world);
//hw->debug_print();
check_node(hw);
//concatenation
for (int i = 0; i<100; i++) {
if (i%20 == 0)
std::cout<<i<<std::endl;
hw = hw->concat_with(hello);
//hw->debug_print();
assert(check_node(hw));
}
assert(check_node(hw));
hw->debug_print();
//random access
for (int i = 0; i<100; i++) {
Iterator iter = Iterator(hw);
int pos = 0;
std::string s = hw->as_string();
while (pos < hw->length()) {
//std::cout<<pos<<" ";
assert(s[pos] == iter.current());
int d = rand()%100;
pos += d;
iter.advance(d);
}
assert(!iter.valid);
//std::cout<<std::endl;
}
//slices
for (int i = 0; i<100; i++) {
int begin = rand()%(hw->length()+1);
int end = begin+rand()%(hw->length()-begin+1);
NodePtr slice = hw->slice(begin, end);
assert(check_node(slice));
std::cout<<begin<<" "<<end<<std::endl;
}
std::cout<<"hw depth "<<hw->depth()<<std::endl;
}
示例7: getTwiddleFactors
namespace sfft { namespace detail
{
template<typename T>
std::vector<std::complex<T> > getTwiddleFactors(size_t N, bool fwd,
size_t Lm1Qm1 = std::numeric_limits<size_t>::max)
{
std::vector<std::complex<T> > factors(std::min(N, Lm1Qm1));
if(factors.size() > 0)
{
factors[0] = 1;
if(factors.size() > 1)
{
// Use high-precision multiplication of phasors.
typedef std::complex<long double> HighPrecComplex;
long double phase = 2*3.14159265358979323846/N;
HighPrecComplex phasor(cos(phase), fwd ? -sin(phase) : sin(phase));
HighPrecComplex tmp(phasor);
factors[1] = tmp;
for(size_t i = 2; i < factors.size(); ++i)
factors[i] = tmp = tmp * phasor;
}
}
return factors;
}
} // namespace detail
template<typename Iterator>
using DereferencedType = typename std::remove_reference<decltype(*(Iterator()))>::type;
template<typename T>
struct Twiddler
{
Twiddler(size_t N_, bool fwd,
size_t Lm1Qm1 = std::numeric_limits<size_t>::max())
:factors(detail::getTwiddleFactors<T>(N_, fwd, Lm1Qm1)),
N(N_) {}
const std::vector<std::complex<T> > factors;
const size_t N;
};
} //namespace sfft
示例8: mapping_iterator
namespace maxwell {
/// \needsdoc
template<class Iterator, class Mapping>
class mapping_iterator : public Iterator {
public:
typedef mapping_iterator self;
typedef Iterator iterator_type;
typedef Mapping mapping_type;
typedef typename Mapping::result_type result_type;
explicit mapping_iterator(Mapping m): mapping(m) {}
explicit mapping_iterator(Iterator it): Iterator(it) {}
mapping_iterator(Iterator it, Mapping m): Iterator(it), mapping(m) {}
result_type operator*() const { return mapping(Iterator::operator*()); }
result_type operator->() const { return mapping(Iterator::operator->()); }
private:
mapping_type mapping;
};
/// \needsdoc
template<class T>
struct dereference {
typedef T argument_type;
typedef decltype(*T(nullptr)) result_type;
result_type operator() (T const& x) const { return *x; }
};
/// \needsdoc
template<class Iterator>
using dereferencing_iterator = mapping_iterator<Iterator, dereference<
typename std::remove_reference<decltype(*Iterator())>::type>
>;
} // namespace maxwell
示例9: erase_after
Iterator erase_after(const Iterator& it)
{
auto target = it.ptr->next ;
it.ptr->next = target->next;
if(last == target)
{
last = target->next;
if(last == nullptr)
{
first = nullptr;
}
}
delete target;
return Iterator(it.ptr->next);
}
示例10: main
int main(int, char* [] )
{
typedef itk::Image<unsigned char, 2> ImageType;
ImageType::Pointer image = ImageType::New();
itk::Index<2> corner = {{0,0}};
itk::Size<2> size = {{10,10}};
itk::ImageRegion<2> region(corner,size);
image->SetRegions(region);
image->Allocate();
unsigned int counter = 0; // To make sure the loop isn't optimized away
for(unsigned int i = 0; i < 1e7; ++i)
{
counter += Iterator(image.GetPointer()); // about 7.2 seconds
// counter += IteratorWithIndex(image.GetPointer()); // about 2.6 seconds
}
std::cout << "counter " << counter << std::endl; // To make sure the loop isn't optimized away
return 0;
}
示例11: find
Iterator find(const Key_T &key)
{
Node* current_node;
Node* fallback_node = levels;
for(int i = (MaxLevel - 1); i >= 0; i--)
{
current_node = fallback_node;
while(current_node != NULL)
{
fallback_node = current_node;
if(current_node->nodes[i] == NULL || current_node->nodes[i]->dataPair.first > key)
break; // Next string on this node
else if (current_node->nodes[i]->dataPair.first == key)
return Iterator(current_node->nodes[i]);
else if(current_node->nodes[i]->dataPair.first < key)
current_node = current_node->nodes[i];
}
}
return NULL;
}
示例12: find_next_node_breadth
void SceneGraph::Iterator::
find_next_node_breadth() {
if (breadth_nodes_.empty()) {
Iterator end;
for (Iterator it(start_node_); it != end; ++it)
breadth_nodes_[it.get_depth()].push_back(it.current_node_);
}
auto end(breadth_nodes_[current_depth_].end());
for (auto node(breadth_nodes_[current_depth_].begin());
node != end; ++node) {
if (*node == current_node_) {
if (++node != end) {
current_node_ = *node;
} else if (++current_depth_ < breadth_nodes_.size()) {
current_node_ = breadth_nodes_[current_depth_].front();
} else *this = Iterator();
break;
}
}
}
示例13: begin
Iterator begin() const {
return Iterator(*this);
}
示例15: begin
Iterator begin()
{
return Iterator(first);
}