MCPcopy Create free account
hub / github.com/chokkan/crfsuite / SwigPyIteratorClosed_T

Class SwigPyIteratorClosed_T

swig/python/export_wrap.cpp:4505–4559  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4503 typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
4504 typename FromOper = from_oper<ValueType> >
4505 class SwigPyIteratorClosed_T : public SwigPyIterator_T<OutIterator>
4506 {
4507 public:
4508 FromOper from;
4509 typedef OutIterator out_iterator;
4510 typedef ValueType value_type;
4511 typedef SwigPyIterator_T<out_iterator> base;
4512 typedef SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper> self_type;
4513
4514 SwigPyIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, PyObject *seq)
4515 : SwigPyIterator_T<OutIterator>(curr, seq), begin(first), end(last)
4516 {
4517 }
4518
4519 PyObject *value() const {
4520 if (base::current == end) {
4521 throw stop_iteration();
4522 } else {
4523 return from(static_cast<const value_type&>(*(base::current)));
4524 }
4525 }
4526
4527 SwigPyIterator *copy() const
4528 {
4529 return new self_type(*this);
4530 }
4531
4532 SwigPyIterator *incr(size_t n = 1)
4533 {
4534 while (n--) {
4535 if (base::current == end) {
4536 throw stop_iteration();
4537 } else {
4538 ++base::current;
4539 }
4540 }
4541 return this;
4542 }
4543
4544 SwigPyIterator *decr(size_t n = 1)
4545 {
4546 while (n--) {
4547 if (base::current == begin) {
4548 throw stop_iteration();
4549 } else {
4550 --base::current;
4551 }
4552 }
4553 return this;
4554 }
4555
4556 private:
4557 out_iterator begin;
4558 out_iterator end;
4559 };
4560
4561 template<typename OutIter>
4562 inline SwigPyIterator*

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected