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

Class SwigPySequence_Cont

swig/python/export_wrap.cpp:4721–4806  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4719
4720 template <class T>
4721 struct SwigPySequence_Cont
4722 {
4723 typedef SwigPySequence_Ref<T> reference;
4724 typedef const SwigPySequence_Ref<T> const_reference;
4725 typedef T value_type;
4726 typedef T* pointer;
4727 typedef int difference_type;
4728 typedef int size_type;
4729 typedef const pointer const_pointer;
4730 typedef SwigPySequence_InputIterator<T, reference> iterator;
4731 typedef SwigPySequence_InputIterator<T, const_reference> const_iterator;
4732
4733 SwigPySequence_Cont(PyObject* seq) : _seq(0)
4734 {
4735 if (!PySequence_Check(seq)) {
4736 throw std::invalid_argument("a sequence is expected");
4737 }
4738 _seq = seq;
4739 Py_INCREF(_seq);
4740 }
4741
4742 ~SwigPySequence_Cont()
4743 {
4744 Py_XDECREF(_seq);
4745 }
4746
4747 size_type size() const
4748 {
4749 return static_cast<size_type>(PySequence_Size(_seq));
4750 }
4751
4752 bool empty() const
4753 {
4754 return size() == 0;
4755 }
4756
4757 iterator begin()
4758 {
4759 return iterator(_seq, 0);
4760 }
4761
4762 const_iterator begin() const
4763 {
4764 return const_iterator(_seq, 0);
4765 }
4766
4767 iterator end()
4768 {
4769 return iterator(_seq, size());
4770 }
4771
4772 const_iterator end() const
4773 {
4774 return const_iterator(_seq, size());
4775 }
4776
4777 reference operator[](difference_type n)
4778 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected