Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78649789
aka_csr.i
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Aug 22, 04:33
Size
1 KB
Mime Type
text/x-python
Expires
Sat, Aug 24, 04:33 (2 d)
Engine
blob
Format
Raw Data
Handle
19907250
Attached To
rAKA akantu
aka_csr.i
View Options
%{
#include "aka_csr.hh"
%}
namespace akantu {
%ignore CSR::begin;
}
%inline %{
namespace akantu{
template <typename T>
class CSRIterator{
public:
CSRIterator(CSR<T> & csr,UInt row) {
this->it = csr.begin(row);
this->end = csr.end(row);
};
~CSRIterator(){
};
T & __next_cpp(){
if (this->it == this->end) AKANTU_SILENT_EXCEPTION("StopIteration");
T & ref = *(this->it);
++this->it;
return ref;
}
private:
typename CSR<T>::iterator it;
typename CSR<T>::iterator end;
};
}
%}
%extend akantu::CSRIterator<akantu::Element>
{
%insert("python") %{
def __iter__(self):
return self
def __next__(self):
try:
return self.__next_cpp()
except Exception as e:
raise StopIteration
def next(self):
return self.__next__()
%}
}
%extend akantu::CSR<akantu::Element>
{
akantu::CSRIterator<akantu::Element> row(akantu::UInt row){
return akantu::CSRIterator<akantu::Element>(*$self,row);
}
}
%include "aka_csr.hh"
namespace akantu {
%template (CSRUInt) CSR<UInt>;
%template (CSRElement) CSR<Element>;
%template (CSRIteratorElement) CSRIterator<Element>;
}
Event Timeline
Log In to Comment