Last change
on this file since 16231 was
16191,
checked in by hmaislin, 6 years ago
|
#2929: Added current DLL to PGE dir that needs to be placed in bin path
|
File size:
664 bytes
|
Line | |
---|
1 | package pge
|
---|
2 |
|
---|
3 | type IpreNode struct {
|
---|
4 | val int
|
---|
5 | cnt int
|
---|
6 | vst int
|
---|
7 |
|
---|
8 | next map[int]*IpreNode
|
---|
9 | }
|
---|
10 |
|
---|
11 | func (n *IpreNode) InsertSerial(s []int) (did_ins bool) {
|
---|
12 | in, _ := n.next[s[0]]
|
---|
13 |
|
---|
14 | // does this branch exist?
|
---|
15 | if in == nil {
|
---|
16 | in = new(IpreNode)
|
---|
17 | in.val = s[0]
|
---|
18 | in.next = make(map[int]*IpreNode)
|
---|
19 | n.next[s[0]] = in
|
---|
20 | did_ins = true
|
---|
21 | }
|
---|
22 |
|
---|
23 | // recursive call to insert
|
---|
24 | if len(s) > 1 {
|
---|
25 | did_ins = in.InsertSerial(s[1:]) || did_ins
|
---|
26 | }
|
---|
27 |
|
---|
28 | // visitation accounting
|
---|
29 | // (-1 is the root of the memoization tree)
|
---|
30 | in.vst++
|
---|
31 | if n.val == -1 {
|
---|
32 | n.vst++
|
---|
33 | }
|
---|
34 | if did_ins {
|
---|
35 | in.cnt++
|
---|
36 | if n.val == -1 {
|
---|
37 | n.cnt++
|
---|
38 | }
|
---|
39 | }
|
---|
40 |
|
---|
41 | return did_ins
|
---|
42 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.