46 |
46 |
<i>input</i> port and sends one of its elements to the <i>output</i>
|
47 |
47 |
port. The element that is extracted is determined by the
|
48 |
48 |
<i>index</i> parameter (or port). It is required that
|
49 |
|
0 <= <i>index</i> < <i>N</i>, where <i>N</i> is the
|
|
49 |
<i>-N</i> <= <i>index</i> < <i>N</i>, where <i>N</i> is the
|
50 |
50 |
length of the input array, or
|
51 |
|
an exception will be thrown by the fire() method.
|
|
51 |
an exception will be thrown by the fire() method. If negative, the
|
|
52 |
sum of the index and length of the input array will be used.
|
|
53 |
(e.g. -2 is the second to last element).
|
52 |
54 |
|
53 |
55 |
@see LookupTable
|
54 |
56 |
@see RecordDisassembler
|
... | ... | |
85 |
87 |
|
86 |
88 |
/** The index into the input array. This is an integer that
|
87 |
89 |
* defaults to 0, and is required to be less than or equal to the
|
88 |
|
* length of the input array. If the port is left unconnected,
|
89 |
|
* then the parameter value will be used.
|
|
90 |
* length of the input array. If negative, the sum of the index and
|
|
91 |
* array length will be used. If the port is left unconnected, then
|
|
92 |
* the parameter value will be used.
|
90 |
93 |
*/
|
91 |
94 |
public PortParameter index;
|
92 |
95 |
|
... | ... | |
129 |
132 |
if (input.hasToken(0)) {
|
130 |
133 |
ArrayToken token = (ArrayToken) input.get(0);
|
131 |
134 |
|
|
135 |
// Allow for indexing from the end too.
|
|
136 |
if (indexValue < 0) {
|
|
137 |
indexValue += token.length();
|
|
138 |
}
|
|
139 |
|
132 |
140 |
if ((indexValue < 0) || (indexValue >= token.length())) {
|
133 |
141 |
throw new IllegalActionException(this, "index " + indexValue
|
134 |
142 |
+ " is out of range for the input "
|