Package gnu.mapping
Class Values<E>
- java.lang.Object
-
- gnu.lists.AbstractSequence<E>
-
- gnu.mapping.Values<E>
-
- All Implemented Interfaces:
Consumable,java.io.Externalizable,java.io.Serializable
- Direct Known Subclasses:
Values.FromArray,Values.FromList,Values.FromTreeList,Values.Values2
public abstract class Values<E> extends AbstractSequence<E> implements Consumable, java.io.Externalizable
Encapsulate multiple values in a single object. In Scheme and Lisp mainly used to return multiple values from a function. In XQuery used to represent a non-singleton sequence.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classValues.FromArray<E>An implementation of Values that stores the values in an array.static classValues.FromList<E>An implementation of Values that uses a java.util.List.static classValues.FromTreeListAn implementation of Values that uses a TreeList.static classValues.Values2<E,V1 extends E,V2 extends E>A specialization of Values for exactly 2 values.
-
Field Summary
Fields Modifier and Type Field Description static Valuesemptystatic java.lang.Object[]noArgs-
Fields inherited from class gnu.lists.AbstractSequence
noInts
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedValues()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectcall_with(Procedure proc)Apply a Procedure with these values as the arguments.java.lang.Objectcanonicalize()If a simple value, return that value.static voidcheckFinalPos(java.lang.Object values, int pos)static intcountValues(java.lang.Object value)static java.lang.ObjectgetFromPos(java.lang.Object values, int pos)static java.lang.ObjectgetFromPosFinal(java.lang.Object values, int pos)java.lang.Object[]getValues()Get the values encapsulated.static intincrPos(java.lang.Object values, int pos)static Valuesmake()static <E> java.lang.Objectmake(E[] vals)Create a value for each element of an array.static java.lang.Objectmake(TreeList list, int startPosition, int endPosition)Extract a value (single or Values) from a sub-range of a TreeList.static <E> java.lang.Objectmake(java.util.List<E> seq)Create a value for each element of a list.static <E> Values<E>makeFromArray(E... vals)protected intnextIndex(int ipos)Get the offset from the beginning corresponding to a position cookie.static intnextIndex(java.lang.Object values, int curIndex)Helper method called by compiled code.static java.lang.ObjectnextValue(java.lang.Object values, int curIndex)Helper method called by compiled code.voidprint(Consumer out)java.lang.ObjectreadResolve()static java.lang.Objectvalues(java.lang.Object... vals)static <E,V1 extends E,V2 extends E>
Values.Values2<E,V1,V2>values2(V1 val1, V2 val2)voidwriteExternal(java.io.ObjectOutput out)static voidwriteValues(java.lang.Object value, Consumer out)-
Methods inherited from class gnu.lists.AbstractSequence
add, add, addAll, addAll, addPos, asImmutable, badRank, boundedHash, checkCanWrite, checkRank, clear, compare, compare, compare, consume, consume, consumeNext, consumePosRange, contains, containsAll, copyPos, createPos, createRelativePos, effectiveIndex, effectiveIndex, effectiveIndex, effectiveIndex, effectiveIndex, elements, endPos, equals, equals, fill, fill, fillPosRange, firstAttributePos, firstChildPos, firstChildPos, fromEndIndex, get, get, get, get, get, getAttribute, getAttributeLength, getBooleanRaw, getByteRaw, getCharRaw, getContainingSequenceSize, getDoubleRaw, getElementKind, getFloatRaw, getIndexDifference, getInt, getInt, getInt, getInt, getInt, getIntRaw, getIterator, getIterator, getIteratorAtPos, getLongRaw, getLowBound, getNextKind, getNextTypeName, getNextTypeObject, getPosNext, getPosPrevious, getRaw, getRowMajor, getShortRaw, getSize, getSize, gotoAttributesStart, gotoChildrenStart, gotoParent, hashCode, hasNext, hasPrevious, indexOf, isAfterPos, isEmpty, iterator, lastIndexOf, listIterator, listIterator, nextIndex, nextMatching, nextPos, parentPos, previousPos, rank, releasePos, remove, remove, removeAll, removePos, removePosRange, retainAll, set, set, setAt, setBuffer, setPosNext, setPosPrevious, setRaw, size, stableCompare, startPos, subList, subSequence, subSequencePos, toArray, toArray, toString, toString, unsupported, unsupportedException
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface gnu.lists.Consumable
consume
-
-
-
-
Field Detail
-
noArgs
public static final java.lang.Object[] noArgs
-
empty
public static final Values empty
-
-
Method Detail
-
getValues
public java.lang.Object[] getValues()
Get the values encapsulated.
-
values
public static java.lang.Object values(java.lang.Object... vals)
-
values2
public static <E,V1 extends E,V2 extends E> Values.Values2<E,V1,V2> values2(V1 val1, V2 val2)
-
make
public static Values make()
-
make
public static <E> java.lang.Object make(E[] vals)
Create a value for each element of an array.- Parameters:
vals- values to use. The array should be immutable, as may be re-used for the result.
-
makeFromArray
public static <E> Values<E> makeFromArray(E... vals)
-
make
public static <E> java.lang.Object make(java.util.List<E> seq)
Create a value for each element of a list.- Parameters:
seq- values to use. The list should be immutable, as may be re-used for the result.
-
make
public static java.lang.Object make(TreeList list, int startPosition, int endPosition)
Extract a value (single or Values) from a sub-range of a TreeList.- Parameters:
list- the TreeList to copystartPosition- start of range, as a raw index in dataendPosition- end of range, as a raw index in data
-
canonicalize
public java.lang.Object canonicalize()
If a simple value, return that value. Also, if no values, return empty.
-
call_with
public java.lang.Object call_with(Procedure proc) throws java.lang.Throwable
Apply a Procedure with these values as the arguments.- Throws:
java.lang.Throwable
-
print
public void print(Consumer out)
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
writeExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
readResolve
public java.lang.Object readResolve() throws java.io.ObjectStreamException- Throws:
java.io.ObjectStreamException
-
incrPos
public static int incrPos(java.lang.Object values, int pos)
-
getFromPos
public static java.lang.Object getFromPos(java.lang.Object values, int pos)
-
getFromPosFinal
public static java.lang.Object getFromPosFinal(java.lang.Object values, int pos)
-
checkFinalPos
public static void checkFinalPos(java.lang.Object values, int pos)
-
nextIndex
public static int nextIndex(java.lang.Object values, int curIndex)Helper method called by compiled code. The compiled code iterates through zero or more values. Return the index of the next value, or -1 if currently at eof. A non-Values object is treated as a singleton value, so in that case there is no next value.
-
nextValue
public static java.lang.Object nextValue(java.lang.Object values, int curIndex)Helper method called by compiled code. The compiled code iterates through zero or more values. Extract the object referenced by the curIndex. A non-Values object is treated as a singleton value.
-
nextIndex
protected int nextIndex(int ipos)
Description copied from class:AbstractSequenceGet the offset from the beginning corresponding to a position cookie.- Overrides:
nextIndexin classAbstractSequence<E>
-
writeValues
public static void writeValues(java.lang.Object value, Consumer out)
-
countValues
public static int countValues(java.lang.Object value)
-
-