|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.python.core.PyObject
org.python.core.PySequence
org.python.core.PyArray
public class PyArray
A wrapper class around native java arrays. Instances of PyArray are created either by java functions or directly by the jarray module.
See also the jarray module.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.python.core.PyObject |
---|
PyObject.ConversionException |
Field Summary | |
---|---|
static PyType |
TYPE
|
Constructor Summary | |
---|---|
PyArray(Class<?> type,
int n)
|
|
PyArray(Class<?> type,
Object data)
|
|
PyArray(PyArray toCopy)
|
|
PyArray(PyType type)
|
Method Summary | |
---|---|
PyObject |
__add__(PyObject other)
Equivalent to the standard Python __add__ method |
PyObject |
__iadd__(PyObject other)
Equivalent to the standard Python __iadd__ method |
PyObject |
__imul__(PyObject o)
Equivalent to the standard Python __imul__ method |
int |
__len__()
Length of the array |
PyObject |
__mul__(PyObject o)
Equivalent to the standard Python __mul__ method |
PyObject |
__reduce__()
Used for pickling. |
PyObject |
__rmul__(PyObject o)
Equivalent to the standard Python __rmul__ method |
Object |
__tojava__(Class<?> c)
Equivalent to the Jython __tojava__ method. |
void |
append(PyObject value)
Append new value x to the end of the array. |
PyObject |
array___iter__()
|
void |
array_append(PyObject value)
|
void |
array_byteswap()
|
int |
array_count(PyObject value)
|
void |
array_extend(PyObject iterable)
|
void |
array_fromfile(PyObject f,
int count)
|
void |
array_fromlist(PyObject obj)
|
int |
array_index(PyObject value)
|
void |
array_insert(int index,
PyObject value)
|
PyObject |
array_pop(int i)
|
void |
array_remove(PyObject value)
|
void |
array_reverse()
|
void |
array_tofile(PyObject f)
|
PyObject |
array_tolist()
|
PyObject |
array_tostring()
|
PyObject |
array_tounicode()
|
void |
array_write(PyObject f)
|
static PyArray |
array(PyObject seq,
char typecode)
|
static PyArray |
array(PyObject init,
Class<?> ctype)
Create a PyArray storing ctype types and being initialised with initialiser. |
void |
byteswap()
"Byteswap" all items of the array. |
static Class<?> |
char2class(char type)
Converts a character code for the array type to a Java Class . |
Object |
clone()
Implementation of Cloneable interface. |
PyInteger |
count(PyObject value)
Return the number of occurrences of x in the array. |
void |
extend(PyObject iterable)
Append items from iterable to the end of the array. |
void |
fromfile(PyObject f,
int count)
Read count items (as machine values) from the file object f and append them to the end of the array. |
void |
fromlist(PyObject obj)
Append items from the list. |
void |
fromstring(String input)
|
void |
fromunicode(PyUnicode input)
|
Object |
getArray()
Return the internal Java array storage of the PyArray instance |
int |
getItemsize()
Getter for the storage size of the array's type. |
int |
getStorageSize()
|
String |
getTypecode()
Getter for the type code of the array. |
PyObject |
index(PyObject value)
Return the smallest i such that i is the index of the first occurrence of value in the array. |
void |
insert(int index,
PyObject value)
Insert a new item with value value in the array before position index. |
PyObject |
pop()
Removes the item with the index index from the array and returns it. |
PyObject |
pop(int index)
Removes the item with the index index from the array and returns it. |
void |
remove(PyObject value)
Remove the first occurrence of value from the array. |
void |
reverse()
Reverse the elements in the array |
void |
set(int i,
char value)
|
void |
set(int i,
int value)
|
void |
set(int i,
PyObject value)
Set an element in the array - the index needs to exist, this method does not automatically extend the array. |
void |
tofile(PyObject f)
Write all items (as machine values) to the file object f. |
PyObject |
tolist()
Convert the array to an ordinary list with the same items. |
String |
tostring()
Convert the array to an array of machine values and return the string representation (the same sequence of bytes that would be written to a file by the tofile() method.) |
String |
toString()
|
String |
tounicode()
|
static PyArray |
zeros(int n,
char typecode)
|
static PyArray |
zeros(int n,
Class<?> ctype)
|
Methods inherited from class org.python.core.PySequence |
---|
__delitem__, __delslice__, __eq__, __finditem__, __finditem__, __ge__, __getitem__, __getslice__, __gt__, __iter__, __le__, __lt__, __ne__, __nonzero__, __setitem__, __setitem__, __setslice__, isMappingType, isNumberType, isSequenceType |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final PyType TYPE
Constructor Detail |
---|
public PyArray(PyType type)
public PyArray(Class<?> type, Object data)
public PyArray(Class<?> type, int n)
public PyArray(PyArray toCopy)
Method Detail |
---|
public static PyArray zeros(int n, char typecode)
public static PyArray zeros(int n, Class<?> ctype)
public static PyArray array(PyObject seq, char typecode)
public static PyArray array(PyObject init, Class<?> ctype)
init
- an initialiser for the array - can be PyString or PySequence
(including PyArray) or iterable type.ctype
- Class
type of the elements stored in the array.
public PyObject array___iter__()
public PyObject __imul__(PyObject o)
PyObject
__imul__
in class PyObject
o
- the object to perform this binary operation with
(the right-hand operand).
public PyObject __mul__(PyObject o)
PyObject
__mul__
in class PyObject
o
- the object to perform this binary operation with
(the right-hand operand).
public PyObject __rmul__(PyObject o)
PyObject
__rmul__
in class PyObject
o
- the object to perform this binary operation with
(the left-hand operand).
public PyObject __iadd__(PyObject other)
PyObject
__iadd__
in class PyObject
other
- the object to perform this binary operation with
(the right-hand operand).
public PyObject __add__(PyObject other)
PyObject
__add__
in class PyObject
other
- the object to perform this binary operation with
(the right-hand operand).
public int __len__()
__len__
in class PyObject
public PyObject __reduce__()
PyObject
__reduce__
in class PyObject
public String toString()
toString
in class PyObject
public Object __tojava__(Class<?> c)
PyObject
Py.NoConversion
if this PyObject
can not be converted to the
desired Java class.
__tojava__
in class PySequence
c
- target Class for the conversion
public final void array_append(PyObject value)
public void append(PyObject value)
value
- item to be appended to the arraypublic void array_byteswap()
public void byteswap()
public Object clone()
clone
in class Object
public static Class<?> char2class(char type) throws PyIgnoreMethodTag
Class
.
The following character codes and their native types are supported:Type code | native type |
z | boolean |
c | char |
b | byte |
h | short |
i | int |
l | long |
f | float |
d | double |
type
- character code for the array type
Class
of the native type
PyIgnoreMethodTag
public final int array_count(PyObject value)
public PyInteger count(PyObject value)
value
- instances of the value to be counted
public final void array_extend(PyObject iterable)
public void extend(PyObject iterable)
iterable
- iterable object used to extend the arraypublic final void array_fromfile(PyObject f, int count)
public void fromfile(PyObject f, int count)
f
- Python builtin file object to retrieve datacount
- number of array elements to readpublic final void array_fromlist(PyObject obj)
public void fromlist(PyObject obj)
obj
- input list object that will be appended to the arraypublic void fromstring(String input)
public void fromunicode(PyUnicode input)
public Object getArray() throws PyIgnoreMethodTag
Array
store.
PyIgnoreMethodTag
public int getItemsize()
Type | Size |
boolean |
1 |
byte |
1 |
char |
1 |
short |
2 |
int |
4 |
long |
8 |
float |
4 |
double |
8 |
public int getStorageSize()
public String getTypecode()
char2class
describes the possible type codes
and their meaning.
public final int array_index(PyObject value)
public PyObject index(PyObject value)
value
- value to find the index of
public final void array_insert(int index, PyObject value)
public void insert(int index, PyObject value)
index
- insert positionvalue
- value to be inserted into arraypublic final PyObject array_pop(int i)
public PyObject pop()
public PyObject pop(int index)
index
- array location to be popped from the array
public final void array_remove(PyObject value)
public void remove(PyObject value)
value
- array value to be removedpublic final void array_reverse()
public void reverse()
public void set(int i, PyObject value)
AbstractArray.setSize()
or
AbstractArray.ensureCapacity()
for ways to extend capacity.
This code specifically checks for overflows of the integral types: byte,
short, int and long.
i
- index of the element to be setvalue
- value to set the element topublic void set(int i, int value)
public void set(int i, char value)
public final void array_tofile(PyObject f)
public void array_write(PyObject f)
public void tofile(PyObject f)
f
- Python builtin file object to write datapublic final PyObject array_tolist()
public PyObject tolist()
public final PyObject array_tostring()
public String tostring()
tofile()
method.)
public String tounicode()
public final PyObject array_tounicode()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |