Documentation
¶
Index ¶
- type Category
- type CategoryMap
- func (cm *CategoryMap) GeneratePaths()
- func (cm *CategoryMap) Get(id int) (c *Category)
- func (cm *CategoryMap) Index() []int
- func (cm *CategoryMap) JSONTree(offset int) ([]byte, error)
- func (cm *CategoryMap) Set(c *Category)
- func (cm *CategoryMap) Sort()
- func (cm *CategoryMap) Tree(offset int) (root []*Category)
- func (cm *CategoryMap) XMLTree(offset int) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CategoryMap ¶
type CategoryMap struct {
// contains filtered or unexported fields
}
CategoryMap a map of Category pointers and associates an index with it, for ordered output. The order of the index is based on the order items where added.
func (*CategoryMap) GeneratePaths ¶
func (cm *CategoryMap) GeneratePaths()
GeneratePaths generate paths for each category
func (*CategoryMap) Get ¶
func (cm *CategoryMap) Get(id int) (c *Category)
Get a Category pointer by its id.
func (*CategoryMap) Index ¶
func (cm *CategoryMap) Index() []int
Index returns a struct of category id. It allows for a sorted range loop.
func (*CategoryMap) JSONTree ¶
func (cm *CategoryMap) JSONTree(offset int) ([]byte, error)
JSONTree returns a JSON document, representing the parent / child relationship of the categories in a tree. It returns an error if json.Marshall does.
func (*CategoryMap) Set ¶
func (cm *CategoryMap) Set(c *Category)
Set a Category point to the map. It will also be appended to the index, keeping the order of calling this function.
func (*CategoryMap) Sort ¶
func (cm *CategoryMap) Sort()
Sort re-indexes the CategoryMap, increasing order on category id. It is advised to add the categories in a sorted way instead of using this method.
func (*CategoryMap) Tree ¶
func (cm *CategoryMap) Tree(offset int) (root []*Category)
Tree creates decendant tree by population the Category's children. It returns a slice of Category pointers, representing the root of the tree.