public abstract class Series
extends java.lang.Object
Values
, is like the standard Java
Enumeration and Iterator but with simpler semantics. The most
important methods are elt()
, hasSome()
and
advance()
. A Series has state, and is eventually used up.
Also see Value.Scannable
– something that
implements Scannable can produce a Series, repeatedly.Modifier and Type | Class and Description |
---|---|
static class |
Series.Discrete
Series producing Discrete Values.
|
static class |
Series.Int
Series producing Int Values.
|
static class |
Series.Lines
Series of lines (
Value.Chars , strings) from an
input stream of byte such as a FileInputStream, say. |
static class |
Series.Range
Series of Ints from 'fst' inclusive, to 'ovr' exclusive, with
an optional 'step' (default is 1) which may be negative.
|
static class |
Series.Separator
A Series of "comma"-separated variables (CSV) as Chars (strings) out
of a String, s.
|
Modifier and Type | Field and Description |
---|---|
static Series |
EMPTY
The EMPTY Series always
hasNone() . |
Constructor and Description |
---|
Series() |
Modifier and Type | Method and Description |
---|---|
abstract void |
advance()
Advance past the current element -- there might or might not
be any more; also see
hasSome() . |
void |
advance(int n)
Advance past 'n' elements (an error if impossible).
|
void |
advanceTo(int n)
Advance to position 'n' (an error if impossible).
|
Series |
append(Series s2)
Series of elements from 'this' until exhausted, then from 's2'.
|
Value.List |
asList()
Return a
List of elements in 'this' Series;
beware, do not share the Series because a Series has
side-effects but a List does not. |
abstract Value |
elt()
Return the current element, if there is one, but do
not
advance() . |
void |
error(java.lang.String msg)
Throw a RuntimeException.
|
void |
exhaust()
|
static Series.Int |
fromInts(int[] ns) |
static Series |
fromVector(Vector v) |
boolean |
hasNone()
For convenience -- return not
hasSome() . |
abstract boolean |
hasSome()
|
static void |
main(java.lang.String[] args) |
Series |
merge(boolean keepShared,
Series s2)
Merge the outputs of 'this' and 's2' in ascending order.
|
Series |
merge(Series s2)
merge(true,s2) , i.e.,
keep elements shared by 'this' and 's2'. |
abstract int |
position()
What position in the Series are we at (starting at zero)?
If
hasNone() , the series was finite and position()
is now its length. |
static Series |
singleton(Value v)
The Series of just one element.
|
java.lang.String |
toString()
Return a short String description of 'this' Series,
say for use in debugging.
|
static Series |
values(Value[] arr)
Series of elements from an array of Values, one at a time.
|
double |
wt()
Return the weight of the current element; this default
gives 1.0.
|
public abstract boolean hasSome()
public boolean hasNone()
hasSome()
.public abstract int position()
hasNone()
, the series was finite and position()
is now its length.public abstract Value elt()
public double wt()
Vector.wt(int)
.public abstract void advance()
hasSome()
.public void advance(int n)
public void advanceTo(int n)
public void exhaust()
public Value.List asList()
List
of elements in 'this' Series;
beware, do not share the Series because a Series has
side-effects but a List does not.public java.lang.String toString()
toString
in class java.lang.Object
public static Series.Int fromInts(int[] ns)
public Series append(Series s2)
public Series merge(Series s2)
merge(true,s2)
, i.e.,
keep elements shared by 'this' and 's2'.public Series merge(boolean keepShared, Series s2)
public static Series singleton(Value v)
values(arr)
public static Series values(Value[] arr)
Vector.toSeries()
.public void error(java.lang.String msg)
position()
, the toString() of
'this' Series and 'msg'.public static void main(java.lang.String[] args)