Skip to content

Commit

Permalink
removed asIterator. Its semantics were very dodgy
Browse files Browse the repository at this point in the history
  • Loading branch information
David R. MacIver committed May 2, 2009
1 parent 5dde3b6 commit 0793603
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
2 changes: 1 addition & 1 deletion src/generic.scala
Expand Up @@ -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, _)); }
}

Expand Down
13 changes: 0 additions & 13 deletions src/operations.scala
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 0793603

Please sign in to comment.