Created
December 24, 2009 17:19
-
-
Save alaz/263272 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def toArray(dbo: DBObject): Seq[Any] = { | |
def arrayValues(i: Int): Stream[Any] = { | |
val key = i.toString | |
if (dbo.containsField(key)) Stream.cons(dbo.get(key), arrayValues(i+1)) | |
else Stream.empty | |
} | |
arrayValues(0).toList | |
// | |
// | |
// class ArrayValuesIterator extends Iterator[Any] { | |
// private var i = 0 | |
// private def key = i.toString | |
// | |
// def hasNext = dbo.containsField(key) | |
// def next = { | |
// val v = dbo.get(key) | |
// i += 1 | |
// v | |
// } | |
// } | |
// | |
// List.fromIterator(new ArrayValuesIterator) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment