Permalink
Browse files

deleted

  • Loading branch information...
1 parent 089ff3a commit 179218fb5ffd8d51597411b1dd8d5cb4a81704fb @Frankencelery Frankencelery committed Oct 19, 2012
Showing with 0 additions and 11,480 deletions.
  1. 0 src/examples/lib/user/.dummy
  2. +0 −364 src/log-mega.txt
  3. +0 −1,713 src/tests/Algorithm/Diff.pm
  4. +0 −76 src/tests/Make.tests
  5. +0 −53 src/tests/arc4.c
  6. +0 −17 src/tests/arc4.h
  7. +0 −29 src/tests/arc4.pm
  8. +0 −92 src/tests/cksum.c
  9. +0 −8 src/tests/cksum.h
  10. +0 −87 src/tests/cksum.pm
  11. +0 −18 src/tests/filesys/Grading.no-vm
  12. +0 −22 src/tests/filesys/Grading.with-vm
  13. +0 −18 src/tests/filesys/base/Make.tests
  14. +0 −19 src/tests/filesys/base/Rubric
  15. +0 −44 src/tests/filesys/base/child-syn-read.c
  16. +0 −35 src/tests/filesys/base/child-syn-wrt.c
  17. +0 −20 src/tests/filesys/base/full.inc
  18. +0 −5 src/tests/filesys/base/lg-create.c
  19. +0 −13 src/tests/filesys/base/lg-create.ck
  20. +0 −6 src/tests/filesys/base/lg-full.c
  21. +0 −16 src/tests/filesys/base/lg-full.ck
  22. +0 −7 src/tests/filesys/base/lg-random.c
  23. +0 −14 src/tests/filesys/base/lg-random.ck
  24. +0 −7 src/tests/filesys/base/lg-seq-block.c
  25. +0 −16 src/tests/filesys/base/lg-seq-block.ck
  26. +0 −6 src/tests/filesys/base/lg-seq-random.c
  27. +0 −16 src/tests/filesys/base/lg-seq-random.ck
  28. +0 −59 src/tests/filesys/base/random.inc
  29. +0 −20 src/tests/filesys/base/seq-block.inc
  30. +0 −22 src/tests/filesys/base/seq-random.inc
  31. +0 −5 src/tests/filesys/base/sm-create.c
  32. +0 −13 src/tests/filesys/base/sm-create.ck
  33. +0 −6 src/tests/filesys/base/sm-full.c
  34. +0 −16 src/tests/filesys/base/sm-full.ck
  35. +0 −7 src/tests/filesys/base/sm-random.c
  36. +0 −14 src/tests/filesys/base/sm-random.ck
  37. +0 −7 src/tests/filesys/base/sm-seq-block.c
  38. +0 −16 src/tests/filesys/base/sm-seq-block.ck
  39. +0 −6 src/tests/filesys/base/sm-seq-random.c
  40. +0 −16 src/tests/filesys/base/sm-seq-random.ck
  41. +0 −31 src/tests/filesys/base/syn-read.c
  42. +0 −33 src/tests/filesys/base/syn-read.ck
  43. +0 −7 src/tests/filesys/base/syn-read.h
  44. +0 −30 src/tests/filesys/base/syn-remove.c
  45. +0 −16 src/tests/filesys/base/syn-remove.ck
  46. +0 −31 src/tests/filesys/base/syn-write.c
  47. +0 −32 src/tests/filesys/base/syn-write.ck
  48. +0 −9 src/tests/filesys/base/syn-write.h
  49. +0 −15 src/tests/filesys/create.inc
  50. +0 −61 src/tests/filesys/extended/Make.tests
  51. +0 −26 src/tests/filesys/extended/Rubric.functionality
  52. +0 −24 src/tests/filesys/extended/Rubric.persistence
  53. +0 −9 src/tests/filesys/extended/Rubric.robustness
  54. +0 −53 src/tests/filesys/extended/child-syn-rw.c
  55. +0 −6 src/tests/filesys/extended/dir-empty-name-persistence.ck
  56. +0 −12 src/tests/filesys/extended/dir-empty-name.c
  57. +0 −10 src/tests/filesys/extended/dir-empty-name.ck
  58. +0 −16 src/tests/filesys/extended/dir-mk-tree-persistence.ck
  59. +0 −12 src/tests/filesys/extended/dir-mk-tree.c
  60. +0 −12 src/tests/filesys/extended/dir-mk-tree.ck
  61. +0 −6 src/tests/filesys/extended/dir-mkdir-persistence.ck
  62. +0 −15 src/tests/filesys/extended/dir-mkdir.c
  63. +0 −13 src/tests/filesys/extended/dir-mkdir.ck
  64. +0 −6 src/tests/filesys/extended/dir-open-persistence.ck
  65. +0 −21 src/tests/filesys/extended/dir-open.c
  66. +0 −20 src/tests/filesys/extended/dir-open.ck
  67. +0 −6 src/tests/filesys/extended/dir-over-file-persistence.ck
  68. +0 −13 src/tests/filesys/extended/dir-over-file.c
  69. +0 −11 src/tests/filesys/extended/dir-over-file.ck
  70. +0 −8 src/tests/filesys/extended/dir-rm-cwd-persistence.ck
  71. +0 −75 src/tests/filesys/extended/dir-rm-cwd.c
  72. +0 −51 src/tests/filesys/extended/dir-rm-cwd.ck
  73. +0 −6 src/tests/filesys/extended/dir-rm-parent-persistence.ck
  74. +0 −16 src/tests/filesys/extended/dir-rm-parent.c
  75. +0 −14 src/tests/filesys/extended/dir-rm-parent.ck
  76. +0 −6 src/tests/filesys/extended/dir-rm-root-persistence.ck
  77. +0 −13 src/tests/filesys/extended/dir-rm-root.c
  78. +0 −11 src/tests/filesys/extended/dir-rm-root.ck
  79. +0 −6 src/tests/filesys/extended/dir-rm-tree-persistence.ck
  80. +0 −62 src/tests/filesys/extended/dir-rm-tree.c
  81. +0 −14 src/tests/filesys/extended/dir-rm-tree.ck
  82. +0 −6 src/tests/filesys/extended/dir-rmdir-persistence.ck
  83. +0 −14 src/tests/filesys/extended/dir-rmdir.c
  84. +0 −12 src/tests/filesys/extended/dir-rmdir.ck
  85. +0 −6 src/tests/filesys/extended/dir-under-file-persistence.ck
  86. +0 −13 src/tests/filesys/extended/dir-under-file.c
  87. +0 −11 src/tests/filesys/extended/dir-under-file.ck
  88. +0 −37 src/tests/filesys/extended/dir-vine-persistence.ck
  89. +0 −85 src/tests/filesys/extended/dir-vine.c
  90. +0 −11 src/tests/filesys/extended/dir-vine.ck
  91. +0 −6 src/tests/filesys/extended/grow-create-persistence.ck
  92. +0 −4 src/tests/filesys/extended/grow-create.c
  93. +0 −13 src/tests/filesys/extended/grow-create.ck
  94. +0 −9 src/tests/filesys/extended/grow-dir-lg-persistence.ck
  95. +0 −6 src/tests/filesys/extended/grow-dir-lg.c
  96. +0 −61 src/tests/filesys/extended/grow-dir-lg.ck
  97. +0 −41 src/tests/filesys/extended/grow-dir.inc
  98. +0 −7 src/tests/filesys/extended/grow-file-size-persistence.ck
  99. +0 −33 src/tests/filesys/extended/grow-file-size.c
  100. +0 −17 src/tests/filesys/extended/grow-file-size.ck
  101. +0 −9 src/tests/filesys/extended/grow-root-lg-persistence.ck
  102. +0 −4 src/tests/filesys/extended/grow-root-lg.c
  103. +0 −60 src/tests/filesys/extended/grow-root-lg.ck
  104. +0 −9 src/tests/filesys/extended/grow-root-sm-persistence.ck
  105. +0 −4 src/tests/filesys/extended/grow-root-sm.c
  106. +0 −30 src/tests/filesys/extended/grow-root-sm.ck
  107. +0 −7 src/tests/filesys/extended/grow-seq-lg-persistence.ck
  108. +0 −5 src/tests/filesys/extended/grow-seq-lg.c
  109. +0 −17 src/tests/filesys/extended/grow-seq-lg.ck
  110. +0 −7 src/tests/filesys/extended/grow-seq-sm-persistence.ck
  111. +0 −5 src/tests/filesys/extended/grow-seq-sm.c
  112. +0 −17 src/tests/filesys/extended/grow-seq-sm.ck
  113. +0 −20 src/tests/filesys/extended/grow-seq.inc
  114. +0 −6 src/tests/filesys/extended/grow-sparse-persistence.ck
  115. +0 −25 src/tests/filesys/extended/grow-sparse.c
  116. +0 −17 src/tests/filesys/extended/grow-sparse.ck
  117. +0 −7 src/tests/filesys/extended/grow-tell-persistence.ck
  118. +0 −32 src/tests/filesys/extended/grow-tell.c
  119. +0 −17 src/tests/filesys/extended/grow-tell.ck
  120. +0 −9 src/tests/filesys/extended/grow-two-files-persistence.ck
  121. +0 −62 src/tests/filesys/extended/grow-two-files.c
  122. +0 −23 src/tests/filesys/extended/grow-two-files.ck
  123. +0 −67 src/tests/filesys/extended/mk-tree.c
  124. +0 −6 src/tests/filesys/extended/mk-tree.h
  125. +0 −8 src/tests/filesys/extended/syn-rw-persistence.ck
  126. +0 −35 src/tests/filesys/extended/syn-rw.c
  127. +0 −20 src/tests/filesys/extended/syn-rw.ck
  128. +0 −9 src/tests/filesys/extended/syn-rw.h
  129. +0 −208 src/tests/filesys/extended/tar.c
  130. +0 −37 src/tests/filesys/seq-test.c
  131. +0 −11 src/tests/filesys/seq-test.h
  132. +0 −174 src/tests/internal/list.c
  133. +0 −208 src/tests/internal/stdio.c
  134. +0 −114 src/tests/internal/stdlib.c
  135. +0 −196 src/tests/lib.c
  136. +0 −50 src/tests/lib.h
  137. +0 −19 src/tests/lib.pm
  138. +0 −15 src/tests/main.c
  139. +0 −6 src/tests/main.h
  140. +0 −152 src/tests/make-grade
  141. +0 −27 src/tests/random.pm
  142. +0 −625 src/tests/tests.pm
  143. +0 −6 src/tests/threads/Grading
  144. +0 −53 src/tests/threads/Make.tests
  145. +0 −53 src/tests/threads/Make.tests~
  146. +0 −10 src/tests/threads/Rubric.alarm
  147. +0 −14 src/tests/threads/Rubric.mlfqs
  148. +0 −15 src/tests/threads/Rubric.priority
  149. +0 −4 src/tests/threads/alarm-many.ck
  150. +0 −4 src/tests/threads/alarm-mega.ck
  151. +0 −4 src/tests/threads/alarm-multiple.ck
  152. +0 −15 src/tests/threads/alarm-negative.c
  153. +0 −10 src/tests/threads/alarm-negative.ck
  154. +0 −4 src/tests/threads/alarm-onethousand.ck
  155. +0 −4 src/tests/threads/alarm-onethousand.ck~
  156. +0 −58 src/tests/threads/alarm-priority.c
  157. +0 −19 src/tests/threads/alarm-priority.ck
  158. +0 −94 src/tests/threads/alarm-simultaneous.c
  159. +0 −27 src/tests/threads/alarm-simultaneous.ck
  160. +0 −4 src/tests/threads/alarm-single.ck
  161. +0 −168 src/tests/threads/alarm-wait.c
  162. +0 −168 src/tests/threads/alarm-wait.c~
  163. +0 −15 src/tests/threads/alarm-zero.c
  164. +0 −10 src/tests/threads/alarm-zero.ck
  165. +0 −32 src/tests/threads/alarm.pm
  166. +0 −64 src/tests/threads/mlfqs-block.c
  167. +0 −17 src/tests/threads/mlfqs-block.ck
  168. +0 −7 src/tests/threads/mlfqs-fair-2.ck
  169. +0 −7 src/tests/threads/mlfqs-fair-20.ck
  170. +0 −124 src/tests/threads/mlfqs-fair.c
  171. +0 −60 src/tests/threads/mlfqs-load-1.c
  172. +0 −15 src/tests/threads/mlfqs-load-1.ck
  173. +0 −155 src/tests/threads/mlfqs-load-60.c
  174. +0 −36 src/tests/threads/mlfqs-load-60.ck
  175. +0 −167 src/tests/threads/mlfqs-load-avg.c
  176. +0 −36 src/tests/threads/mlfqs-load-avg.ck
  177. +0 −7 src/tests/threads/mlfqs-nice-10.ck
  178. +0 −7 src/tests/threads/mlfqs-nice-2.ck
  179. +0 −144 src/tests/threads/mlfqs-recent-1.c
  180. +0 −31 src/tests/threads/mlfqs-recent-1.ck
  181. +0 −146 src/tests/threads/mlfqs.pm
  182. +0 −31 src/tests/threads/priority-change.c
  183. +0 −14 src/tests/threads/priority-change.ck
  184. +0 −53 src/tests/threads/priority-condvar.c
  185. +0 −39 src/tests/threads/priority-condvar.ck
  186. +0 −114 src/tests/threads/priority-donate-chain.c
  187. +0 −46 src/tests/threads/priority-donate-chain.ck
  188. +0 −51 src/tests/threads/priority-donate-lower.c
  189. +0 −16 src/tests/threads/priority-donate-lower.ck
  190. +0 −77 src/tests/threads/priority-donate-multiple.c
  191. +0 −19 src/tests/threads/priority-donate-multiple.ck
  192. +0 −90 src/tests/threads/priority-donate-multiple2.c
  193. +0 −19 src/tests/threads/priority-donate-multiple2.ck
  194. +0 −94 src/tests/threads/priority-donate-nest.c
  195. +0 −19 src/tests/threads/priority-donate-nest.ck
  196. +0 −65 src/tests/threads/priority-donate-one.c
  197. +0 −17 src/tests/threads/priority-donate-one.ck
  198. +0 −82 src/tests/threads/priority-donate-sema.c
  199. +0 −16 src/tests/threads/priority-donate-sema.ck
  200. +0 −99 src/tests/threads/priority-fifo.c
  201. +0 −63 src/tests/threads/priority-fifo.ck
  202. +0 −41 src/tests/threads/priority-preempt.c
  203. +0 −16 src/tests/threads/priority-preempt.ck
  204. +0 −45 src/tests/threads/priority-sema.c
  205. +0 −29 src/tests/threads/priority-sema.ck
  206. +0 −106 src/tests/threads/tests.c
  207. +0 −106 src/tests/threads/tests.c~
  208. +0 −45 src/tests/threads/tests.h
  209. +0 −44 src/tests/threads/tests.h~
  210. +0 −11 src/tests/userprog/Grading
  211. +0 −133 src/tests/userprog/Make.tests
  212. +0 −52 src/tests/userprog/Rubric.functionality
  213. +0 −48 src/tests/userprog/Rubric.robustness
  214. +0 −15 src/tests/userprog/args-dbl-space.ck
  215. +0 −35 src/tests/userprog/args-many.ck
  216. +0 −17 src/tests/userprog/args-multiple.ck
  217. +0 −13 src/tests/userprog/args-none.ck
  218. +0 −14 src/tests/userprog/args-single.ck
  219. +0 −25 src/tests/userprog/args.c
  220. +0 −13 src/tests/userprog/bad-jump.c
  221. +0 −9 src/tests/userprog/bad-jump.ck
  222. +0 −13 src/tests/userprog/bad-jump2.c
  223. +0 −9 src/tests/userprog/bad-jump2.ck
  224. +0 −13 src/tests/userprog/bad-read.c
  225. +0 −9 src/tests/userprog/bad-read.ck
  226. +0 −13 src/tests/userprog/bad-read2.c
  227. +0 −9 src/tests/userprog/bad-read2.ck
  228. +0 −12 src/tests/userprog/bad-write.c
  229. +0 −9 src/tests/userprog/bad-write.ck
  230. +0 −12 src/tests/userprog/bad-write2.c
  231. +0 −9 src/tests/userprog/bad-write2.ck
  232. +0 −33 src/tests/userprog/boundary.c
  233. +0 −7 src/tests/userprog/boundary.h
  234. +0 −14 src/tests/userprog/child-bad.c
  235. +0 −28 src/tests/userprog/child-close.c
  236. +0 −55 src/tests/userprog/child-rox.c
  237. +0 −15 src/tests/userprog/child-simple.c
  238. +0 −11 src/tests/userprog/close-bad-fd.c
  239. +0 −13 src/tests/userprog/close-bad-fd.ck
  240. +0 −14 src/tests/userprog/close-normal.c
  241. +0 −12 src/tests/userprog/close-normal.ck
  242. +0 −11 src/tests/userprog/close-stdin.c
  243. +0 −13 src/tests/userprog/close-stdin.ck
  244. +0 −11 src/tests/userprog/close-stdout.c
  245. +0 −13 src/tests/userprog/close-stdout.ck
  246. +0 −18 src/tests/userprog/close-twice.c
  247. +0 −19 src/tests/userprog/close-twice.ck
  248. +0 −12 src/tests/userprog/create-bad-ptr.c
  249. +0 −9 src/tests/userprog/create-bad-ptr.ck
  250. +0 −14 src/tests/userprog/create-bound.c
  251. +0 −11 src/tests/userprog/create-bound.ck
  252. +0 −10 src/tests/userprog/create-empty.c
  253. +0 −14 src/tests/userprog/create-empty.ck
  254. +0 −16 src/tests/userprog/create-exists.c
  255. +0 −15 src/tests/userprog/create-exists.ck
  256. +0 −17 src/tests/userprog/create-long.c
  257. +0 −11 src/tests/userprog/create-long.ck
  258. +0 −10 src/tests/userprog/create-normal.c
  259. +0 −11 src/tests/userprog/create-normal.ck
  260. +0 −11 src/tests/userprog/create-null.c
  261. +0 −9 src/tests/userprog/create-null.ck
  262. +0 −10 src/tests/userprog/exec-arg.c
  263. +0 −17 src/tests/userprog/exec-arg.ck
  264. +0 −11 src/tests/userprog/exec-bad-ptr.c
  265. +0 −13 src/tests/userprog/exec-bad-ptr.ck
  266. +0 −12 src/tests/userprog/exec-missing.c
  267. +0 −31 src/tests/userprog/exec-missing.ck
  268. +0 −14 src/tests/userprog/exec-multiple.c
  269. +0 −18 src/tests/userprog/exec-multiple.ck
  270. +0 −11 src/tests/userprog/exec-once.c
  271. +0 −12 src/tests/userprog/exec-once.ck
  272. +0 −11 src/tests/userprog/exit.c
  273. +0 −9 src/tests/userprog/exit.ck
  274. +0 −11 src/tests/userprog/halt.c
  275. +0 −15 src/tests/userprog/halt.ck
  276. +0 −1 src/tests/userprog/lib/.gitignore
  277. 0 src/tests/userprog/lib/user/.dummy
  278. +0 −1 src/tests/userprog/lib/user/.gitignore
  279. +0 −25 src/tests/userprog/multi-child-fd.c
  280. +0 −25 src/tests/userprog/multi-child-fd.ck
  281. +0 −34 src/tests/userprog/multi-recurse.c
  282. +0 −70 src/tests/userprog/multi-recurse.ck
  283. +0 −8 src/tests/userprog/no-vm/Make.tests
  284. +0 −3 src/tests/userprog/no-vm/Rubric
  285. +0 −179 src/tests/userprog/no-vm/multi-oom.c
  286. +0 −10 src/tests/userprog/no-vm/multi-oom.ck
  287. +0 −8 src/tests/userprog/null.ck
  288. +0 −13 src/tests/userprog/open-bad-ptr.c
  289. +0 −13 src/tests/userprog/open-bad-ptr.ck
  290. +0 −14 src/tests/userprog/open-boundary.c
  291. +0 −11 src/tests/userprog/open-boundary.ck
  292. +0 −13 src/tests/userprog/open-empty.c
  293. +0 −10 src/tests/userprog/open-empty.ck
  294. +0 −13 src/tests/userprog/open-missing.c
  295. +0 −10 src/tests/userprog/open-missing.ck
  296. +0 −13 src/tests/userprog/open-normal.c
  297. +0 −10 src/tests/userprog/open-normal.ck
  298. +0 −12 src/tests/userprog/open-null.c
  299. +0 −13 src/tests/userprog/open-null.ck
  300. +0 −19 src/tests/userprog/open-twice.c
