SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 223 | Next

Jonathan Jacky, Margus Veanes, Colin Campbell, Wolfram Schulte

"Model-Based Software Testing and Analysis with C#"

EmptySequence;
for(int i = 0; i < 5; i += 1)
squares = squares.AddLast(i * i);
166 Modeling Systems with Structured State
You can construct a sequence from any value that supports IEnumerable:
static Sequence ConvertToSequence(IEnumerable list)
{
return new Sequence(list);
}
Sequence queries
You can access the first and last element of a sequence using the Head and Last
properties.
The subsequence of all elements except the first is the Tail. The subsequence of
all elements except the last is the Front of the sequence.
Sequence squares = new Sequence(0, 1, 4, 9, 16, 25, 36);
Assert.AreEqual(squares.Head, 0);
Assert.AreEqual(squares.Last, 36);
Assert.AreEqual(squares.Tail.Head, 1);
Assert.AreEqual(squares.Front.Last, 25);
Assert.AreEqual(squares.Tail.Tail.Head, 4);
Sequences also provide for random access using the C# indexer. However, if your
primary mode of access is random, you should consider using the ValueArray type
instead of a sequence.
10.3.4 Value arrays
A value array is an ordered collection of (possibly repeating) elements. It is similar
to the .NET Array type, except that a value array is immutable. Unlike a .NET array,
a value array uses structural equality.
Sequences and value arrays are similar in the way that .NET lists and arrays are
similar. In other words, sequences are best for list-like iterative construction and
access.


Pages:
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6