not found: type in main method scala -


i'm using scala 2.11 , scala ide. , have following problem: have 2 files 1 implementation fo weight biased leftist heap , driver, object, main method.

wblheap.scala

package heaps  abstract class wblheap[+a] {   /**    * o(1)    * @return weight of heap    */   def weight() : int    /**    *     */   def isweightedleftist(): boolean   /**    * wblt n elements, length of right spine    * <= floor(log2(n+1))    */    def rightspine() : list[a]   /**    * o(log(n))    * @return wblheap heap , heap h    */    def merge[b >: a](h: wblheap[b]) : wblheap[b]     case object emptyheap extends wblheap[nothing] {     def weight(): int = 0     def isweightedleftist(): boolean = true     def rightspine() : list[nothing] = list()     def merge[b >: nothing](h: wblheap[b]) : wblheap[b] = h   }    case class node[a](elem: a, weightnode: int, left: wblheap[a], right: wblheap[a]) extends wblheap[a] {     def weight(): int = weightnode      def isweightedleftist(): boolean =        left.weight >= right.weight && left.isweightedleftist() &&        right.isweightedleftist()      def rightspine() : list[a] = elem :: right.rightspine()      def merge[b >: a](h: wblheap[b]) : wblheap[b] = h match {         case emptyheap =>         case node(e, w, l: wblheap[b], r: wblheap[b]) if this.weightnode <= w => buildnode(elem, left, r.merge(h) )         case node(e: b, w, l: wblheap[b], r: wblheap[b]) if this.weightnode > w => buildnode(e, l, this.merge(r))         //there warning here don't know why.          //abstract type pattern unchecked since eliminated erasure       }      private def buildnode[b >: a](x: b, h1: wblheap[b], h2: wblheap[b]): wblheap[b] = {       val w1 = h1.weight()       val w2 = h2.weight()       val newweight = w1 + w2 + 1       if(w1 >= w2)         return new node[b](x, newweight, h1, h2)       else         return new node[b](x, newweight, h2, h1)     }    } } 

driver.scala

package heaps  object driver {   def main(args:array[string]) = {      val h = new node[char]('b', 2,          new node[char]('c', 1, emptyheap(), emptyheap()),         emptyheap())     } } 

in line: "val h = new node[char]('b', 2, ", have error: not found: type node. happens everytime use object emptyheap.

does know doing wrong?

thank you!

either move node definition out of abstract class wblheap, change abstract class wblheap object, or add extends wblheap[...] driver, node becomes accessible.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -