diff options
Diffstat (limited to 'dbxrecover.d')
| -rw-r--r-- | dbxrecover.d | 71 |
1 files changed, 35 insertions, 36 deletions
diff --git a/dbxrecover.d b/dbxrecover.d index 3801f5a..2a3292e 100644 --- a/dbxrecover.d +++ b/dbxrecover.d @@ -52,6 +52,41 @@ class ChainFinder ChunkInfo[][uint] infos; bool[uint] first; + int walk(uint id, int delegate(inout Message) dg) + { + auto m = new Message(s); + return walk(id, &infos[id], dg, m, 1); + } + + int walk(uint id, ChunkInfo[]* infosp, int delegate(inout Message) dg, Message m, uint combinations) + { + if (combinations > 16) + { + chainstats.dropped++; + return 0; + } + foreach(ChunkInfo info; *infosp) + { + m.push(id, info); + bool seen = m.seen(info.next); + ChunkInfo[]* nextp = info.next in infos; + if (nextp && (!seen)) + { + walk(info.next, nextp, dg, m, combinations * nextp.length); + } + else + { + if (seen) chainstats.loops++; + if (m.broken()) chainstats.broken++; + chainstats.count++; + int result = dg(m); + if (result) return result; + } + m.pop(id); + } + return 0; + } + public: struct ChunkStatistics { @@ -119,42 +154,6 @@ class ChainFinder } return 0; } - - int walk(uint id, int delegate(inout Message) dg) - { - auto m = new Message(s); - return walk(id, &infos[id], dg, m, 1); - } - - int walk(uint id, ChunkInfo[]* infosp, int delegate(inout Message) dg, Message m, uint combinations) - { - if (combinations > 16) - { - chainstats.dropped++; - return 0; - } - foreach(ChunkInfo info; *infosp) - { - m.push(id, info); - bool seen = m.seen(info.next); - ChunkInfo[]* nextp = info.next in infos; - if (nextp && (!seen)) - { - walk(info.next, nextp, dg, m, combinations * nextp.length); - } - else - { - if (seen) chainstats.loops++; - if (m.broken()) chainstats.broken++; - chainstats.count++; - int result = dg(m); - if (result) return result; - } - m.pop(id); - } - return 0; - } - }; class Message |