Sorry, we could not display the entire diff because too many files (435) changed.
View
0 src/examples/lib/user/.dummy
No changes.
View
364 src/log-mega.txt
@@ -1,364 +0,0 @@
-PiLo hda1
-Loading..........
-Kernel command line: run alarm-mega
-Pin========================================================================
- Bochs x86 Emulator 2.4.5
- Build from CVS snapshot, on April 25, 2010
-========================================================================
-ach.
-(alarm-mega) Thread 0 sleeps 10 ticks each time,
-(alarm-mega) thread 1 sleeps 20 ticks each time, and so on.
-(alarm-mega) If successful, product of iteration count and
-(alarm-mega) sleep duration will appear in nondescending order.
-(alarm-mega) thread 0: duration=10, iteration=1, product=10
-(alarm-mega) thread 0: duration=10, iteration=2, product=20
-(alarm-mega) thread 1: duration=20, iteration=1, product=20
-(alarm-mega) thread 0: duration=10, iteration=3, product=30
-(alarm-mega) thread 2: duration=30, iteration=1, product=30
-(alarm-mega) thread 3: duration=40, iteration=1, product=40
-(alarm-mega) thread 0: duration=10, iteration=4, product=40
-(alarm-mega) thread 1: duration=20, iteration=2, product=40
-(alarm-mega) thread 4: duration=50, iteration=1, product=50
-(alarm-mega) thread 0: duration=10, iteration=5, product=50
-(alarm-mega) thread 0: duration=10, iteration=6, product=60
-(alarm-mega) thread 1: duration=20, iteration=3, product=60
-(alarm-mega) thread 2: duration=30, iteration=2, product=60
-(alarm-mega) thread 0: duration=10, iteration=7, product=70
-(alarm-mega) thread 0: duration=10, iteration=8, product=80
-(alarm-mega) thread 1: duration=20, iteration=4, product=80
-(alarm-mega) thread 3: duration=40, iteration=2, product=80
-(alarm-mega) thread 0: duration=10, iteration=9, product=90
-(alarm-mega) thread 2: duration=30, iteration=3, product=90
-(alarm-mega) thread 4: duration=50, iteration=2, product=100
-(alarm-mega) thread 0: duration=10, iteration=10, product=100
-(alarm-mega) thread 1: duration=20, iteration=5, product=100
-(alarm-mega) thread 0: duration=10, iteration=11, product=110
-(alarm-mega) thread 0: duration=10, iteration=12, product=120
-(alarm-mega) thread 1: duration=20, iteration=6, product=120
-(alarm-mega) thread 2: duration=30, iteration=4, product=120
-(alarm-mega) thread 3: duration=40, iteration=3, product=120
-(alarm-mega) thread 0: duration=10, iteration=13, product=130
-(alarm-mega) thread 0: duration=10, iteration=14, product=140
-(alarm-mega) thread 1: duration=20, iteration=7, product=140
-(alarm-mega) thread 0: duration=10, iteration=15, product=150
-(alarm-mega) thread 2: duration=30, iteration=5, product=150
-(alarm-mega) thread 4: duration=50, iteration=3, product=150
-(alarm-mega) thread 3: duration=40, iteration=4, product=160
-(alarm-mega) thread 0: duration=10, iteration=16, product=160
-(alarm-mega) thread 1: duration=20, iteration=8, product=160
-(alarm-mega) thread 0: duration=10, iteration=17, product=170
-(alarm-mega) thread 0: duration=10, iteration=18, product=180
-(alarm-mega) thread 1: duration=20, iteration=9, product=180
-(alarm-mega) thread 2: duration=30, iteration=6, product=180
-(alarm-mega) thread 0: duration=10, iteration=19, product=190
-(alarm-mega) thread 0: duration=10, iteration=20, product=200
-(alarm-mega) thread 1: duration=20, iteration=10, product=200
-(alarm-mega) thread 3: duration=40, iteration=5, product=200
-(alarm-mega) thread 4: duration=50, iteration=4, product=200
-(alarm-mega) thread 0: duration=10, iteration=21, product=210
-(alarm-mega) thread 2: duration=30, iteration=7, product=210
-(alarm-mega) thread 0: duration=10, iteration=22, product=220
-(alarm-mega) thread 1: duration=20, iteration=11, product=220
-(alarm-mega) thread 0: duration=10, iteration=23, product=230
-(alarm-mega) thread 2: duration=30, iteration=8, product=240
-(alarm-mega) thread 3: duration=40, iteration=6, product=240
-(alarm-mega) thread 0: duration=10, iteration=24, product=240
-(alarm-mega) thread 1: duration=20, iteration=12, product=240
-(alarm-mega) thread 4: duration=50, iteration=5, product=250
-(alarm-mega) thread 0: duration=10, iteration=25, product=250
-(alarm-mega) thread 0: duration=10, iteration=26, product=260
-(alarm-mega) thread 1: duration=20, iteration=13, product=260
-(alarm-mega) thread 0: duration=10, iteration=27, product=270
-(alarm-mega) thread 2: duration=30, iteration=9, product=270
-(alarm-mega) thread 3: duration=40, iteration=7, product=280
-(alarm-mega) thread 0: duration=10, iteration=28, product=280
-(alarm-mega) thread 1: duration=20, iteration=14, product=280
-(alarm-mega) thread 0: duration=10, iteration=29, product=290
-(alarm-mega) thread 2: duration=30, iteration=10, product=300
-(alarm-mega) thread 4: duration=50, iteration=6, product=300
-(alarm-mega) thread 0: duration=10, iteration=30, product=300
-(alarm-mega) thread 1: duration=20, iteration=15, product=300
-(alarm-mega) thread 0: duration=10, iteration=31, product=310
-(alarm-mega) thread 0: duration=10, iteration=32, product=320
-(alarm-mega) thread 1: duration=20, iteration=16, product=320
-(alarm-mega) thread 3: duration=40, iteration=8, product=320
-(alarm-mega) thread 0: duration=10, iteration=33, product=330
-(alarm-mega) thread 2: duration=30, iteration=11, product=330
-(alarm-mega) thread 0: duration=10, iteration=34, product=340
-(alarm-mega) thread 1: duration=20, iteration=17, product=340
-(alarm-mega) thread 0: duration=10, iteration=35, product=350
-(alarm-mega) thread 4: duration=50, iteration=7, product=350
-(alarm-mega) thread 2: duration=30, iteration=12, product=360
-(alarm-mega) thread 3: duration=40, iteration=9, product=360
-(alarm-mega) thread 0: duration=10, iteration=36, product=360
-(alarm-mega) thread 1: duration=20, iteration=18, product=360
-(alarm-mega) thread 0: duration=10, iteration=37, product=370
-(alarm-mega) thread 0: duration=10, iteration=38, product=380
-(alarm-mega) thread 1: duration=20, iteration=19, product=380
-(alarm-mega) thread 2: duration=30, iteration=13, product=390
-(alarm-mega) thread 0: duration=10, iteration=39, product=390
-(alarm-mega) thread 4: duration=50, iteration=8, product=400
-(alarm-mega) thread 0: duration=10, iteration=40, product=400
-(alarm-mega) thread 1: duration=20, iteration=20, product=400
-(alarm-mega) thread 3: duration=40, iteration=10, product=400
-(alarm-mega) thread 0: duration=10, iteration=41, product=410
-(alarm-mega) thread 2: duration=30, iteration=14, product=420
-(alarm-mega) thread 0: duration=10, iteration=42, product=420
-(alarm-mega) thread 1: duration=20, iteration=21, product=420
-(alarm-mega) thread 0: duration=10, iteration=43, product=430
-(alarm-mega) thread 0: duration=10, iteration=44, product=440
-(alarm-mega) thread 1: duration=20, iteration=22, product=440
-(alarm-mega) thread 3: duration=40, iteration=11, product=440
-(alarm-mega) thread 2: duration=30, iteration=15, product=450
-(alarm-mega) thread 4: duration=50, iteration=9, product=450
-(alarm-mega) thread 0: duration=10, iteration=45, product=450
-(alarm-mega) thread 0: duration=10, iteration=46, product=460
-(alarm-mega) thread 1: duration=20, iteration=23, product=460
-(alarm-mega) thread 0: duration=10, iteration=47, product=470
-(alarm-mega) thread 3: duration=40, iteration=12, product=480
-(alarm-mega) thread 0: duration=10, iteration=48, product=480
-(alarm-mega) thread 1: duration=20, iteration=24, product=480
-(alarm-mega) thread 2: duration=30, iteration=16, product=480
-(alarm-mega) thread 0: duration=10, iteration=49, product=490
-(alarm-mega) thread 0: duration=10, iteration=50, product=500
-(alarm-mega) thread 1: duration=20, iteration=25, product=500
-(alarm-mega) thread 4: duration=50, iteration=10, product=500
-(alarm-mega) thread 2: duration=30, iteration=17, product=510
-(alarm-mega) thread 0: duration=10, iteration=51, product=510
-(alarm-mega) thread 0: duration=10, iteration=52, product=520
-(alarm-mega) thread 1: duration=20, iteration=26, product=520
-(alarm-mega) thread 3: duration=40, iteration=13, product=520
-(alarm-mega) thread 0: duration=10, iteration=53, product=530
-(alarm-mega) thread 0: duration=10, iteration=54, product=540
-(alarm-mega) thread 1: duration=20, iteration=27, product=540
-(alarm-mega) thread 2: duration=30, iteration=18, product=540
-(alarm-mega) thread 4: duration=50, iteration=11, product=550
-(alarm-mega) thread 0: duration=10, iteration=55, product=550
-(alarm-mega) thread 0: duration=10, iteration=56, product=560
-(alarm-mega) thread 1: duration=20, iteration=28, product=560
-(alarm-mega) thread 3: duration=40, iteration=14, product=560
-(alarm-mega) thread 2: duration=30, iteration=19, product=570
-(alarm-mega) thread 0: duration=10, iteration=57, product=570
-(alarm-mega) thread 0: duration=10, iteration=58, product=580
-(alarm-mega) thread 1: duration=20, iteration=29, product=580
-(alarm-mega) thread 0: duration=10, iteration=59, product=590
-(alarm-mega) thread 4: duration=50, iteration=12, product=600
-(alarm-mega) thread 0: duration=10, iteration=60, product=600
-(alarm-mega) thread 1: duration=20, iteration=30, product=600
-(alarm-mega) thread 2: duration=30, iteration=20, product=600
-(alarm-mega) thread 3: duration=40, iteration=15, product=600
-(alarm-mega) thread 0: duration=10, iteration=61, product=610
-(alarm-mega) thread 0: duration=10, iteration=62, product=620
-(alarm-mega) thread 1: duration=20, iteration=31, product=620
-(alarm-mega) thread 0: duration=10, iteration=63, product=630
-(alarm-mega) thread 2: duration=30, iteration=21, product=630
-(alarm-mega) thread 0: duration=10, iteration=64, product=640
-(alarm-mega) thread 1: duration=20, iteration=32, product=640
-(alarm-mega) thread 3: duration=40, iteration=16, product=640
-(alarm-mega) thread 0: duration=10, iteration=65, product=650
-(alarm-mega) thread 4: duration=50, iteration=13, product=650
-(alarm-mega) thread 0: duration=10, iteration=66, product=660
-(alarm-mega) thread 1: duration=20, iteration=33, product=660
-(alarm-mega) thread 2: duration=30, iteration=22, product=660
-(alarm-mega) thread 0: duration=10, iteration=67, product=670
-(alarm-mega) thread 3: duration=40, iteration=17, product=680
-(alarm-mega) thread 0: duration=10, iteration=68, product=680
-(alarm-mega) thread 1: duration=20, iteration=34, product=680
-(alarm-mega) thread 0: duration=10, iteration=69, product=690
-(alarm-mega) thread 2: duration=30, iteration=23, product=690
-(alarm-mega) thread 0: duration=10, iteration=70, product=700
-(alarm-mega) thread 1: duration=20, iteration=35, product=700
-(alarm-mega) thread 4: duration=50, iteration=14, product=700
-(alarm-mega) thread 1: duration=20, iteration=36, product=720
-(alarm-mega) thread 2: duration=30, iteration=24, product=720
-(alarm-mega) thread 3: duration=40, iteration=18, product=720
-(alarm-mega) thread 1: duration=20, iteration=37, product=740
-(alarm-mega) thread 4: duration=50, iteration=15, product=750
-(alarm-mega) thread 2: duration=30, iteration=25, product=750
-(alarm-mega) thread 3: duration=40, iteration=19, product=760
-(alarm-mega) thread 1: duration=20, iteration=38, product=760
-(alarm-mega) thread 2: duration=30, iteration=26, product=780
-(alarm-mega) thread 1: duration=20, iteration=39, product=780
-(alarm-mega) thread 1: duration=20, iteration=40, product=800
-(alarm-mega) thread 3: duration=40, iteration=20, product=800
-(alarm-mega) thread 4: duration=50, iteration=16, product=800
-(alarm-mega) thread 2: duration=30, iteration=27, product=810
-(alarm-mega) thread 1: duration=20, iteration=41, product=820
-(alarm-mega) thread 1: duration=20, iteration=42, product=840
-(alarm-mega) thread 2: duration=30, iteration=28, product=840
-(alarm-mega) thread 3: duration=40, iteration=21, product=840
-(alarm-mega) thread 4: duration=50, iteration=17, product=850
-(alarm-mega) thread 1: duration=20, iteration=43, product=860
-(alarm-mega) thread 2: duration=30, iteration=29, product=870
-(alarm-mega) thread 1: duration=20, iteration=44, product=880
-(alarm-mega) thread 3: duration=40, iteration=22, product=880
-(alarm-mega) thread 1: duration=20, iteration=45, product=900
-(alarm-mega) thread 2: duration=30, iteration=30, product=900
-(alarm-mega) thread 4: duration=50, iteration=18, product=900
-(alarm-mega) thread 3: duration=40, iteration=23, product=920
-(alarm-mega) thread 1: duration=20, iteration=46, product=920
-(alarm-mega) thread 2: duration=30, iteration=31, product=930
-(alarm-mega) thread 1: duration=20, iteration=47, product=940
-(alarm-mega) thread 4: duration=50, iteration=19, product=950
-(alarm-mega) thread 1: duration=20, iteration=48, product=960
-(alarm-mega) thread 2: duration=30, iteration=32, product=960
-(alarm-mega) thread 3: duration=40, iteration=24, product=960
-(alarm-mega) thread 1: duration=20, iteration=49, product=980
-(alarm-mega) thread 2: duration=30, iteration=33, product=990
-(alarm-mega) thread 3: duration=40, iteration=25, product=1000
-(alarm-mega) thread 4: duration=50, iteration=20, product=1000
-(alarm-mega) thread 1: duration=20, iteration=50, product=1000
-(alarm-mega) thread 2: duration=30, iteration=34, product=1020
-(alarm-mega) thread 1: duration=20, iteration=51, product=1020
-(alarm-mega) thread 1: duration=20, iteration=52, product=1040
-(alarm-mega) thread 3: duration=40, iteration=26, product=1040
-(alarm-mega) thread 2: duration=30, iteration=35, product=1050
-(alarm-mega) thread 4: duration=50, iteration=21, product=1050
-(alarm-mega) thread 1: duration=20, iteration=53, product=1060
-(alarm-mega) thread 1: duration=20, iteration=54, product=1080
-(alarm-mega) thread 2: duration=30, iteration=36, product=1080
-(alarm-mega) thread 3: duration=40, iteration=27, product=1080
-(alarm-mega) thread 4: duration=50, iteration=22, product=1100
-(alarm-mega) thread 1: duration=20, iteration=55, product=1100
-(alarm-mega) thread 2: duration=30, iteration=37, product=1110
-(alarm-mega) thread 1: duration=20, iteration=56, product=1120
-(alarm-mega) thread 3: duration=40, iteration=28, product=1120
-(alarm-mega) thread 1: duration=20, iteration=57, product=1140
-(alarm-mega) thread 2: duration=30, iteration=38, product=1140
-(alarm-mega) thread 4: duration=50, iteration=23, product=1150
-(alarm-mega) thread 3: duration=40, iteration=29, product=1160
-(alarm-mega) thread 1: duration=20, iteration=58, product=1160
-(alarm-mega) thread 2: duration=30, iteration=39, product=1170
-(alarm-mega) thread 1: duration=20, iteration=59, product=1180
-(alarm-mega) thread 2: duration=30, iteration=40, product=1200
-(alarm-mega) thread 3: duration=40, iteration=30, product=1200
-(alarm-mega) thread 4: duration=50, iteration=24, product=1200
-(alarm-mega) thread 1: duration=20, iteration=60, product=1200
-(alarm-mega) thread 1: duration=20, iteration=61, product=1220
-(alarm-mega) thread 2: duration=30, iteration=41, product=1230
-(alarm-mega) thread 1: duration=20, iteration=62, product=1240
-(alarm-mega) thread 3: duration=40, iteration=31, product=1240
-(alarm-mega) thread 4: duration=50, iteration=25, product=1250
-(alarm-mega) thread 2: duration=30, iteration=42, product=1260
-(alarm-mega) thread 1: duration=20, iteration=63, product=1260
-(alarm-mega) thread 1: duration=20, iteration=64, product=1280
-(alarm-mega) thread 3: duration=40, iteration=32, product=1280
-(alarm-mega) thread 2: duration=30, iteration=43, product=1290
-(alarm-mega) thread 1: duration=20, iteration=65, product=1300
-(alarm-mega) thread 4: duration=50, iteration=26, product=1300
-(alarm-mega) thread 1: duration=20, iteration=66, product=1320
-(alarm-mega) thread 2: duration=30, iteration=44, product=1320
-(alarm-mega) thread 3: duration=40, iteration=33, product=1320
-(alarm-mega) thread 1: duration=20, iteration=67, product=1340
-(alarm-mega) thread 2: duration=30, iteration=45, product=1350
-(alarm-mega) thread 4: duration=50, iteration=27, product=1350
-(alarm-mega) thread 1: duration=20, iteration=68, product=1360
-(alarm-mega) thread 3: duration=40, iteration=34, product=1360
-(alarm-mega) thread 1: duration=20, iteration=69, product=1380
-(alarm-mega) thread 2: duration=30, iteration=46, product=1380
-(alarm-mega) thread 1: duration=20, iteration=70, product=1400
-(alarm-mega) thread 3: duration=40, iteration=35, product=1400
-(alarm-mega) thread 4: duration=50, iteration=28, product=1400
-(alarm-mega) thread 2: duration=30, iteration=47, product=1410
-(alarm-mega) thread 2: duration=30, iteration=48, product=1440
-(alarm-mega) thread 3: duration=40, iteration=36, product=1440
-(alarm-mega) thread 4: duration=50, iteration=29, product=1450
-(alarm-mega) thread 2: duration=30, iteration=49, product=1470
-(alarm-mega) thread 3: duration=40, iteration=37, product=1480
-(alarm-mega) thread 2: duration=30, iteration=50, product=1500
-(alarm-mega) thread 4: duration=50, iteration=30, product=1500
-(alarm-mega) thread 3: duration=40, iteration=38, product=1520
-(alarm-mega) thread 2: duration=30, iteration=51, product=1530
-(alarm-mega) thread 4: duration=50, iteration=31, product=1550
-(alarm-mega) thread 2: duration=30, iteration=52, product=1560
-(alarm-mega) thread 3: duration=40, iteration=39, product=1560
-(alarm-mega) thread 2: duration=30, iteration=53, product=1590
-(alarm-mega) thread 3: duration=40, iteration=40, product=1600
-(alarm-mega) thread 4: duration=50, iteration=32, product=1600
-(alarm-mega) thread 2: duration=30, iteration=54, product=1620
-(alarm-mega) thread 3: duration=40, iteration=41, product=1640
-(alarm-mega) thread 4: duration=50, iteration=33, product=1650
-(alarm-mega) thread 2: duration=30, iteration=55, product=1650
-(alarm-mega) thread 2: duration=30, iteration=56, product=1680
-(alarm-mega) thread 3: duration=40, iteration=42, product=1680
-(alarm-mega) thread 4: duration=50, iteration=34, product=1700
-(alarm-mega) thread 2: duration=30, iteration=57, product=1710
-(alarm-mega) thread 3: duration=40, iteration=43, product=1720
-(alarm-mega) thread 2: duration=30, iteration=58, product=1740
-(alarm-mega) thread 4: duration=50, iteration=35, product=1750
-(alarm-mega) thread 3: duration=40, iteration=44, product=1760
-(alarm-mega) thread 2: duration=30, iteration=59, product=1770
-(alarm-mega) thread 3: duration=40, iteration=45, product=1800
-(alarm-mega) thread 4: duration=50, iteration=36, product=1800
-(alarm-mega) thread 2: duration=30, iteration=60, product=1800
-(alarm-mega) thread 2: duration=30, iteration=61, product=1830
-(alarm-mega) thread 3: duration=40, iteration=46, product=1840
-(alarm-mega) thread 4: duration=50, iteration=37, product=1850
-(alarm-mega) thread 2: duration=30, iteration=62, product=1860
-(alarm-mega) thread 3: duration=40, iteration=47, product=1880
-(alarm-mega) thread 2: duration=30, iteration=63, product=1890
-(alarm-mega) thread 4: duration=50, iteration=38, product=1900
-(alarm-mega) thread 3: duration=40, iteration=48, product=1920
-(alarm-mega) thread 2: duration=30, iteration=64, product=1920
-(alarm-mega) thread 2: duration=30, iteration=65, product=1950
-(alarm-mega) thread 4: duration=50, iteration=39, product=1950
-(alarm-mega) thread 3: duration=40, iteration=49, product=1960
-(alarm-mega) thread 2: duration=30, iteration=66, product=1980
-(alarm-mega) thread 4: duration=50, iteration=40, product=2000
-(alarm-mega) thread 3: duration=40, iteration=50, product=2000
-(alarm-mega) thread 2: duration=30, iteration=67, product=2010
-(alarm-mega) thread 2: duration=30, iteration=68, product=2040
-(alarm-mega) thread 3: duration=40, iteration=51, product=2040
-(alarm-mega) thread 4: duration=50, iteration=41, product=2050
-(alarm-mega) thread 2: duration=30, iteration=69, product=2070
-(alarm-mega) thread 3: duration=40, iteration=52, product=2080
-(alarm-mega) thread 4: duration=50, iteration=42, product=2100
-(alarm-mega) thread 2: duration=30, iteration=70, product=2100
-(alarm-mega) thread 3: duration=40, iteration=53, product=2120
-(alarm-mega) thread 4: duration=50, iteration=43, product=2150
-(alarm-mega) thread 3: duration=40, iteration=54, product=2160
-(alarm-mega) thread 3: duration=40, iteration=55, product=2200
-(alarm-mega) thread 4: duration=50, iteration=44, product=2200
-(alarm-mega) thread 3: duration=40, iteration=56, product=2240
-(alarm-mega) thread 4: duration=50, iteration=45, product=2250
-(alarm-mega) thread 3: duration=40, iteration=57, product=2280
-(alarm-mega) thread 4: duration=50, iteration=46, product=2300
-(alarm-mega) thread 3: duration=40, iteration=58, product=2320
-(alarm-mega) thread 4: duration=50, iteration=47, product=2350
-(alarm-mega) thread 3: duration=40, iteration=59, product=2360
-(alarm-mega) thread 3: duration=40, iteration=60, product=2400
-(alarm-mega) thread 4: duration=50, iteration=48, product=2400
-(alarm-mega) thread 3: duration=40, iteration=61, product=2440
-(alarm-mega) thread 4: duration=50, iteration=49, product=2450
-(alarm-mega) thread 3: duration=40, iteration=62, product=2480
-(alarm-mega) thread 4: duration=50, iteration=50, product=2500
-(alarm-mega) thread 3: duration=40, iteration=63, product=2520
-(alarm-mega) thread 4: duration=50, iteration=51, product=2550
-(alarm-mega) thread 3: duration=40, iteration=64, product=2560
-(alarm-mega) thread 3: duration=40, iteration=65, product=2600
-(alarm-mega) thread 4: duration=50, iteration=52, product=2600
-(alarm-mega) thread 3: duration=40, iteration=66, product=2640
-(alarm-mega) thread 4: duration=50, iteration=53, product=2650
-(alarm-mega) thread 3: duration=40, iteration=67, product=2680
-(alarm-mega) thread 4: duration=50, iteration=54, product=2700
-(alarm-mega) thread 3: duration=40, iteration=68, product=2720
-(alarm-mega) thread 4: duration=50, iteration=55, product=2750
-(alarm-mega) thread 3: duration=40, iteration=69, product=2760
-(alarm-mega) thread 3: duration=40, iteration=70, product=2800
-(alarm-mega) thread 4: duration=50, iteration=56, product=2800
-(alarm-mega) thread 4: duration=50, iteration=57, product=2850
-(alarm-mega) thread 4: duration=50, iteration=58, product=2900
-(alarm-mega) thread 4: duration=50, iteration=59, product=2950
-(alarm-mega) thread 4: duration=50, iteration=60, product=3000
-(alarm-mega) thread 4: duration=50, iteration=61, product=3050
-(alarm-mega) thread 4: duration=50, iteration=62, product=3100
-(alarm-mega) thread 4: duration=50, iteration=63, product=3150
-(alarm-mega) thread 4: duration=50, iteration=64, product=3200
-(alarm-mega) thread 4: duration=50, iteration=65, product=3250
-(alarm-mega) thread 4: duration=50, iteration=66, product=3300
-(alarm-mega) thread 4: duration=50, iteration=67, product=3350
-(alarm-mega) thread 4: duration=50, iteration=68, product=3400
-(alarm-mega) thread 4: duration=50, iteration=69, product=3450
-(alarm-mega) thread 4: duration=50, iteration=70, product=3500
-(alarm-mega) end
-Execution of 'alarm-mega' complete.
View
1,713 src/tests/Algorithm/Diff.pm
@@ -1,1713 +0,0 @@
-package Algorithm::Diff;
-# Skip to first "=head" line for documentation.
-use strict;
-
-use integer; # see below in _replaceNextLargerWith() for mod to make
- # if you don't use this
-use vars qw( $VERSION @EXPORT_OK );
-$VERSION = 1.19_01;
-# ^ ^^ ^^-- Incremented at will
-# | \+----- Incremented for non-trivial changes to features
-# \-------- Incremented for fundamental changes
-require Exporter;
-*import = \&Exporter::import;
-@EXPORT_OK = qw(
- prepare LCS LCDidx LCS_length
- diff sdiff compact_diff
- traverse_sequences traverse_balanced
-);
-
-# McIlroy-Hunt diff algorithm
-# Adapted from the Smalltalk code of Mario I. Wolczko, <mario@wolczko.com>
-# by Ned Konz, perl@bike-nomad.com
-# Updates by Tye McQueen, http://perlmonks.org/?node=tye
-
-# Create a hash that maps each element of $aCollection to the set of
-# positions it occupies in $aCollection, restricted to the elements
-# within the range of indexes specified by $start and $end.
-# The fourth parameter is a subroutine reference that will be called to
-# generate a string to use as a key.
-# Additional parameters, if any, will be passed to this subroutine.
-#
-# my $hashRef = _withPositionsOfInInterval( \@array, $start, $end, $keyGen );
-
-sub _withPositionsOfInInterval
-{
- my $aCollection = shift; # array ref
- my $start = shift;
- my $end = shift;
- my $keyGen = shift;
- my %d;
- my $index;
- for ( $index = $start ; $index <= $end ; $index++ )
- {
- my $element = $aCollection->[$index];
- my $key = &$keyGen( $element, @_ );
- if ( exists( $d{$key} ) )
- {
- unshift ( @{ $d{$key} }, $index );
- }
- else
- {
- $d{$key} = [$index];
- }
- }
- return wantarray ? %d : \%d;
-}
-
-# Find the place at which aValue would normally be inserted into the
-# array. If that place is already occupied by aValue, do nothing, and
-# return undef. If the place does not exist (i.e., it is off the end of
-# the array), add it to the end, otherwise replace the element at that
-# point with aValue. It is assumed that the array's values are numeric.
-# This is where the bulk (75%) of the time is spent in this module, so
-# try to make it fast!
-
-sub _replaceNextLargerWith
-{
- my ( $array, $aValue, $high ) = @_;
- $high ||= $#$array;
-
- # off the end?
- if ( $high == -1 || $aValue > $array->[-1] )
- {
- push ( @$array, $aValue );
- return $high + 1;
- }
-
- # binary search for insertion point...
- my $low = 0;
- my $index;
- my $found;
- while ( $low <= $high )
- {
- $index = ( $high + $low ) / 2;
-
- # $index = int(( $high + $low ) / 2); # without 'use integer'
- $found = $array->[$index];
-
- if ( $aValue == $found )
- {
- return undef;
- }
- elsif ( $aValue > $found )
- {
- $low = $index + 1;
- }
- else
- {
- $high = $index - 1;
- }
- }
-
- # now insertion point is in $low.
- $array->[$low] = $aValue; # overwrite next larger
- return $low;
-}
-
-# This method computes the longest common subsequence in $a and $b.
-
-# Result is array or ref, whose contents is such that
-# $a->[ $i ] == $b->[ $result[ $i ] ]
-# foreach $i in ( 0 .. $#result ) if $result[ $i ] is defined.
-
-# An additional argument may be passed; this is a hash or key generating
-# function that should return a string that uniquely identifies the given
-# element. It should be the case that if the key is the same, the elements
-# will compare the same. If this parameter is undef or missing, the key
-# will be the element as a string.
-
-# By default, comparisons will use "eq" and elements will be turned into keys
-# using the default stringizing operator '""'.
-
-# Additional parameters, if any, will be passed to the key generation
-# routine.
-
-sub _longestCommonSubsequence
-{
- my $a = shift; # array ref or hash ref
- my $b = shift; # array ref or hash ref
- my $counting = shift; # scalar
- my $keyGen = shift; # code ref
- my $compare; # code ref
-
- if ( ref($a) eq 'HASH' )
- { # prepared hash must be in $b
- my $tmp = $b;
- $b = $a;
- $a = $tmp;
- }
-
- # Check for bogus (non-ref) argument values
- if ( !ref($a) || !ref($b) )
- {
- my @callerInfo = caller(1);
- die 'error: must pass array or hash references to ' . $callerInfo[3];
- }
-
- # set up code refs
- # Note that these are optimized.
- if ( !defined($keyGen) ) # optimize for strings
- {
- $keyGen = sub { $_[0] };
- $compare = sub { my ( $a, $b ) = @_; $a eq $b };
- }
- else
- {
- $compare = sub {
- my $a = shift;
- my $b = shift;
- &$keyGen( $a, @_ ) eq &$keyGen( $b, @_ );
- };
- }
-
- my ( $aStart, $aFinish, $matchVector ) = ( 0, $#$a, [] );
- my ( $prunedCount, $bMatches ) = ( 0, {} );
-
- if ( ref($b) eq 'HASH' ) # was $bMatches prepared for us?
- {
- $bMatches = $b;
- }
- else
- {
- my ( $bStart, $bFinish ) = ( 0, $#$b );
-
- # First we prune off any common elements at the beginning
- while ( $aStart <= $aFinish
- and $bStart <= $bFinish
- and &$compare( $a->[$aStart], $b->[$bStart], @_ ) )
- {
- $matchVector->[ $aStart++ ] = $bStart++;
- $prunedCount++;
- }
-
- # now the end
- while ( $aStart <= $aFinish
- and $bStart <= $bFinish
- and &$compare( $a->[$aFinish], $b->[$bFinish], @_ ) )
- {
- $matchVector->[ $aFinish-- ] = $bFinish--;
- $prunedCount++;
- }
-
- # Now compute the equivalence classes of positions of elements
- $bMatches =
- _withPositionsOfInInterval( $b, $bStart, $bFinish, $keyGen, @_ );
- }
- my $thresh = [];
- my $links = [];
-
- my ( $i, $ai, $j, $k );
- for ( $i = $aStart ; $i <= $aFinish ; $i++ )
- {
- $ai = &$keyGen( $a->[$i], @_ );
- if ( exists( $bMatches->{$ai} ) )
- {
- $k = 0;
- for $j ( @{ $bMatches->{$ai} } )
- {
-
- # optimization: most of the time this will be true
- if ( $k and $thresh->[$k] > $j and $thresh->[ $k - 1 ] < $j )
- {
- $thresh->[$k] = $j;
- }
- else
- {
- $k = _replaceNextLargerWith( $thresh, $j, $k );
- }
-
- # oddly, it's faster to always test this (CPU cache?).
- if ( defined($k) )
- {
- $links->[$k] =
- [ ( $k ? $links->[ $k - 1 ] : undef ), $i, $j ];
- }
- }
- }
- }
-
- if (@$thresh)
- {
- return $prunedCount + @$thresh if $counting;
- for ( my $link = $links->[$#$thresh] ; $link ; $link = $link->[0] )
- {
- $matchVector->[ $link->[1] ] = $link->[2];
- }
- }
- elsif ($counting)
- {
- return $prunedCount;
- }
-
- return wantarray ? @$matchVector : $matchVector;
-}
-
-sub traverse_sequences
-{
- my $a = shift; # array ref
- my $b = shift; # array ref
- my $callbacks = shift || {};
- my $keyGen = shift;
- my $matchCallback = $callbacks->{'MATCH'} || sub { };
- my $discardACallback = $callbacks->{'DISCARD_A'} || sub { };
- my $finishedACallback = $callbacks->{'A_FINISHED'};
- my $discardBCallback = $callbacks->{'DISCARD_B'} || sub { };
- my $finishedBCallback = $callbacks->{'B_FINISHED'};
- my $matchVector = _longestCommonSubsequence( $a, $b, 0, $keyGen, @_ );
-
- # Process all the lines in @$matchVector
- my $lastA = $#$a;
- my $lastB = $#$b;
- my $bi = 0;
- my $ai;
-
- for ( $ai = 0 ; $ai <= $#$matchVector ; $ai++ )
- {
- my $bLine = $matchVector->[$ai];
- if ( defined($bLine) ) # matched
- {
- &$discardBCallback( $ai, $bi++, @_ ) while $bi < $bLine;
- &$matchCallback( $ai, $bi++, @_ );
- }
- else
- {
- &$discardACallback( $ai, $bi, @_ );
- }
- }
-
- # The last entry (if any) processed was a match.
- # $ai and $bi point just past the last matching lines in their sequences.
-
- while ( $ai <= $lastA or $bi <= $lastB )
- {
-
- # last A?
- if ( $ai == $lastA + 1 and $bi <= $lastB )
- {
- if ( defined($finishedACallback) )
- {
- &$finishedACallback( $lastA, @_ );
- $finishedACallback = undef;
- }
- else
- {
- &$discardBCallback( $ai, $bi++, @_ ) while $bi <= $lastB;
- }
- }
-
- # last B?
- if ( $bi == $lastB + 1 and $ai <= $lastA )
- {
- if ( defined($finishedBCallback) )
- {
- &$finishedBCallback( $lastB, @_ );
- $finishedBCallback = undef;
- }
- else
- {
- &$discardACallback( $ai++, $bi, @_ ) while $ai <= $lastA;
- }
- }
-
- &$discardACallback( $ai++, $bi, @_ ) if $ai <= $lastA;
- &$discardBCallback( $ai, $bi++, @_ ) if $bi <= $lastB;
- }
-
- return 1;
-}
-
-sub traverse_balanced
-{
- my $a = shift; # array ref
- my $b = shift; # array ref
- my $callbacks = shift || {};
- my $keyGen = shift;
- my $matchCallback = $callbacks->{'MATCH'} || sub { };
- my $discardACallback = $callbacks->{'DISCARD_A'} || sub { };
- my $discardBCallback = $callbacks->{'DISCARD_B'} || sub { };
- my $changeCallback = $callbacks->{'CHANGE'};
- my $matchVector = _longestCommonSubsequence( $a, $b, 0, $keyGen, @_ );
-
- # Process all the lines in match vector
- my $lastA = $#$a;
- my $lastB = $#$b;
- my $bi = 0;
- my $ai = 0;
- my $ma = -1;
- my $mb;
-
- while (1)
- {
-
- # Find next match indices $ma and $mb
- do {
- $ma++;
- } while(
- $ma <= $#$matchVector
- && !defined $matchVector->[$ma]
- );
-
- last if $ma > $#$matchVector; # end of matchVector?
- $mb = $matchVector->[$ma];
-
- # Proceed with discard a/b or change events until
- # next match
- while ( $ai < $ma || $bi < $mb )
- {
-
- if ( $ai < $ma && $bi < $mb )
- {
-
- # Change
- if ( defined $changeCallback )
- {
- &$changeCallback( $ai++, $bi++, @_ );
- }
- else
- {
- &$discardACallback( $ai++, $bi, @_ );
- &$discardBCallback( $ai, $bi++, @_ );
- }
- }
- elsif ( $ai < $ma )
- {
- &$discardACallback( $ai++, $bi, @_ );
- }
- else
- {
-
- # $bi < $mb
- &$discardBCallback( $ai, $bi++, @_ );
- }
- }
-
- # Match
- &$matchCallback( $ai++, $bi++, @_ );
- }
-
- while ( $ai <= $lastA || $bi <= $lastB )
- {
- if ( $ai <= $lastA && $bi <= $lastB )
- {
-
- # Change
- if ( defined $changeCallback )
- {
- &$changeCallback( $ai++, $bi++, @_ );
- }
- else
- {
- &$discardACallback( $ai++, $bi, @_ );
- &$discardBCallback( $ai, $bi++, @_ );
- }
- }
- elsif ( $ai <= $lastA )
- {
- &$discardACallback( $ai++, $bi, @_ );
- }
- else
- {
-
- # $bi <= $lastB
- &$discardBCallback( $ai, $bi++, @_ );
- }
- }
-
- return 1;
-}
-
-sub prepare
-{
- my $a = shift; # array ref
- my $keyGen = shift; # code ref
-
- # set up code ref
- $keyGen = sub { $_[0] } unless defined($keyGen);
-
- return scalar _withPositionsOfInInterval( $a, 0, $#$a, $keyGen, @_ );
-}
-
-sub LCS
-{
- my $a = shift; # array ref
- my $b = shift; # array ref or hash ref
- my $matchVector = _longestCommonSubsequence( $a, $b, 0, @_ );
- my @retval;
- my $i;
- for ( $i = 0 ; $i <= $#$matchVector ; $i++ )
- {
- if ( defined( $matchVector->[$i] ) )
- {
- push ( @retval, $a->[$i] );
- }
- }
- return wantarray ? @retval : \@retval;
-}
-
-sub LCS_length
-{
- my $a = shift; # array ref
- my $b = shift; # array ref or hash ref
- return _longestCommonSubsequence( $a, $b, 1, @_ );
-}
-
-sub LCSidx
-{
- my $a= shift @_;
- my $b= shift @_;
- my $match= _longestCommonSubsequence( $a, $b, 0, @_ );
- my @am= grep defined $match->[$_], 0..$#$match;
- my @bm= @{$match}[@am];
- return \@am, \@bm;
-}
-
-sub compact_diff
-{
- my $a= shift @_;
- my $b= shift @_;
- my( $am, $bm )= LCSidx( $a, $b, @_ );
- my @cdiff;
- my( $ai, $bi )= ( 0, 0 );
- push @cdiff, $ai, $bi;
- while( 1 ) {
- while( @$am && $ai == $am->[0] && $bi == $bm->[0] ) {
- shift @$am;
- shift @$bm;
- ++$ai, ++$bi;
- }
- push @cdiff, $ai, $bi;
- last if ! @$am;
- $ai = $am->[0];
- $bi = $bm->[0];
- push @cdiff, $ai, $bi;
- }
- push @cdiff, 0+@$a, 0+@$b
- if $ai < @$a || $bi < @$b;
- return wantarray ? @cdiff : \@cdiff;
-}
-
-sub diff
-{
- my $a = shift; # array ref
- my $b = shift; # array ref
- my $retval = [];
- my $hunk = [];
- my $discard = sub {
- push @$hunk, [ '-', $_[0], $a->[ $_[0] ] ];
- };
- my $add = sub {
- push @$hunk, [ '+', $_[1], $b->[ $_[1] ] ];
- };
- my $match = sub {
- push @$retval, $hunk
- if 0 < @$hunk;
- $hunk = []
- };
- traverse_sequences( $a, $b,
- { MATCH => $match, DISCARD_A => $discard, DISCARD_B => $add }, @_ );
- &$match();
- return wantarray ? @$retval : $retval;
-}
-
-sub sdiff
-{
- my $a = shift; # array ref
- my $b = shift; # array ref
- my $retval = [];
- my $discard = sub { push ( @$retval, [ '-', $a->[ $_[0] ], "" ] ) };
- my $add = sub { push ( @$retval, [ '+', "", $b->[ $_[1] ] ] ) };
- my $change = sub {
- push ( @$retval, [ 'c', $a->[ $_[0] ], $b->[ $_[1] ] ] );
- };
- my $match = sub {
- push ( @$retval, [ 'u', $a->[ $_[0] ], $b->[ $_[1] ] ] );
- };
- traverse_balanced(
- $a,
- $b,
- {
- MATCH => $match,
- DISCARD_A => $discard,
- DISCARD_B => $add,
- CHANGE => $change,
- },
- @_
- );
- return wantarray ? @$retval : $retval;
-}
-
-########################################
-my $Root= __PACKAGE__;
-package Algorithm::Diff::_impl;
-use strict;
-
-sub _Idx() { 0 } # $me->[_Idx]: Ref to array of hunk indices
- # 1 # $me->[1]: Ref to first sequence
- # 2 # $me->[2]: Ref to second sequence
-sub _End() { 3 } # $me->[_End]: Diff between forward and reverse pos
-sub _Same() { 4 } # $me->[_Same]: 1 if pos 1 contains unchanged items
-sub _Base() { 5 } # $me->[_Base]: Added to range's min and max
-sub _Pos() { 6 } # $me->[_Pos]: Which hunk is currently selected
-sub _Off() { 7 } # $me->[_Off]: Offset into _Idx for current position
-sub _Min() { -2 } # Added to _Off to get min instead of max+1
-
-sub Die
-{
- require Carp;
- Carp::confess( @_ );
-}
-
-sub _ChkPos
-{
- my( $me )= @_;
- return if $me->[_Pos];
- my $meth= ( caller(1) )[3];
- Die( "Called $meth on 'reset' object" );
-}
-
-sub _ChkSeq
-{
- my( $me, $seq )= @_;
- return $seq + $me->[_Off]
- if 1 == $seq || 2 == $seq;
- my $meth= ( caller(1) )[3];
- Die( "$meth: Invalid sequence number ($seq); must be 1 or 2" );
-}
-
-sub getObjPkg
-{
- my( $us )= @_;
- return ref $us if ref $us;
- return $us . "::_obj";
-}
-
-sub new
-{
- my( $us, $seq1, $seq2, $opts ) = @_;
- my @args;
- for( $opts->{keyGen} ) {
- push @args, $_ if $_;
- }
- for( $opts->{keyGenArgs} ) {
- push @args, @$_ if $_;
- }
- my $cdif= Algorithm::Diff::compact_diff( $seq1, $seq2, @args );
- my $same= 1;
- if( 0 == $cdif->[2] && 0 == $cdif->[3] ) {
- $same= 0;
- splice @$cdif, 0, 2;
- }
- my @obj= ( $cdif, $seq1, $seq2 );
- $obj[_End] = (1+@$cdif)/2;
- $obj[_Same] = $same;
- $obj[_Base] = 0;
- my $me = bless \@obj, $us->getObjPkg();
- $me->Reset( 0 );
- return $me;
-}
-
-sub Reset
-{
- my( $me, $pos )= @_;
- $pos= int( $pos || 0 );
- $pos += $me->[_End]
- if $pos < 0;
- $pos= 0
- if $pos < 0 || $me->[_End] <= $pos;
- $me->[_Pos]= $pos || !1;
- $me->[_Off]= 2*$pos - 1;
- return $me;
-}
-
-sub Base
-{
- my( $me, $base )= @_;
- my $oldBase= $me->[_Base];
- $me->[_Base]= 0+$base if defined $base;
- return $oldBase;
-}
-
-sub Copy
-{
- my( $me, $pos, $base )= @_;
- my @obj= @$me;
- my $you= bless \@obj, ref($me);
- $you->Reset( $pos ) if defined $pos;
- $you->Base( $base );
- return $you;
-}
-
-sub Next {
- my( $me, $steps )= @_;
- $steps= 1 if ! defined $steps;
- if( $steps ) {
- my $pos= $me->[_Pos];
- my $new= $pos + $steps;
- $new= 0 if $pos && $new < 0;
- $me->Reset( $new )
- }
- return $me->[_Pos];
-}
-
-sub Prev {
- my( $me, $steps )= @_;
- $steps= 1 if ! defined $steps;
- my $pos= $me->Next(-$steps);
- $pos -= $me->[_End] if $pos;
- return $pos;
-}
-
-sub Diff {
- my( $me )= @_;
- $me->_ChkPos();
- return 0 if $me->[_Same] == ( 1 & $me->[_Pos] );
- my $ret= 0;
- my $off= $me->[_Off];
- for my $seq ( 1, 2 ) {
- $ret |= $seq
- if $me->[_Idx][ $off + $seq + _Min ]
- < $me->[_Idx][ $off + $seq ];
- }
- return $ret;
-}
-
-sub Min {
- my( $me, $seq, $base )= @_;
- $me->_ChkPos();
- my $off= $me->_ChkSeq($seq);
- $base= $me->[_Base] if !defined $base;
- return $base + $me->[_Idx][ $off + _Min ];
-}
-
-sub Max {
- my( $me, $seq, $base )= @_;
- $me->_ChkPos();
- my $off= $me->_ChkSeq($seq);
- $base= $me->[_Base] if !defined $base;
- return $base + $me->[_Idx][ $off ] -1;
-}
-
-sub Range {
- my( $me, $seq, $base )= @_;
- $me->_ChkPos();
- my $off = $me->_ChkSeq($seq);
- if( !wantarray ) {
- return $me->[_Idx][ $off ]
- - $me->[_Idx][ $off + _Min ];
- }
- $base= $me->[_Base] if !defined $base;
- return ( $base + $me->[_Idx][ $off + _Min ] )
- .. ( $base + $me->[_Idx][ $off ] - 1 );
-}
-
-sub Items {
- my( $me, $seq )= @_;
- $me->_ChkPos();
- my $off = $me->_ChkSeq($seq);
- if( !wantarray ) {
- return $me->[_Idx][ $off ]
- - $me->[_Idx][ $off + _Min ];
- }
- return
- @{$me->[$seq]}[
- $me->[_Idx][ $off + _Min ]
- .. ( $me->[_Idx][ $off ] - 1 )
- ];
-}
-
-sub Same {
- my( $me )= @_;
- $me->_ChkPos();
- return wantarray ? () : 0
- if $me->[_Same] != ( 1 & $me->[_Pos] );
- return $me->Items(1);
-}
-
-my %getName;
-BEGIN {
- %getName= (
- same => \&Same,
- diff => \&Diff,
- base => \&Base,
- min => \&Min,
- max => \&Max,
- range=> \&Range,
- items=> \&Items, # same thing
- );
-}
-
-sub Get
-{
- my $me= shift @_;
- $me->_ChkPos();
- my @value;
- for my $arg ( @_ ) {
- for my $word ( split ' ', $arg ) {
- my $meth;
- if( $word !~ /^(-?\d+)?([a-zA-Z]+)([12])?$/
- || not $meth= $getName{ lc $2 }
- ) {
- Die( $Root, ", Get: Invalid request ($word)" );
- }
- my( $base, $name, $seq )= ( $1, $2, $3 );
- push @value, scalar(
- 4 == length($name)
- ? $meth->( $me )
- : $meth->( $me, $seq, $base )
- );
- }
- }
- if( wantarray ) {
- return @value;
- } elsif( 1 == @value ) {
- return $value[0];
- }
- Die( 0+@value, " values requested from ",
- $Root, "'s Get in scalar context" );
-}
-
-
-my $Obj= getObjPkg($Root);
-no strict 'refs';
-
-for my $meth ( qw( new getObjPkg ) ) {
- *{$Root."::".$meth} = \&{$meth};
- *{$Obj ."::".$meth} = \&{$meth};
-}
-for my $meth ( qw(
- Next Prev Reset Copy Base Diff
- Same Items Range Min Max Get
- _ChkPos _ChkSeq
-) ) {
- *{$Obj."::".$meth} = \&{$meth};
-}
-
-1;
-__END__
-
-=head1 NAME
-
-Algorithm::Diff - Compute `intelligent' differences between two files / lists
-
-=head1 SYNOPSIS
-
- require Algorithm::Diff;
-
- # This example produces traditional 'diff' output:
-
- my $diff = Algorithm::Diff->new( \@seq1, \@seq2 );
-
- $diff->Base( 1 ); # Return line numbers, not indices
- while( $diff->Next() ) {
- next if $diff->Same();
- my $sep = '';
- if( ! $diff->Items(2) ) {
- sprintf "%d,%dd%d\n",
- $diff->Get(qw( Min1 Max1 Max2 ));
- } elsif( ! $diff->Items(1) ) {
- sprint "%da%d,%d\n",
- $diff->Get(qw( Max1 Min2 Max2 ));
- } else {
- $sep = "---\n";
- sprintf "%d,%dc%d,%d\n",
- $diff->Get(qw( Min1 Max1 Min2 Max2 ));
- }
- print "< $_" for $diff->Items(1);
- print $sep;
- print "> $_" for $diff->Items(2);
- }
-
-
- # Alternate interfaces:
-
- use Algorithm::Diff qw(
- LCS LCS_length LCSidx
- diff sdiff compact_diff
- traverse_sequences traverse_balanced );
-
- @lcs = LCS( \@seq1, \@seq2 );
- $lcsref = LCS( \@seq1, \@seq2 );
- $count = LCS_length( \@seq1, \@seq2 );
-
- ( $seq1idxref, $seq2idxref ) = LCSidx( \@seq1, \@seq2 );
-
-
- # Complicated interfaces:
-
- @diffs = diff( \@seq1, \@seq2 );
-
- @sdiffs = sdiff( \@seq1, \@seq2 );
-
- @cdiffs = compact_diff( \@seq1, \@seq2 );
-
- traverse_sequences(
- \@seq1,
- \@seq2,
- { MATCH => \&callback1,
- DISCARD_A => \&callback2,
- DISCARD_B => \&callback3,
- },
- \&key_generator,
- @extra_args,
- );
-
- traverse_balanced(
- \@seq1,
- \@seq2,
- { MATCH => \&callback1,
- DISCARD_A => \&callback2,
- DISCARD_B => \&callback3,
- CHANGE => \&callback4,
- },
- \&key_generator,
- @extra_args,
- );
-
-
-=head1 INTRODUCTION
-
-(by Mark-Jason Dominus)
-
-I once read an article written by the authors of C<diff>; they said
-that they worked very hard on the algorithm until they found the
-right one.
-
-I think what they ended up using (and I hope someone will correct me,
-because I am not very confident about this) was the `longest common
-subsequence' method. In the LCS problem, you have two sequences of
-items:
-
- a b c d f g h j q z
-
- a b c d e f g i j k r x y z
-
-and you want to find the longest sequence of items that is present in
-both original sequences in the same order. That is, you want to find
-a new sequence I<S> which can be obtained from the first sequence by
-deleting some items, and from the secend sequence by deleting other
-items. You also want I<S> to be as long as possible. In this case I<S>
-is
-
- a b c d f g j z
-
-From there it's only a small step to get diff-like output:
-
- e h i k q r x y
- + - + + - + + +
-
-This module solves the LCS problem. It also includes a canned function
-to generate C<diff>-like output.
-
-It might seem from the example above that the LCS of two sequences is
-always pretty obvious, but that's not always the case, especially when
-the two sequences have many repeated elements. For example, consider
-
- a x b y c z p d q
- a b c a x b y c z
-
-A naive approach might start by matching up the C<a> and C<b> that
-appear at the beginning of each sequence, like this:
-
- a x b y c z p d q
- a b c a b y c z
-
-This finds the common subsequence C<a b c z>. But actually, the LCS
-is C<a x b y c z>:
-
- a x b y c z p d q
- a b c a x b y c z
-
-or
-
- a x b y c z p d q
- a b c a x b y c z
-
-=head1 USAGE
-
-(See also the README file and several example
-scripts include with this module.)
-
-This module now provides an object-oriented interface that uses less
-memory and is easier to use than most of the previous procedural
-interfaces. It also still provides several exportable functions. We'll
-deal with these in ascending order of difficulty: C<LCS>,
-C<LCS_length>, C<LCSidx>, OO interface, C<prepare>, C<diff>, C<sdiff>,
-C<traverse_sequences>, and C<traverse_balanced>.
-
-=head2 C<LCS>
-
-Given references to two lists of items, LCS returns an array containing
-their longest common subsequence. In scalar context, it returns a
-reference to such a list.
-
- @lcs = LCS( \@seq1, \@seq2 );
- $lcsref = LCS( \@seq1, \@seq2 );
-
-C<LCS> may be passed an optional third parameter; this is a CODE
-reference to a key generation function. See L</KEY GENERATION
-FUNCTIONS>.
-
- @lcs = LCS( \@seq1, \@seq2, \&keyGen, @args );
- $lcsref = LCS( \@seq1, \@seq2, \&keyGen, @args );
-
-Additional parameters, if any, will be passed to the key generation
-routine.
-
-=head2 C<LCS_length>
-
-This is just like C<LCS> except it only returns the length of the
-longest common subsequence. This provides a performance gain of about
-9% compared to C<LCS>.
-
-=head2 C<LCSidx>
-
-Like C<LCS> except it returns references to two arrays. The first array
-contains the indices into @seq1 where the LCS items are located. The
-second array contains the indices into @seq2 where the LCS items are located.
-
-Therefore, the following three lists will contain the same values:
-
- my( $idx1, $idx2 ) = LCSidx( \@seq1, \@seq2 );
- my @list1 = @seq1[ @$idx1 ];
- my @list2 = @seq2[ @$idx2 ];
- my @list3 = LCS( \@seq1, \@seq2 );
-
-=head2 C<new>
-
- $diff = Algorithm::Diffs->new( \@seq1, \@seq2 );
- $diff = Algorithm::Diffs->new( \@seq1, \@seq2, \%opts );
-
-C<new> computes the smallest set of additions and deletions necessary
-to turn the first sequence into the second and compactly records them
-in the object.
-
-You use the object to iterate over I<hunks>, where each hunk represents
-a contiguous section of items which should be added, deleted, replaced,
-or left unchanged.
-
-=over 4
-
-The following summary of all of the methods looks a lot like Perl code
-but some of the symbols have different meanings:
-
- [ ] Encloses optional arguments
- : Is followed by the default value for an optional argument
- | Separates alternate return results
-
-Method summary:
-
- $obj = Algorithm::Diff->new( \@seq1, \@seq2, [ \%opts ] );
- $pos = $obj->Next( [ $count : 1 ] );
- $revPos = $obj->Prev( [ $count : 1 ] );
- $obj = $obj->Reset( [ $pos : 0 ] );
- $copy = $obj->Copy( [ $pos, [ $newBase ] ] );
- $oldBase = $obj->Base( [ $newBase ] );
-
-Note that all of the following methods C<die> if used on an object that
-is "reset" (not currently pointing at any hunk).
-
- $bits = $obj->Diff( );
- @items|$cnt = $obj->Same( );
- @items|$cnt = $obj->Items( $seqNum );
- @idxs |$cnt = $obj->Range( $seqNum, [ $base ] );
- $minIdx = $obj->Min( $seqNum, [ $base ] );
- $maxIdx = $obj->Max( $seqNum, [ $base ] );
- @values = $obj->Get( @names );
-
-Passing in C<undef> for an optional argument is always treated the same
-as if no argument were passed in.
-
-=item C<Next>
-
- $pos = $diff->Next(); # Move forward 1 hunk
- $pos = $diff->Next( 2 ); # Move forward 2 hunks
- $pos = $diff->Next(-5); # Move backward 5 hunks
-
-C<Next> moves the object to point at the next hunk. The object starts
-out "reset", which means it isn't pointing at any hunk. If the object
-is reset, then C<Next()> moves to the first hunk.
-
-C<Next> returns a true value iff the move didn't go past the last hunk.
-So C<Next(0)> will return true iff the object is not reset.
-
-Actually, C<Next> returns the object's new position, which is a number
-between 1 and the number of hunks (inclusive), or returns a false value.
-
-=item C<Prev>
-
-C<Prev($N)> is almost identical to C<Next(-$N)>; it moves to the $Nth
-previous hunk. On a 'reset' object, C<Prev()> [and C<Next(-1)>] move
-to the last hunk.
-
-The position returned by C<Prev> is relative to the I<end> of the
-hunks; -1 for the last hunk, -2 for the second-to-last, etc.
-
-=item C<Reset>
-
- $diff->Reset(); # Reset the object's position
- $diff->Reset($pos); # Move to the specified hunk
- $diff->Reset(1); # Move to the first hunk
- $diff->Reset(-1); # Move to the last hunk
-
-C<Reset> returns the object, so, for example, you could use
-C<< $diff->Reset()->Next(-1) >> to get the number of hunks.
-
-=item C<Copy>
-
- $copy = $diff->Copy( $newPos, $newBase );
-
-C<Copy> returns a copy of the object. The copy and the orignal object
-share most of their data, so making copies takes very little memory.
-The copy maintains its own position (separate from the original), which
-is the main purpose of copies. It also maintains its own base.
-
-By default, the copy's position starts out the same as the original
-object's position. But C<Copy> takes an optional first argument to set the
-new position, so the following three snippets are equivalent:
-
- $copy = $diff->Copy($pos);
-
- $copy = $diff->Copy();
- $copy->Reset($pos);
-
- $copy = $diff->Copy()->Reset($pos);
-
-C<Copy> takes an optional second argument to set the base for
-the copy. If you wish to change the base of the copy but leave
-the position the same as in the original, here are two
-equivalent ways:
-
- $copy = $diff->Copy();
- $copy->Base( 0 );
-
- $copy = $diff->Copy(undef,0);
-
-Here are two equivalent way to get a "reset" copy:
-
- $copy = $diff->Copy(0);
-
- $copy = $diff->Copy()->Reset();
-
-=item C<Diff>
-
- $bits = $obj->Diff();
-
-C<Diff> returns a true value iff the current hunk contains items that are
-different between the two sequences. It actually returns one of the
-follow 4 values:
-
-=over 4
-
-=item 3
-
-C<3==(1|2)>. This hunk contains items from @seq1 and the items
-from @seq2 that should replace them. Both sequence 1 and 2
-contain changed items so both the 1 and 2 bits are set.
-
-=item 2
-
-This hunk only contains items from @seq2 that should be inserted (not
-items from @seq1). Only sequence 2 contains changed items so only the 2
-bit is set.
-
-=item 1
-
-This hunk only contains items from @seq1 that should be deleted (not
-items from @seq2). Only sequence 1 contains changed items so only the 1
-bit is set.
-
-=item 0
-
-This means that the items in this hunk are the same in both sequences.
-Neither sequence 1 nor 2 contain changed items so neither the 1 nor the
-2 bits are set.
-
-=back
-
-=item C<Same>
-
-C<Same> returns a true value iff the current hunk contains items that
-are the same in both sequences. It actually returns the list of items
-if they are the same or an emty list if they aren't. In a scalar
-context, it returns the size of the list.
-
-=item C<Items>
-
- $count = $diff->Items(2);
- @items = $diff->Items($seqNum);
-
-C<Items> returns the (number of) items from the specified sequence that
-are part of the current hunk.
-
-If the current hunk contains only insertions, then
-C<< $diff->Items(1) >> will return an empty list (0 in a scalar conext).
-If the current hunk contains only deletions, then C<< $diff->Items(2) >>
-will return an empty list (0 in a scalar conext).
-
-If the hunk contains replacements, then both C<< $diff->Items(1) >> and
-C<< $diff->Items(2) >> will return different, non-empty lists.
-
-Otherwise, the hunk contains identical items and all of the following
-will return the same lists:
-
- @items = $diff->Items(1);
- @items = $diff->Items(2);
- @items = $diff->Same();
-
-=item C<Range>
-
- $count = $diff->Range( $seqNum );
- @indices = $diff->Range( $seqNum );
- @indices = $diff->Range( $seqNum, $base );
-
-C<Range> is like C<Items> except that it returns a list of I<indices> to
-the items rather than the items themselves. By default, the index of
-the first item (in each sequence) is 0 but this can be changed by
-calling the C<Base> method. So, by default, the following two snippets
-return the same lists:
-
- @list = $diff->Items(2);
- @list = @seq2[ $diff->Range(2) ];
-
-You can also specify the base to use as the second argument. So the
-following two snippets I<always> return the same lists:
-
- @list = $diff->Items(1);
- @list = @seq1[ $diff->Range(1,0) ];
-
-=item C<Base>
-
- $curBase = $diff->Base();
- $oldBase = $diff->Base($newBase);
-
-C<Base> sets and/or returns the current base (usually 0 or 1) that is
-used when you request range information. The base defaults to 0 so
-that range information is returned as array indices. You can set the
-base to 1 if you want to report traditional line numbers instead.
-
-=item C<Min>
-
- $min1 = $diff->Min(1);
- $min = $diff->Min( $seqNum, $base );
-
-C<Min> returns the first value that C<Range> would return (given the
-same arguments) or returns C<undef> if C<Range> would return an empty
-list.
-
-=item C<Max>
-
-C<Max> returns the last value that C<Range> would return or C<undef>.
-
-=item C<Get>
-
- ( $n, $x, $r ) = $diff->Get(qw( min1 max1 range1 ));
- @values = $diff->Get(qw( 0min2 1max2 range2 same base ));
-
-C<Get> returns one or more scalar values. You pass in a list of the
-names of the values you want returned. Each name must match one of the
-following regexes:
-
- /^(-?\d+)?(min|max)[12]$/i
- /^(range[12]|same|diff|base)$/i
-
-The 1 or 2 after a name says which sequence you want the information
-for (and where allowed, it is required). The optional number before
-"min" or "max" is the base to use. So the following equalities hold:
-
- $diff->Get('min1') == $diff->Min(1)
- $diff->Get('0min2') == $diff->Min(2,0)
-
-Using C<Get> in a scalar context when you've passed in more than one
-name is a fatal error (C<die> is called).
-
-=back
-
-=head2 C<prepare>
-
-Given a reference to a list of items, C<prepare> returns a reference
-to a hash which can be used when comparing this sequence to other
-sequences with C<LCS> or C<LCS_length>.
-
- $prep = prepare( \@seq1 );
- for $i ( 0 .. 10_000 )
- {
- @lcs = LCS( $prep, $seq[$i] );
- # do something useful with @lcs
- }
-
-C<prepare> may be passed an optional third parameter; this is a CODE
-reference to a key generation function. See L</KEY GENERATION
-FUNCTIONS>.
-
- $prep = prepare( \@seq1, \&keyGen );
- for $i ( 0 .. 10_000 )
- {
- @lcs = LCS( $seq[$i], $prep, \&keyGen );
- # do something useful with @lcs
- }
-
-Using C<prepare> provides a performance gain of about 50% when calling LCS
-many times compared with not preparing.
-
-=head2 C<diff>
-
- @diffs = diff( \@seq1, \@seq2 );
- $diffs_ref = diff( \@seq1, \@seq2 );
-
-C<diff> computes the smallest set of additions and deletions necessary
-to turn the first sequence into the second, and returns a description
-of these changes. The description is a list of I<hunks>; each hunk
-represents a contiguous section of items which should be added,
-deleted, or replaced. (Hunks containing unchanged items are not
-included.)
-
-The return value of C<diff> is a list of hunks, or, in scalar context, a
-reference to such a list. If there are no differences, the list will be
-empty.
-
-Here is an example. Calling C<diff> for the following two sequences:
-
- a b c e h j l m n p
- b c d e f j k l m r s t
-
-would produce the following list:
-
- (
- [ [ '-', 0, 'a' ] ],
-
- [ [ '+', 2, 'd' ] ],
-
- [ [ '-', 4, 'h' ],
- [ '+', 4, 'f' ] ],
-
- [ [ '+', 6, 'k' ] ],
-
- [ [ '-', 8, 'n' ],
- [ '-', 9, 'p' ],
- [ '+', 9, 'r' ],
- [ '+', 10, 's' ],
- [ '+', 11, 't' ] ],
- )
-
-There are five hunks here. The first hunk says that the C<a> at
-position 0 of the first sequence should be deleted (C<->). The second
-hunk says that the C<d> at position 2 of the second sequence should
-be inserted (C<+>). The third hunk says that the C<h> at position 4
-of the first sequence should be removed and replaced with the C<f>
-from position 4 of the second sequence. And so on.
-
-C<diff> may be passed an optional third parameter; this is a CODE
-reference to a key generation function. See L</KEY GENERATION
-FUNCTIONS>.
-
-Additional parameters, if any, will be passed to the key generation
-routine.
-
-=head2 C<sdiff>
-
- @sdiffs = sdiff( \@seq1, \@seq2 );
- $sdiffs_ref = sdiff( \@seq1, \@seq2 );
-
-C<sdiff> computes all necessary components to show two sequences
-and their minimized differences side by side, just like the
-Unix-utility I<sdiff> does:
-
- same same
- before | after
- old < -
- - > new
-
-It returns a list of array refs, each pointing to an array of
-display instructions. In scalar context it returns a reference
-to such a list. If there are no differences, the list will have one
-entry per item, each indicating that the item was unchanged.
-
-Display instructions consist of three elements: A modifier indicator
-(C<+>: Element added, C<->: Element removed, C<u>: Element unmodified,
-C<c>: Element changed) and the value of the old and new elements, to
-be displayed side-by-side.
-
-An C<sdiff> of the following two sequences:
-
- a b c e h j l m n p
- b c d e f j k l m r s t
-
-results in
-
- ( [ '-', 'a', '' ],
- [ 'u', 'b', 'b' ],
- [ 'u', 'c', 'c' ],
- [ '+', '', 'd' ],
- [ 'u', 'e', 'e' ],
- [ 'c', 'h', 'f' ],
- [ 'u', 'j', 'j' ],
- [ '+', '', 'k' ],
- [ 'u', 'l', 'l' ],
- [ 'u', 'm', 'm' ],
- [ 'c', 'n', 'r' ],
- [ 'c', 'p', 's' ],
- [ '+', '', 't' ],
- )
-
-C<sdiff> may be passed an optional third parameter; this is a CODE
-reference to a key generation function. See L</KEY GENERATION
-FUNCTIONS>.
-
-Additional parameters, if any, will be passed to the key generation
-routine.
-
-=head2 C<compact_diff>
-
-C<compact_diff> is much like C<sdiff> except it returns a much more
-compact description consisting of just one flat list of indices. An
-example helps explain the format:
-
- my @a = qw( a b c e h j l m n p );
- my @b = qw( b c d e f j k l m r s t );
- @cdiff = compact_diff( \@a, \@b );
- # Returns:
- # @a @b @a @b
- # start start values values
- ( 0, 0, # =
- 0, 0, # a !
- 1, 0, # b c = b c
- 3, 2, # ! d
- 3, 3, # e = e
- 4, 4, # f ! h
- 5, 5, # j = j
- 6, 6, # ! k
- 6, 7, # l m = l m
- 8, 9, # n p ! r s t
- 10, 12, #
- );
-
-The 0th, 2nd, 4th, etc. entries are all indices into @seq1 (@a in the
-above example) indicating where a hunk begins. The 1st, 3rd, 5th, etc.
-entries are all indices into @seq2 (@b in the above example) indicating
-where the same hunk begins.
-
-So each pair of indices (except the last pair) describes where a hunk
-begins (in each sequence). Since each hunk must end at the item just
-before the item that starts the next hunk, the next pair of indices can
-be used to determine where the hunk ends.
-
-So, the first 4 entries (0..3) describe the first hunk. Entries 0 and 1
-describe where the first hunk begins (and so are always both 0).
-Entries 2 and 3 describe where the next hunk begins, so subtracting 1
-from each tells us where the first hunk ends. That is, the first hunk
-contains items C<$diff[0]> through C<$diff[2] - 1> of the first sequence
-and contains items C<$diff[1]> through C<$diff[3] - 1> of the second
-sequence.
-
-In other words, the first hunk consists of the following two lists of items:
-
- # 1st pair 2nd pair
- # of indices of indices
- @list1 = @a[ $cdiff[0] .. $cdiff[2]-1 ];
- @list2 = @b[ $cdiff[1] .. $cdiff[3]-1 ];
- # Hunk start Hunk end
-
-Note that the hunks will always alternate between those that are part of
-the LCS (those that contain unchanged items) and those that contain
-changes. This means that all we need to be told is whether the first
-hunk is a 'same' or 'diff' hunk and we can determine which of the other
-hunks contain 'same' items or 'diff' items.
-
-By convention, we always make the first hunk contain unchanged items.
-So the 1st, 3rd, 5th, etc. hunks (all odd-numbered hunks if you start
-counting from 1) all contain unchanged items. And the 2nd, 4th, 6th,
-etc. hunks (all even-numbered hunks if you start counting from 1) all
-contain changed items.
-
-Since @a and @b don't begin with the same value, the first hunk in our
-example is empty (otherwise we'd violate the above convention). Note
-that the first 4 index values in our example are all zero. Plug these
-values into our previous code block and we get:
-
- @hunk1a = @a[ 0 .. 0-1 ];
- @hunk1b = @b[ 0 .. 0-1 ];
-
-And C<0..-1> returns the empty list.
-
-Move down one pair of indices (2..5) and we get the offset ranges for
-the second hunk, which contains changed items.
-
-Since C<@diff[2..5]> contains (0,0,1,0) in our example, the second hunk
-consists of these two lists of items:
-
- @hunk2a = @a[ $cdiff[2] .. $cdiff[4]-1 ];
- @hunk2b = @b[ $cdiff[3] .. $cdiff[5]-1 ];
- # or
- @hunk2a = @a[ 0 .. 1-1 ];
- @hunk2b = @b[ 0 .. 0-1 ];
- # or
- @hunk2a = @a[ 0 .. 0 ];
- @hunk2b = @b[ 0 .. -1 ];
- # or
- @hunk2a = ( 'a' );
- @hunk2b = ( );
-
-That is, we would delete item 0 ('a') from @a.
-
-Since C<@diff[4..7]> contains (1,0,3,2) in our example, the third hunk
-consists of these two lists of items:
-
- @hunk3a = @a[ $cdiff[4] .. $cdiff[6]-1 ];
- @hunk3a = @b[ $cdiff[5] .. $cdiff[7]-1 ];
- # or
- @hunk3a = @a[ 1 .. 3-1 ];
- @hunk3a = @b[ 0 .. 2-1 ];
- # or
- @hunk3a = @a[ 1 .. 2 ];
- @hunk3a = @b[ 0 .. 1 ];
- # or
- @hunk3a = qw( b c );
- @hunk3a = qw( b c );
-
-Note that this third hunk contains unchanged items as our convention demands.
-
-You can continue this process until you reach the last two indices,
-which will always be the number of items in each sequence. This is
-required so that subtracting one from each will give you the indices to
-the last items in each sequence.
-
-=head2 C<traverse_sequences>
-
-C<traverse_sequences> used to be the most general facility provided by
-this module (the new OO interface is more powerful and much easier to
-use).
-
-Imagine that there are two arrows. Arrow A points to an element of
-sequence A, and arrow B points to an element of the sequence B.
-Initially, the arrows point to the first elements of the respective
-sequences. C<traverse_sequences> will advance the arrows through the
-sequences one element at a time, calling an appropriate user-specified
-callback function before each advance. It willadvance the arrows in
-such a way that if there are equal elements C<$A[$i]> and C<$B[$j]>
-which are equal and which are part of the LCS, there will be some moment
-during the execution of C<traverse_sequences> when arrow A is pointing
-to C<$A[$i]> and arrow B is pointing to C<$B[$j]>. When this happens,
-C<traverse_sequences> will call the C<MATCH> callback function and then
-it will advance both arrows.
-
-Otherwise, one of the arrows is pointing to an element of its sequence
-that is not part of the LCS. C<traverse_sequences> will advance that
-arrow and will call the C<DISCARD_A> or the C<DISCARD_B> callback,
-depending on which arrow it advanced. If both arrows point to elements
-that are not part of the LCS, then C<traverse_sequences> will advance
-one of them and call the appropriate callback, but it is not specified
-which it will call.
-
-The arguments to C<traverse_sequences> are the two sequences to
-traverse, and a hash which specifies the callback functions, like this:
-
- traverse_sequences(
- \@seq1, \@seq2,
- { MATCH => $callback_1,
- DISCARD_A => $callback_2,
- DISCARD_B => $callback_3,
- }
- );
-
-Callbacks for MATCH, DISCARD_A, and DISCARD_B are invoked with at least
-the indices of the two arrows as their arguments. They are not expected
-to return any values. If a callback is omitted from the table, it is
-not called.
-
-Callbacks for A_FINISHED and B_FINISHED are invoked with at least the
-corresponding index in A or B.
-
-If arrow A reaches the end of its sequence, before arrow B does,
-C<traverse_sequences> will call the C<A_FINISHED> callback when it
-advances arrow B, if there is such a function; if not it will call
-C<DISCARD_B> instead. Similarly if arrow B finishes first.
-C<traverse_sequences> returns when both arrows are at the ends of their
-respective sequences. It returns true on success and false on failure.
-At present there is no way to fail.
-
-C<traverse_sequences> may be passed an optional fourth parameter; this
-is a CODE reference to a key generation function. See L</KEY GENERATION
-FUNCTIONS>.
-
-Additional parameters, if any, will be passed to the key generation function.
-
-If you want to pass additional parameters to your callbacks, but don't
-need a custom key generation function, you can get the default by
-passing undef:
-
- traverse_sequences(
- \@seq1, \@seq2,
- { MATCH => $callback_1,
- DISCARD_A => $callback_2,
- DISCARD_B => $callback_3,
- },
- undef, # default key-gen