repeatStream

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

  1. auto repeatStream(E[] array)
    repeatStream
    (
    E
    )
    (
    const E[] array
    )
  2. auto repeatStream(E element)

Examples

int[] arr = [0, 1, 2, 3, 4, 5, 6, 7];
auto rs = arr.repeatStream;
static assert(isInfinite!(typeof(rs)));
static assert(isInputStream!(typeof(rs)));
static assert(isInplaceComputableStream!(typeof(rs)));
static assert(isBufferedInputStream!(typeof(rs)));


int[] buf1 = new int[24];
assert(rs.readOp!"+"(buf1) == arr ~ arr ~ arr);

short[] buf2 = new short[17];
assert(rs.readOp!"cast(short)b"(buf2) == buf1[0 .. 17]);
auto rs = 1.repeatStream;
static assert(isInfinite!(typeof(rs)));
static assert(isInputStream!(typeof(rs)));
static assert(isInplaceComputableStream!(typeof(rs)));

assert(rs.read(new int[4]) == [1, 1, 1, 1]);

Meta