Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import scala.collection._
- import mutable.ListBuffer
- class FixedList[A](max: Int) extends Traversable[A] {
- val list: ListBuffer[A] = ListBuffer()
- def append(elem: A) {
- if (list.size == max) {
- list.trimStart(1)
- }
- list.append(elem)
- }
- def foreach[U](f: A => U) = list.foreach(f)
- }
- def size = writeIndex - readIndex + (if (readIndex > writeIndex) array.size else 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement