repeatStream

永遠とその配列をループし続けるストリーム

  1. auto repeatStream(const E[] array)
  2. auto repeatStream(E element)
    repeatStream
    (
    E
    )
    if (
    !is(E : T[],
    T
    )
    )

Examples

1 int[] arr = [0, 1, 2, 3, 4, 5, 6, 7];
2 auto rs = arr.repeatStream;
3 static assert(isInfinite!(typeof(rs)));
4 static assert(isInputStream!(typeof(rs)));
5 static assert(isInplaceComputableStream!(typeof(rs)));
6 static assert(isBufferedInputStream!(typeof(rs)));
7 
8 
9 int[] buf1 = new int[24];
10 assert(rs.readOp!"+"(buf1) == arr ~ arr ~ arr);
11 
12 short[] buf2 = new short[17];
13 assert(rs.readOp!"cast(short)b"(buf2) == buf1[0 .. 17]);
1 auto rs = 1.repeatStream;
2 static assert(isInfinite!(typeof(rs)));
3 static assert(isInputStream!(typeof(rs)));
4 static assert(isInplaceComputableStream!(typeof(rs)));
5 
6 assert(rs.read(new int[4]) == [1, 1, 1, 1]);

Meta