Skip to content

Instantly share code, notes, and snippets.

@akr4
Created April 17, 2012 00:22
Show Gist options
  • Save akr4/2402522 to your computer and use it in GitHub Desktop.
Save akr4/2402522 to your computer and use it in GitHub Desktop.
固定サイズの Queue
class FixedSizeQueue[A](limit: Int) extends scala.collection.mutable.Queue[A] {
override def +=(elem: A) = {
super.+=(elem)
while (size > limit) { dequeue }
this
}
override def +=:(elem: A) = {
super.+=:(elem)
while (size > limit) { dequeue }
this
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment