From 079360334591fa916c80837103eb02317d76fd83 Mon Sep 17 00:00:00 2001 From: "David R. MacIver" Date: Sat, 2 May 2009 18:05:01 +0100 Subject: [PATCH] removed asIterator. Its semantics were very dodgy --- src/generic.scala | 2 +- src/operations.scala | 13 ------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/generic.scala b/src/generic.scala index ba7f820..d6b692d 100644 --- a/src/generic.scala +++ b/src/generic.scala @@ -19,7 +19,7 @@ trait Generic extends CoreProtocol{ abstract class LengthEncoded[S <: Collection[T], T](implicit binT : Format[T]) extends Format[S]{ def build(size : Int, ts : Iterator[T]) : S; - def reads(in : Input) = { val size = read[Int](in); build(size, asIterator[T](in).take(size)) } + def reads(in : Input) = { val size = read[Int](in); build(size, (0 until size).map(i => read[T](in)).elements) } def writes(out : Output, ts : S) = { write(out, ts.size); ts.foreach(write(out, _)); } } diff --git a/src/operations.scala b/src/operations.scala index 5caecda..e1528f4 100644 --- a/src/operations.scala +++ b/src/operations.scala @@ -11,19 +11,6 @@ object Operations{ def write[T](out : Output, value : T)(implicit writer : Writes[T]) = writer.writes(out, value); - /** - * Returns an iterator that iterates by reading from this input. - * In order to ensure proper laziness properties (and not reading more - * data than is strictly neccessary) this will always return true - * from hasNext but may throw an EOFException on an unexpected end - * of stream. - */ - def asIterator[S](input : Input)(implicit bin : Reads[S]) = new Iterator[S]{ - def hasNext = true; - def next = read[S](input); - } - - /** * Get the serialized value of this class as a byte array. */