PyQwt has a partial interface to the following C++ QwtArray templates:
Those classes have at least 3 constructors - taking QwtArrayDouble as an example:
array = QwtArrayDouble()
array = QwtArrayDouble(int)
array = QwtArrayDouble(otherArray)
QwtArrayDouble and QwtArrayInt have also a constructor which takes a sequence of items convertable to a C++ double and a C++ long:
array = QwtArrayDouble(Numeric.array([0.0, 1.0]))
array = QwtArrayInt(Numeric.array([0, 1]))
All those classes have 16 member functions - taking QwtArrayDouble as example:
array = array.assign(otherArray)
item = array.at(index)
index = array.bsearch(item)
index = contains(item)
array = otherArray.copy()
result = array.count()
array.detach()
array = array.duplicate(otherArray)
bool = array.fill(item, index=-1)
index = array.find(item, index=0)
bool = array.isEmpty()
bool = array.isNull()
bool = array.resize(index)
result = array.size()
array.sort()
bool = array.truncate(index)
Iterators are not yet implemented. However, the implementation of the Python slots __getitem__, __len__ and __setitem__ let you use those classes almost as a sequence. For instance:
>>> import PyQt4.Qwt5 as Qwt >>> import numpy as NP >>> a = Qwt.QwtArrayDouble(NP.arange(10, 20, 4)) >>> for i in a: # thanks to __getitem__ ... print i ... 10.0 14.0 18.0 >>> for i in range(len(a)): # thanks to __len__ ... print a[i] # thanks to __getitem__ ... 10.0 14.0 18.0 >>> for i in range(len(a)): # thanks to __len__ ... a[i] = 10+3*i # thanks to __setitem__ ... >>> for i in a: # thanks to __getitem__ ... print i ... 10.0 13.0 16.0 >>>