I'm trying to make a stack that will store a series of Huffman Tree structs. Currently I'm using an implementation that I found on github.
package util
type item struct {
value interface{}
next *item
}
//Stack the implementation of stack
//this stack is not thread safe!
type Stack struct {
top *item
size int
}
// Basic stack methods...
The problem is that when I store my Huffman tree structs in the stack I can't use any of the fields of the Huffman tree such as left/right child.
package huffmantree
type HuffmanTree struct {
freq int
value byte
isLeaf bool
left *HuffmanTree
right *HuffmanTree
code []bool
depth int
}
How am I supposed to implement a stack in Go which will correctly store structs and allow access to their fields?
Edit:
I tried replacing the interface {}
part with huffmantree.HuffmanTree
(huffmantree struct) and got this error message:
can't load package: import cycle not allowed
package github.com/inondle/huffman/util
imports github.com/inondle/huffman/huffmantree
imports github.com/inondle/huffman/util
import cycle not allowed
My guess would be that the huffmantree class imports the util package and the stack has to import the huffmantree package so there is some sort of conflict? Anyone know what went wrong?