org.python.core
public class PyArray extends PySequence implements Cloneable
See also the jarray module.
Field Summary | |
---|---|
static Class | exposed_base |
static String | exposed_name |
Constructor Summary | |
---|---|
PyArray(PyType type) | |
PyArray(PyArray toCopy) | |
PyArray(Class type, Object data) | |
PyArray(Class type, int n) |
Method Summary | |
---|---|
void | append(PyObject value)
Append new value x to the end of the array.
|
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 | array_append(PyObject value) |
void | array_byteswap() |
int | array_count(PyObject value) |
void | array_extend(PyObject iterable) |
void | array_fromlist(PyObject obj) |
int | array_index(PyObject value) |
void | array_insert(int index, PyObject value) |
PyObject | array_pop() |
PyObject | array_pop(int i) |
void | array_remove(PyObject value) |
void | array_reverse() |
void | array_tofile(PyObject f) |
PyObject | array_tolist() |
PyObject | array_tostring() |
void | array_write(PyObject f) |
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)
Appends items from the string, interpreting the string as an array of
machine values (as if it had been read from a file using the
fromfile() method).
|
Object | getArray()
Return the internal Java array storage of the PyArray instance
|
int | getItemsize()
Getter for the storage size of the array's type.
|
String | getTypecode()
Getter for the type code of the array.
char2class describes the possible type codes
and their meaning.
|
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 | 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.) |
static void | typeSetup(PyObject dict, PyType.Newstyle marker) |
static PyArray | zeros(int n, char typecode) |
static PyArray | zeros(int n, Class ctype) |
PyObject | __add__(PyObject other)
Adds (appends) two PyArrays together
|
PyObject | __findattr__(String name)
Finds the attribute.
|
int | __len__()
Length of the array
|
PyString | __repr__()
String representation of PyArray
|
Object | __tojava__(Class c) |
Parameters: value item to be appended to the array
Parameters: 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.
Returns: a new PyArray
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 |
Parameters: type character code for the array type
Returns: Class
of the native type
Returns: copy of current PyArray
Parameters: value instances of the value to be counted
Returns: number of time value was found in the array.
Parameters: iterable iterable object used to extend the array
Parameters: f Python builtin file object to retrieve data count number of array elements to read
Parameters: obj input list object that will be appended to the array
fromfile()
method).
Parameters: input string of bytes containing array data
Returns: the Array
store.
Type | Size |
boolean |
1 |
byte |
1 |
char |
1 |
short |
2 |
int |
4 |
long |
8 |
float |
4 |
double |
8 |
Returns: number of bytes used to store array type.
char2class
describes the possible type codes
and their meaning.
Returns: single character type code for the array
Parameters: value value to find the index of
Returns: index of the first occurance of value
Parameters: index insert position value value to be inserted into array
Parameters: index array location to be popped from the array
Returns: array element popped from index
Parameters: value array value to be removed
Parameters: f Python builtin file object to write data
Returns: array contents as a list
tofile()
method.)Parameters: other a PyArray to be added to the instance
Returns: the result of the addition as a new PyArray instance
Parameters: name the name of the attribute of interest
Returns: the value for the attribute of the specified name
Returns: number of elements in the array
Returns: string representation of PyArray
Parameters: c target Class for the conversion
Returns: Java object converted to required class type if possible.