Having the code:
class DoubleLinkedQueue[T] {
class DoubleLinkedQueueNode[T](value: T) {
var next : DoubleLinkedQueueNode[T]
var prev : DoubleLinkedQueueNode[T]
}
var head = new DoubleLinkedQueueNode[T](_)
var tail = new DoubleLinkedQueueNode[T](_)
head.next = tail //compillation error here
def isEmpty() : Boolean = {
return head.next == tail //and here
}
def peekStart() : T = {
return head.next.value //and here too
}
def popStart() : T = {
val result = peekStart()
head.next = head.next.next //and everywhere when trying to acces head or tail properties
return result
}
def peekEnd() : T = {
return tail.prev.value
}
def popEnd() : T = {
val result = peekEnd()
tail.prev = tail.prev.prev
return result
}
def pushStart(value : T) : DoubleLinkedQueue[T] = {
val node = new DoubleLinkedQueueNode[T](value)
node.next = head.next
node.prev = head
head.next = node
return this
}
def pushEnd(value : T) : DoubleLinkedQueue[T] = {
val node = new DoubleLinkedQueueNode[T](value)
node.prev = tail.prev
node.next = tail
tail.prev = node
return this
}
}
and having the compillation error:
DoubleLinkedQueue.scala:9: error: value next is not a member of T => DoubleLinkedQueue.this.DoubleLinkedQueueNode[T] head.next = tail
Does anybody know how to fix it?
UPD1 Is it the same issue that described here?