Package ptolemy.data
Class UpdatedArrayToken
- java.lang.Object
-
- ptolemy.data.Token
-
- ptolemy.data.AbstractNotConvertibleToken
-
- ptolemy.data.ArrayToken
-
- ptolemy.data.UpdatedArrayToken
-
public class UpdatedArrayToken extends ArrayToken
A token that contains an array of tokens that is equal to another specified ArrayToken except at one location, where it has a new value. This implementation keeps a reference to the other specified token and records only the diff between this modified array and the original one.This technique is inspired by a similar technique of storing diffs described by Michael Isard in a talk at Berkeley in February, 2012.
- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Edward A. Lee
- Pt.AcceptedRating:
- Red (cxh) nil token code
- Pt.ProposedRating:
- Yellow (cxh)
-
-
Field Summary
-
Fields inherited from class ptolemy.data.ArrayToken
_depth, _elementType, NIL
-
-
Constructor Summary
Constructors Constructor Description UpdatedArrayToken(ArrayToken baseToken, int index, Token newValue)
Construct an UpdatedArrayToken that is equal to the specified baseToken, except at index, where its value is newValue.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Token
getElement(int index)
Return the element at the specified index.int
length()
Return the length of the contained token array.-
Methods inherited from class ptolemy.data.ArrayToken
_add, _divide, _divideReverse, _isCloseTo, _isEqualTo, _modulo, _moduloReverse, _multiply, _subtract, _subtractReverse, add, addReverse, append, append, arrayTokenToUnsignedByteArray, arrayValue, contains, divide, divideReverse, elementAdd, elementDivide, elementModulo, elementMultiply, elementMultiplyReturnType, elementSubtract, equals, extract, getElementType, getType, hashCode, isCloseTo, isNil, modulo, moduloReverse, multiply, multiplyReverse, one, reverse, subarray, subarray, subtract, subtractReverse, toString, unsignedByteArrayToArrayToken, update, zero
-
Methods inherited from class ptolemy.data.AbstractNotConvertibleToken
isEqualTo, notSupportedDifferentClassesMessage
-
Methods inherited from class ptolemy.data.Token
isCloseTo, notSupportedConversionMessage, notSupportedIncomparableConversionMessage, notSupportedIncomparableMessage, notSupportedMessage, notSupportedNullNilStringMessage, pow, zeroReturnType
-
-
-
-
Constructor Detail
-
UpdatedArrayToken
public UpdatedArrayToken(ArrayToken baseToken, int index, Token newValue) throws IllegalActionException
Construct an UpdatedArrayToken that is equal to the specified baseToken, except at index, where its value is newValue. The type of the resulting array type is the least upper bound of the types of the elements, which is not necessarily the same as the type of the base token.- Parameters:
baseToken
- The base array.index
- The index of the new value.newValue
- The updated value.- Throws:
IllegalActionException
- If the index is out of range for the base token.
-
-
Method Detail
-
getElement
public Token getElement(int index)
Return the element at the specified index.- Overrides:
getElement
in classArrayToken
- Parameters:
index
- The index of the desired element.- Returns:
- The token contained in this array token at the specified index.
- Throws:
java.lang.ArrayIndexOutOfBoundsException
- If the specified index is outside the range of the token array.
-
length
public int length()
Return the length of the contained token array.- Overrides:
length
in classArrayToken
- Returns:
- The length of the contained token array.
-
-