public class NDList extends java.util.ArrayList<NDArray> implements java.lang.AutoCloseable
NDList
represents a sequence of NDArray
s with names.
Each NDArray
in this list can optionally have a name. You can use the name to look up
an NDArray in the NDList.
NDArray
,
Serialized FormConstructor and Description |
---|
NDList()
Constructs an empty NDList.
|
NDList(java.util.Collection<NDArray> other)
Constructs and initiates an NDList with the specified
NDArray s. |
NDList(int initialCapacity)
Constructs an empty NDList with the specified initial capacity.
|
NDList(NDArray... arrays)
Constructs and initiates an NDList with the specified
NDArray s. |
Modifier and Type | Method and Description |
---|---|
NDList |
addAll(NDList other)
Appends all of the NDArrays in the specified NDList to the end of this NDList, in the order
that they are returned by the specified NDList's iterator.
|
java.util.List<NDManager> |
attach(java.util.List<NDManager> managers)
Attaches each ndarray in this list to the specified manager.
|
java.util.List<NDManager> |
attach(NDManager manager)
Attaches each ndarray in this list to the specified manager.
|
void |
close() |
boolean |
contains(java.lang.String name)
Returns
true if this NDList contains an NDArray with the specified name. |
static NDList |
decode(NDManager manager,
byte[] byteArray)
Decodes NDList from byte array.
|
void |
detach()
Detaches each ndarray in this list from their current managers.
|
byte[] |
encode()
Encodes the NDList to byte array.
|
Shape[] |
getShapes()
Gets all of shapes in the
NDList . |
NDArray |
head()
Returns the head index of the NDList.
|
NDArray |
remove(java.lang.String name)
Removes the first occurrence of the specified element from this NDList if it is present.
|
NDArray |
singletonOrThrow()
Returns the only element if this is a singleton NDList or throws an exception if multiple
elements.
|
NDList |
subNDList(int fromIndex)
Returns a view of the portion of this NDList between the specified fromIndex, inclusive, and
to the end.
|
NDList |
toDevice(Device device,
boolean copy)
|
java.lang.String |
toString() |
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
public NDList()
public NDList(int initialCapacity)
initialCapacity
- the initial capacity of the listjava.lang.IllegalArgumentException
- if the specified initial capacity is negativepublic NDList(NDArray... arrays)
NDArray
s.arrays
- the NDArray
spublic static NDList decode(NDManager manager, byte[] byteArray)
manager
- manager assigned to NDArray
byteArray
- byte array to load fromNDList
public NDArray remove(java.lang.String name)
If this list does not contain the element, it is unchanged. More formally, removes the
element with the lowest index i
such that (o==null ? get(i)==null : o.equals(get(i)))
(if such an element exists).
name
- the name of the NDArray to be removed from this NDList, if presentpublic boolean contains(java.lang.String name)
true
if this NDList contains an NDArray with the specified name.name
- the name of the NDArray to be removed from this NDList, if presenttrue
if this list contains the specified elementpublic NDArray head()
java.lang.IndexOutOfBoundsException
- if the index is out of range (index < 0 || index
>= size()
)public NDArray singletonOrThrow()
java.lang.IndexOutOfBoundsException
- if the list does not contain exactly one elementpublic NDList addAll(NDList other)
other
- the NDList containing NDArray to be added to this listpublic NDList subNDList(int fromIndex)
fromIndex
- the start index (inclusive)public java.util.List<NDManager> attach(NDManager manager)
manager
- the manager to attach the lists toNDManager
with which original NDArray are attachedNDArray.attach(NDManager)
public java.util.List<NDManager> attach(java.util.List<NDManager> managers)
managers
- the list of managers to attachNDManager
with which original NDArray are attachedpublic void detach()
NDArray.detach()
public byte[] encode()
public Shape[] getShapes()
NDList
.NDList
public void close()
close
in interface java.lang.AutoCloseable
public java.lang.String toString()
toString
in class java.util.AbstractCollection<NDArray>