package tree import "fmt" // Print prints a Tree. Main use is to aid in debugging. func (t *Tree) Print() { if t.Root == nil { fmt.Println("") } t.Root.print() } func (n *Node) print() { q := newQueue() q.push(n) nodesInCurrentLevel := 1 nodesInNextLevel := 0 for !q.empty() { do := q.pop() nodesInCurrentLevel-- if do != nil { fmt.Print(do.Elem.Name(), " ") q.push(do.Left) q.push(do.Right) nodesInNextLevel += 2 } if nodesInCurrentLevel == 0 { fmt.Println() } nodesInCurrentLevel = nodesInNextLevel nodesInNextLevel = 0 } fmt.Println() } type queue []*Node // newQueue returns a new queue. func newQueue() queue { q := queue([]*Node{}) return q } // push pushes n to the end of the queue. func (q *queue) push(n *Node) { *q = append(*q, n) } // pop pops the first element off the queue. func (q *queue) pop() *Node { n := (*q)[0] *q = (*q)[1:] return n } // empty returns true when the queue contains zero nodes. func (q *queue) empty() bool { return len(*q) == 0 } /esp32c3-0.20.0'>dependabot/cargo/esp32c3-0.20.0 Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/examples/full-syntax.rs (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2018-04-16update parserGravatar Jorge Aparicio 13-139/+61
2018-04-16bors-ng integrationGravatar Jorge Aparicio 2-3/+5
2018-01-16v0.3.1v0.3.1Gravatar Jorge Aparicio 1-1/+8
2018-01-16specify both the path and version of the cortex-m-rtfm-macros dependencyGravatar Jorge Aparicio 1-1/+1
2018-01-15fix documentation linkGravatar Jorge Aparicio 2-3/+3
2018-01-15v0.3.0Gravatar Jorge Aparicio 11-25/+90
2018-01-11adapt to changes in the cortex-m crateGravatar Jorge Aparicio 11-42/+69
2018-01-11fix the compiletest_rs versionGravatar Jorge Aparicio 1-1/+1
2018-01-11switch to a stable release of compiletest_rsGravatar Jorge Aparicio 1-2/+1
2018-01-11use master branch of cortex-mGravatar Jorge Aparicio 1-1/+1
2017-12-23add a Cargo feature, cm7-r0p1, to fix a Cortex-M7 BASEPRI erratumGravatar Jorge Aparicio 3-2/+17
2017-12-23switch to a compiletest version that works with the latest nightlyGravatar Jorge Aparicio 1-1/+2
2017-12-23switch to master branchesGravatar Jorge Aparicio 2-3/+3
2017-12-17add missing commaGravatar Jorge Aparicio 1-1/+1
2017-12-09safe `&'static mut` references via init.resourcesGravatar Jorge Aparicio 6-10/+153
2017-12-09implement the Resource trait for owned resourcesGravatar Jorge Aparicio 11-220/+278
2017-12-09drop the Static wrapperGravatar Jorge Aparicio 8-26/+28
2017-12-09make resource proxies not SyncGravatar Jorge Aparicio 2-3/+2
2017-12-09also cache the Xargo directoryGravatar Jorge Aparicio 1-1/+4
2017-12-09deny warnings and unsafe code in tests and examplesGravatar Jorge Aparicio 24-0/+24
2017-12-09make resource proxies !SendGravatar Jorge Aparicio 2-2/+58
2017-12-09fix the "generics" exampleGravatar Jorge Aparicio 1-2/+2
2017-12-09rename LateResourceValues to LateResourcesGravatar Jorge Aparicio 4-9/+9
2017-12-09remove special case around peripherals from codegenGravatar Jorge Aparicio 1-209/+114
2017-12-09peripherals as scoped singletonsGravatar Jorge Aparicio 7-30/+68
2017-12-08ci: switch back to a recent nightlyGravatar Jorge Aparicio 1-2/+1
2017-12-08fix cfail testsGravatar Jorge Aparicio 2-2/+2
2017-11-22use older nightly for the x86_64 linux targetGravatar Jorge Aparicio 1-1/+2
2017-11-22fix ciGravatar Jorge Aparicio 3-4/+2
2017-11-22v0.2.2v0.2.2Gravatar Jorge Aparicio 10-61/+161
2017-10-02fix the exampleGravatar Jorge Aparicio 1-2/+2
2017-10-02fix `idle::Resources::new`Gravatar Jorge Aparicio 2-2/+13
2017-09-22Use `true` as the armv6 linkerGravatar Jonas Schievink 1-2/+2
2017-09-22Pin Travis to Xargo 0.3.8Gravatar Jonas Schievink 1-2/+2
2017-09-22Use rtfm-syntax 0.2.0Gravatar Jonas Schievink 1-2/+1