Browse code

Code, documentation re-arrangment / standardization

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/Streamer@68814 bc3139a8-67e5-0310-9ffc-ced21a209358

Martin Morgan authored on 25/08/2012 22:59:04
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,35 @@
1
+.Stream <- setRefClass("Stream", contains = "Consumer")
2
+
3
+.Stream$methods(
4
+    yield=function()
5
+    {
6
+        .self$inputPipe$yield()
7
+    
8
+    })
9
+
10
+setMethod(length, "Stream",
11
+    function(x)
12
+{
13
+    i <- 0L
14
+    inp <- x
15
+    while (extends(class(inp), "Consumer")) {
16
+        inp <- inp$inputPipe
17
+        i <- i + 1L
18
+    }
19
+    i
20
+})
21
+
22
+setMethod("[[", c("Stream", "numeric"),
23
+    function(x, i, j, ...)
24
+{
25
+    i <- as.integer(i)
26
+    len <- length(x)
27
+    if (1L != length(i) || 0 >= i || len < i)
28
+        stop("'i' must be integer(1), 0 < i <= length(x)")
29
+    inp <- x$inputPipe
30
+    while (extends(class(inp), "Consumer") && 1L < i) {
31
+        inp <- inp$inputPipe
32
+        i <- i - 1L
33
+    }
34
+    inp
35
+})