immutable-ruby 0.0.4 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (355) hide show
  1. checksums.yaml +4 -4
  2. data/lib/immutable/core_ext/enumerable.rb +1 -1
  3. data/lib/immutable/core_ext/io.rb +1 -1
  4. data/lib/immutable/core_ext.rb +2 -2
  5. data/lib/immutable/deque.rb +17 -17
  6. data/lib/immutable/enumerable.rb +10 -10
  7. data/lib/immutable/hash.rb +24 -24
  8. data/lib/immutable/list.rb +36 -36
  9. data/lib/immutable/nested.rb +8 -8
  10. data/lib/immutable/set.rb +30 -30
  11. data/lib/immutable/sorted_set.rb +30 -26
  12. data/lib/immutable/trie.rb +2 -2
  13. data/lib/immutable/vector.rb +40 -35
  14. data/lib/immutable/version.rb +1 -1
  15. data/lib/immutable.rb +9 -9
  16. metadata +36 -699
  17. data/lib/immutable/core_ext/struct.rb +0 -9
  18. data/spec/fixtures/io_spec.txt +0 -3
  19. data/spec/lib/immutable/core_ext/array_spec.rb +0 -13
  20. data/spec/lib/immutable/core_ext/enumerable_spec.rb +0 -29
  21. data/spec/lib/immutable/core_ext/io_spec.rb +0 -28
  22. data/spec/lib/immutable/deque/clear_spec.rb +0 -33
  23. data/spec/lib/immutable/deque/construction_spec.rb +0 -29
  24. data/spec/lib/immutable/deque/copying_spec.rb +0 -19
  25. data/spec/lib/immutable/deque/dequeue_spec.rb +0 -34
  26. data/spec/lib/immutable/deque/empty_spec.rb +0 -39
  27. data/spec/lib/immutable/deque/enqueue_spec.rb +0 -27
  28. data/spec/lib/immutable/deque/first_spec.rb +0 -17
  29. data/spec/lib/immutable/deque/inspect_spec.rb +0 -23
  30. data/spec/lib/immutable/deque/last_spec.rb +0 -17
  31. data/spec/lib/immutable/deque/marshal_spec.rb +0 -33
  32. data/spec/lib/immutable/deque/new_spec.rb +0 -43
  33. data/spec/lib/immutable/deque/pop_spec.rb +0 -36
  34. data/spec/lib/immutable/deque/pretty_print_spec.rb +0 -23
  35. data/spec/lib/immutable/deque/push_spec.rb +0 -36
  36. data/spec/lib/immutable/deque/random_modification_spec.rb +0 -33
  37. data/spec/lib/immutable/deque/rotate_spec.rb +0 -68
  38. data/spec/lib/immutable/deque/shift_spec.rb +0 -29
  39. data/spec/lib/immutable/deque/size_spec.rb +0 -19
  40. data/spec/lib/immutable/deque/to_a_spec.rb +0 -26
  41. data/spec/lib/immutable/deque/to_ary_spec.rb +0 -35
  42. data/spec/lib/immutable/deque/to_list_spec.rb +0 -24
  43. data/spec/lib/immutable/deque/unshift_spec.rb +0 -30
  44. data/spec/lib/immutable/hash/all_spec.rb +0 -53
  45. data/spec/lib/immutable/hash/any_spec.rb +0 -53
  46. data/spec/lib/immutable/hash/assoc_spec.rb +0 -51
  47. data/spec/lib/immutable/hash/clear_spec.rb +0 -42
  48. data/spec/lib/immutable/hash/construction_spec.rb +0 -38
  49. data/spec/lib/immutable/hash/copying_spec.rb +0 -13
  50. data/spec/lib/immutable/hash/default_proc_spec.rb +0 -72
  51. data/spec/lib/immutable/hash/delete_spec.rb +0 -39
  52. data/spec/lib/immutable/hash/dig_spec.rb +0 -34
  53. data/spec/lib/immutable/hash/each_spec.rb +0 -77
  54. data/spec/lib/immutable/hash/each_with_index_spec.rb +0 -29
  55. data/spec/lib/immutable/hash/empty_spec.rb +0 -43
  56. data/spec/lib/immutable/hash/eql_spec.rb +0 -75
  57. data/spec/lib/immutable/hash/except_spec.rb +0 -42
  58. data/spec/lib/immutable/hash/fetch_spec.rb +0 -57
  59. data/spec/lib/immutable/hash/fetch_values_spec.rb +0 -22
  60. data/spec/lib/immutable/hash/find_spec.rb +0 -43
  61. data/spec/lib/immutable/hash/flat_map_spec.rb +0 -35
  62. data/spec/lib/immutable/hash/flatten_spec.rb +0 -98
  63. data/spec/lib/immutable/hash/get_spec.rb +0 -79
  64. data/spec/lib/immutable/hash/has_key_spec.rb +0 -31
  65. data/spec/lib/immutable/hash/has_value_spec.rb +0 -27
  66. data/spec/lib/immutable/hash/hash_spec.rb +0 -29
  67. data/spec/lib/immutable/hash/inspect_spec.rb +0 -30
  68. data/spec/lib/immutable/hash/invert_spec.rb +0 -30
  69. data/spec/lib/immutable/hash/key_spec.rb +0 -27
  70. data/spec/lib/immutable/hash/keys_spec.rb +0 -15
  71. data/spec/lib/immutable/hash/map_spec.rb +0 -45
  72. data/spec/lib/immutable/hash/marshal_spec.rb +0 -28
  73. data/spec/lib/immutable/hash/merge_spec.rb +0 -82
  74. data/spec/lib/immutable/hash/min_max_spec.rb +0 -45
  75. data/spec/lib/immutable/hash/new_spec.rb +0 -70
  76. data/spec/lib/immutable/hash/none_spec.rb +0 -48
  77. data/spec/lib/immutable/hash/partition_spec.rb +0 -35
  78. data/spec/lib/immutable/hash/pretty_print_spec.rb +0 -34
  79. data/spec/lib/immutable/hash/put_spec.rb +0 -111
  80. data/spec/lib/immutable/hash/reduce_spec.rb +0 -35
  81. data/spec/lib/immutable/hash/reject_spec.rb +0 -61
  82. data/spec/lib/immutable/hash/reverse_each_spec.rb +0 -27
  83. data/spec/lib/immutable/hash/sample_spec.rb +0 -13
  84. data/spec/lib/immutable/hash/select_spec.rb +0 -57
  85. data/spec/lib/immutable/hash/size_spec.rb +0 -51
  86. data/spec/lib/immutable/hash/slice_spec.rb +0 -44
  87. data/spec/lib/immutable/hash/sort_spec.rb +0 -26
  88. data/spec/lib/immutable/hash/store_spec.rb +0 -75
  89. data/spec/lib/immutable/hash/subset_spec.rb +0 -42
  90. data/spec/lib/immutable/hash/superset_spec.rb +0 -42
  91. data/spec/lib/immutable/hash/take_spec.rb +0 -35
  92. data/spec/lib/immutable/hash/to_a_spec.rb +0 -13
  93. data/spec/lib/immutable/hash/to_hash_spec.rb +0 -21
  94. data/spec/lib/immutable/hash/to_proc_spec.rb +0 -39
  95. data/spec/lib/immutable/hash/update_in_spec.rb +0 -79
  96. data/spec/lib/immutable/hash/values_at_spec.rb +0 -33
  97. data/spec/lib/immutable/hash/values_spec.rb +0 -23
  98. data/spec/lib/immutable/list/add_spec.rb +0 -25
  99. data/spec/lib/immutable/list/all_spec.rb +0 -57
  100. data/spec/lib/immutable/list/any_spec.rb +0 -49
  101. data/spec/lib/immutable/list/append_spec.rb +0 -38
  102. data/spec/lib/immutable/list/at_spec.rb +0 -29
  103. data/spec/lib/immutable/list/break_spec.rb +0 -69
  104. data/spec/lib/immutable/list/cadr_spec.rb +0 -38
  105. data/spec/lib/immutable/list/chunk_spec.rb +0 -28
  106. data/spec/lib/immutable/list/clear_spec.rb +0 -24
  107. data/spec/lib/immutable/list/combination_spec.rb +0 -33
  108. data/spec/lib/immutable/list/compact_spec.rb +0 -34
  109. data/spec/lib/immutable/list/compare_spec.rb +0 -30
  110. data/spec/lib/immutable/list/cons_spec.rb +0 -25
  111. data/spec/lib/immutable/list/construction_spec.rb +0 -110
  112. data/spec/lib/immutable/list/copying_spec.rb +0 -19
  113. data/spec/lib/immutable/list/count_spec.rb +0 -36
  114. data/spec/lib/immutable/list/cycle_spec.rb +0 -28
  115. data/spec/lib/immutable/list/delete_at_spec.rb +0 -18
  116. data/spec/lib/immutable/list/delete_spec.rb +0 -16
  117. data/spec/lib/immutable/list/drop_spec.rb +0 -30
  118. data/spec/lib/immutable/list/drop_while_spec.rb +0 -38
  119. data/spec/lib/immutable/list/each_slice_spec.rb +0 -51
  120. data/spec/lib/immutable/list/each_spec.rb +0 -40
  121. data/spec/lib/immutable/list/each_with_index_spec.rb +0 -28
  122. data/spec/lib/immutable/list/empty_spec.rb +0 -23
  123. data/spec/lib/immutable/list/eql_spec.rb +0 -61
  124. data/spec/lib/immutable/list/fill_spec.rb +0 -49
  125. data/spec/lib/immutable/list/find_all_spec.rb +0 -70
  126. data/spec/lib/immutable/list/find_index_spec.rb +0 -35
  127. data/spec/lib/immutable/list/find_spec.rb +0 -42
  128. data/spec/lib/immutable/list/flat_map_spec.rb +0 -51
  129. data/spec/lib/immutable/list/flatten_spec.rb +0 -30
  130. data/spec/lib/immutable/list/grep_spec.rb +0 -46
  131. data/spec/lib/immutable/list/group_by_spec.rb +0 -41
  132. data/spec/lib/immutable/list/hash_spec.rb +0 -21
  133. data/spec/lib/immutable/list/head_spec.rb +0 -19
  134. data/spec/lib/immutable/list/include_spec.rb +0 -35
  135. data/spec/lib/immutable/list/index_spec.rb +0 -37
  136. data/spec/lib/immutable/list/indices_spec.rb +0 -61
  137. data/spec/lib/immutable/list/init_spec.rb +0 -28
  138. data/spec/lib/immutable/list/inits_spec.rb +0 -28
  139. data/spec/lib/immutable/list/insert_spec.rb +0 -46
  140. data/spec/lib/immutable/list/inspect_spec.rb +0 -29
  141. data/spec/lib/immutable/list/intersperse_spec.rb +0 -28
  142. data/spec/lib/immutable/list/join_spec.rb +0 -63
  143. data/spec/lib/immutable/list/last_spec.rb +0 -23
  144. data/spec/lib/immutable/list/ltlt_spec.rb +0 -19
  145. data/spec/lib/immutable/list/map_spec.rb +0 -45
  146. data/spec/lib/immutable/list/maximum_spec.rb +0 -39
  147. data/spec/lib/immutable/list/merge_by_spec.rb +0 -51
  148. data/spec/lib/immutable/list/merge_spec.rb +0 -59
  149. data/spec/lib/immutable/list/minimum_spec.rb +0 -39
  150. data/spec/lib/immutable/list/multithreading_spec.rb +0 -47
  151. data/spec/lib/immutable/list/none_spec.rb +0 -47
  152. data/spec/lib/immutable/list/one_spec.rb +0 -49
  153. data/spec/lib/immutable/list/partition_spec.rb +0 -115
  154. data/spec/lib/immutable/list/permutation_spec.rb +0 -55
  155. data/spec/lib/immutable/list/pop_spec.rb +0 -25
  156. data/spec/lib/immutable/list/product_spec.rb +0 -23
  157. data/spec/lib/immutable/list/reduce_spec.rb +0 -53
  158. data/spec/lib/immutable/list/reject_spec.rb +0 -45
  159. data/spec/lib/immutable/list/reverse_spec.rb +0 -34
  160. data/spec/lib/immutable/list/rotate_spec.rb +0 -36
  161. data/spec/lib/immutable/list/sample_spec.rb +0 -13
  162. data/spec/lib/immutable/list/select_spec.rb +0 -70
  163. data/spec/lib/immutable/list/size_spec.rb +0 -25
  164. data/spec/lib/immutable/list/slice_spec.rb +0 -229
  165. data/spec/lib/immutable/list/sorting_spec.rb +0 -46
  166. data/spec/lib/immutable/list/span_spec.rb +0 -76
  167. data/spec/lib/immutable/list/split_at_spec.rb +0 -43
  168. data/spec/lib/immutable/list/subsequences_spec.rb +0 -23
  169. data/spec/lib/immutable/list/sum_spec.rb +0 -23
  170. data/spec/lib/immutable/list/tail_spec.rb +0 -30
  171. data/spec/lib/immutable/list/tails_spec.rb +0 -28
  172. data/spec/lib/immutable/list/take_spec.rb +0 -30
  173. data/spec/lib/immutable/list/take_while_spec.rb +0 -46
  174. data/spec/lib/immutable/list/to_a_spec.rb +0 -39
  175. data/spec/lib/immutable/list/to_ary_spec.rb +0 -41
  176. data/spec/lib/immutable/list/to_list_spec.rb +0 -19
  177. data/spec/lib/immutable/list/to_set_spec.rb +0 -17
  178. data/spec/lib/immutable/list/transpose_spec.rb +0 -19
  179. data/spec/lib/immutable/list/union_spec.rb +0 -31
  180. data/spec/lib/immutable/list/uniq_spec.rb +0 -35
  181. data/spec/lib/immutable/list/zip_spec.rb +0 -23
  182. data/spec/lib/immutable/nested/construction_spec.rb +0 -101
  183. data/spec/lib/immutable/set/add_spec.rb +0 -77
  184. data/spec/lib/immutable/set/all_spec.rb +0 -51
  185. data/spec/lib/immutable/set/any_spec.rb +0 -51
  186. data/spec/lib/immutable/set/clear_spec.rb +0 -33
  187. data/spec/lib/immutable/set/compact_spec.rb +0 -30
  188. data/spec/lib/immutable/set/construction_spec.rb +0 -18
  189. data/spec/lib/immutable/set/copying_spec.rb +0 -13
  190. data/spec/lib/immutable/set/count_spec.rb +0 -36
  191. data/spec/lib/immutable/set/delete_spec.rb +0 -71
  192. data/spec/lib/immutable/set/difference_spec.rb +0 -49
  193. data/spec/lib/immutable/set/disjoint_spec.rb +0 -25
  194. data/spec/lib/immutable/set/each_spec.rb +0 -45
  195. data/spec/lib/immutable/set/empty_spec.rb +0 -44
  196. data/spec/lib/immutable/set/eqeq_spec.rb +0 -103
  197. data/spec/lib/immutable/set/eql_spec.rb +0 -109
  198. data/spec/lib/immutable/set/exclusion_spec.rb +0 -47
  199. data/spec/lib/immutable/set/find_spec.rb +0 -35
  200. data/spec/lib/immutable/set/first_spec.rb +0 -28
  201. data/spec/lib/immutable/set/flatten_spec.rb +0 -46
  202. data/spec/lib/immutable/set/grep_spec.rb +0 -57
  203. data/spec/lib/immutable/set/grep_v_spec.rb +0 -59
  204. data/spec/lib/immutable/set/group_by_spec.rb +0 -59
  205. data/spec/lib/immutable/set/hash_spec.rb +0 -22
  206. data/spec/lib/immutable/set/include_spec.rb +0 -60
  207. data/spec/lib/immutable/set/inspect_spec.rb +0 -47
  208. data/spec/lib/immutable/set/intersect_spec.rb +0 -25
  209. data/spec/lib/immutable/set/intersection_spec.rb +0 -52
  210. data/spec/lib/immutable/set/join_spec.rb +0 -64
  211. data/spec/lib/immutable/set/map_spec.rb +0 -59
  212. data/spec/lib/immutable/set/marshal_spec.rb +0 -28
  213. data/spec/lib/immutable/set/maximum_spec.rb +0 -36
  214. data/spec/lib/immutable/set/minimum_spec.rb +0 -36
  215. data/spec/lib/immutable/set/new_spec.rb +0 -53
  216. data/spec/lib/immutable/set/none_spec.rb +0 -47
  217. data/spec/lib/immutable/set/one_spec.rb +0 -47
  218. data/spec/lib/immutable/set/partition_spec.rb +0 -52
  219. data/spec/lib/immutable/set/product_spec.rb +0 -23
  220. data/spec/lib/immutable/set/reduce_spec.rb +0 -55
  221. data/spec/lib/immutable/set/reject_spec.rb +0 -50
  222. data/spec/lib/immutable/set/reverse_each_spec.rb +0 -38
  223. data/spec/lib/immutable/set/sample_spec.rb +0 -13
  224. data/spec/lib/immutable/set/select_spec.rb +0 -73
  225. data/spec/lib/immutable/set/size_spec.rb +0 -17
  226. data/spec/lib/immutable/set/sorting_spec.rb +0 -65
  227. data/spec/lib/immutable/set/subset_spec.rb +0 -51
  228. data/spec/lib/immutable/set/sum_spec.rb +0 -23
  229. data/spec/lib/immutable/set/superset_spec.rb +0 -51
  230. data/spec/lib/immutable/set/to_a_spec.rb +0 -30
  231. data/spec/lib/immutable/set/to_list_spec.rb +0 -35
  232. data/spec/lib/immutable/set/to_set_spec.rb +0 -19
  233. data/spec/lib/immutable/set/union_spec.rb +0 -63
  234. data/spec/lib/immutable/sorted_set/above_spec.rb +0 -51
  235. data/spec/lib/immutable/sorted_set/add_spec.rb +0 -62
  236. data/spec/lib/immutable/sorted_set/at_spec.rb +0 -24
  237. data/spec/lib/immutable/sorted_set/below_spec.rb +0 -51
  238. data/spec/lib/immutable/sorted_set/between_spec.rb +0 -51
  239. data/spec/lib/immutable/sorted_set/clear_spec.rb +0 -43
  240. data/spec/lib/immutable/sorted_set/copying_spec.rb +0 -20
  241. data/spec/lib/immutable/sorted_set/delete_at_spec.rb +0 -18
  242. data/spec/lib/immutable/sorted_set/delete_spec.rb +0 -89
  243. data/spec/lib/immutable/sorted_set/difference_spec.rb +0 -22
  244. data/spec/lib/immutable/sorted_set/disjoint_spec.rb +0 -25
  245. data/spec/lib/immutable/sorted_set/drop_spec.rb +0 -55
  246. data/spec/lib/immutable/sorted_set/drop_while_spec.rb +0 -34
  247. data/spec/lib/immutable/sorted_set/each_spec.rb +0 -28
  248. data/spec/lib/immutable/sorted_set/empty_spec.rb +0 -34
  249. data/spec/lib/immutable/sorted_set/eql_spec.rb +0 -120
  250. data/spec/lib/immutable/sorted_set/exclusion_spec.rb +0 -22
  251. data/spec/lib/immutable/sorted_set/fetch_spec.rb +0 -64
  252. data/spec/lib/immutable/sorted_set/find_index_spec.rb +0 -40
  253. data/spec/lib/immutable/sorted_set/first_spec.rb +0 -18
  254. data/spec/lib/immutable/sorted_set/from_spec.rb +0 -51
  255. data/spec/lib/immutable/sorted_set/group_by_spec.rb +0 -57
  256. data/spec/lib/immutable/sorted_set/include_spec.rb +0 -23
  257. data/spec/lib/immutable/sorted_set/inspect_spec.rb +0 -37
  258. data/spec/lib/immutable/sorted_set/intersect_spec.rb +0 -25
  259. data/spec/lib/immutable/sorted_set/intersection_spec.rb +0 -28
  260. data/spec/lib/immutable/sorted_set/last_spec.rb +0 -36
  261. data/spec/lib/immutable/sorted_set/map_spec.rb +0 -51
  262. data/spec/lib/immutable/sorted_set/marshal_spec.rb +0 -36
  263. data/spec/lib/immutable/sorted_set/maximum_spec.rb +0 -36
  264. data/spec/lib/immutable/sorted_set/minimum_spec.rb +0 -19
  265. data/spec/lib/immutable/sorted_set/new_spec.rb +0 -137
  266. data/spec/lib/immutable/sorted_set/reverse_each_spec.rb +0 -28
  267. data/spec/lib/immutable/sorted_set/sample_spec.rb +0 -13
  268. data/spec/lib/immutable/sorted_set/select_spec.rb +0 -61
  269. data/spec/lib/immutable/sorted_set/size_spec.rb +0 -17
  270. data/spec/lib/immutable/sorted_set/slice_spec.rb +0 -256
  271. data/spec/lib/immutable/sorted_set/sorting_spec.rb +0 -56
  272. data/spec/lib/immutable/sorted_set/subset_spec.rb +0 -47
  273. data/spec/lib/immutable/sorted_set/superset_spec.rb +0 -47
  274. data/spec/lib/immutable/sorted_set/take_spec.rb +0 -54
  275. data/spec/lib/immutable/sorted_set/take_while_spec.rb +0 -33
  276. data/spec/lib/immutable/sorted_set/to_set_spec.rb +0 -17
  277. data/spec/lib/immutable/sorted_set/union_spec.rb +0 -58
  278. data/spec/lib/immutable/sorted_set/up_to_spec.rb +0 -52
  279. data/spec/lib/immutable/sorted_set/util_spec.rb +0 -48
  280. data/spec/lib/immutable/sorted_set/values_at_spec.rb +0 -33
  281. data/spec/lib/immutable/vector/add_spec.rb +0 -67
  282. data/spec/lib/immutable/vector/any_spec.rb +0 -69
  283. data/spec/lib/immutable/vector/assoc_spec.rb +0 -45
  284. data/spec/lib/immutable/vector/bsearch_spec.rb +0 -65
  285. data/spec/lib/immutable/vector/clear_spec.rb +0 -33
  286. data/spec/lib/immutable/vector/combination_spec.rb +0 -81
  287. data/spec/lib/immutable/vector/compact_spec.rb +0 -29
  288. data/spec/lib/immutable/vector/compare_spec.rb +0 -31
  289. data/spec/lib/immutable/vector/concat_spec.rb +0 -34
  290. data/spec/lib/immutable/vector/copying_spec.rb +0 -20
  291. data/spec/lib/immutable/vector/count_spec.rb +0 -17
  292. data/spec/lib/immutable/vector/delete_at_spec.rb +0 -53
  293. data/spec/lib/immutable/vector/delete_spec.rb +0 -30
  294. data/spec/lib/immutable/vector/dig_spec.rb +0 -30
  295. data/spec/lib/immutable/vector/drop_spec.rb +0 -41
  296. data/spec/lib/immutable/vector/drop_while_spec.rb +0 -54
  297. data/spec/lib/immutable/vector/each_index_spec.rb +0 -40
  298. data/spec/lib/immutable/vector/each_spec.rb +0 -44
  299. data/spec/lib/immutable/vector/each_with_index_spec.rb +0 -39
  300. data/spec/lib/immutable/vector/empty_spec.rb +0 -41
  301. data/spec/lib/immutable/vector/eql_spec.rb +0 -76
  302. data/spec/lib/immutable/vector/fetch_spec.rb +0 -64
  303. data/spec/lib/immutable/vector/fill_spec.rb +0 -88
  304. data/spec/lib/immutable/vector/first_spec.rb +0 -18
  305. data/spec/lib/immutable/vector/flat_map_spec.rb +0 -50
  306. data/spec/lib/immutable/vector/flatten_spec.rb +0 -58
  307. data/spec/lib/immutable/vector/get_spec.rb +0 -74
  308. data/spec/lib/immutable/vector/group_by_spec.rb +0 -57
  309. data/spec/lib/immutable/vector/include_spec.rb +0 -30
  310. data/spec/lib/immutable/vector/insert_spec.rb +0 -68
  311. data/spec/lib/immutable/vector/inspect_spec.rb +0 -49
  312. data/spec/lib/immutable/vector/join_spec.rb +0 -58
  313. data/spec/lib/immutable/vector/last_spec.rb +0 -45
  314. data/spec/lib/immutable/vector/length_spec.rb +0 -45
  315. data/spec/lib/immutable/vector/ltlt_spec.rb +0 -65
  316. data/spec/lib/immutable/vector/map_spec.rb +0 -51
  317. data/spec/lib/immutable/vector/marshal_spec.rb +0 -31
  318. data/spec/lib/immutable/vector/maximum_spec.rb +0 -33
  319. data/spec/lib/immutable/vector/minimum_spec.rb +0 -33
  320. data/spec/lib/immutable/vector/multiply_spec.rb +0 -47
  321. data/spec/lib/immutable/vector/new_spec.rb +0 -50
  322. data/spec/lib/immutable/vector/partition_spec.rb +0 -52
  323. data/spec/lib/immutable/vector/permutation_spec.rb +0 -91
  324. data/spec/lib/immutable/vector/pop_spec.rb +0 -26
  325. data/spec/lib/immutable/vector/product_spec.rb +0 -70
  326. data/spec/lib/immutable/vector/reduce_spec.rb +0 -55
  327. data/spec/lib/immutable/vector/reject_spec.rb +0 -43
  328. data/spec/lib/immutable/vector/repeated_combination_spec.rb +0 -77
  329. data/spec/lib/immutable/vector/repeated_permutation_spec.rb +0 -93
  330. data/spec/lib/immutable/vector/reverse_each_spec.rb +0 -31
  331. data/spec/lib/immutable/vector/reverse_spec.rb +0 -21
  332. data/spec/lib/immutable/vector/rindex_spec.rb +0 -36
  333. data/spec/lib/immutable/vector/rotate_spec.rb +0 -73
  334. data/spec/lib/immutable/vector/sample_spec.rb +0 -13
  335. data/spec/lib/immutable/vector/select_spec.rb +0 -63
  336. data/spec/lib/immutable/vector/set_spec.rb +0 -174
  337. data/spec/lib/immutable/vector/shift_spec.rb +0 -27
  338. data/spec/lib/immutable/vector/shuffle_spec.rb +0 -43
  339. data/spec/lib/immutable/vector/slice_spec.rb +0 -240
  340. data/spec/lib/immutable/vector/sorting_spec.rb +0 -56
  341. data/spec/lib/immutable/vector/sum_spec.rb +0 -17
  342. data/spec/lib/immutable/vector/take_spec.rb +0 -42
  343. data/spec/lib/immutable/vector/take_while_spec.rb +0 -34
  344. data/spec/lib/immutable/vector/to_a_spec.rb +0 -41
  345. data/spec/lib/immutable/vector/to_ary_spec.rb +0 -34
  346. data/spec/lib/immutable/vector/to_list_spec.rb +0 -30
  347. data/spec/lib/immutable/vector/to_set_spec.rb +0 -21
  348. data/spec/lib/immutable/vector/transpose_spec.rb +0 -48
  349. data/spec/lib/immutable/vector/uniq_spec.rb +0 -76
  350. data/spec/lib/immutable/vector/unshift_spec.rb +0 -28
  351. data/spec/lib/immutable/vector/update_in_spec.rb +0 -82
  352. data/spec/lib/immutable/vector/values_at_spec.rb +0 -33
  353. data/spec/lib/immutable/vector/zip_spec.rb +0 -57
  354. data/spec/lib/load_spec.rb +0 -42
  355. data/spec/spec_helper.rb +0 -96
data/lib/immutable/set.rb CHANGED
@@ -1,9 +1,9 @@
1
- require "immutable/undefined"
2
- require "immutable/enumerable"
3
- require "immutable/hash"
4
- require "immutable/trie"
5
- require "immutable/sorted_set"
6
- require "set"
1
+ require 'immutable/undefined'
2
+ require 'immutable/enumerable'
3
+ require 'immutable/hash'
4
+ require 'immutable/trie'
5
+ require 'immutable/sorted_set'
6
+ require 'set'
7
7
 
8
8
  module Immutable
9
9
 
@@ -61,7 +61,7 @@ module Immutable
61
61
  #
62
62
  # @return [Set]
63
63
  def empty
64
- @empty ||= self.new
64
+ @empty ||= new
65
65
  end
66
66
 
67
67
  # "Raw" allocation of a new `Set`. Used internally to create a new
@@ -91,7 +91,7 @@ module Immutable
91
91
  def size
92
92
  @trie.size
93
93
  end
94
- alias :length :size
94
+ alias length size
95
95
 
96
96
  # Return a new `Set` with `item` added. If `item` is already in the set,
97
97
  # return `self`.
@@ -105,7 +105,7 @@ module Immutable
105
105
  def add(item)
106
106
  include?(item) ? self : self.class.alloc(@trie.put(item, nil))
107
107
  end
108
- alias :<< :add
108
+ alias << add
109
109
 
110
110
  # If `item` is not a member of this `Set`, return a new `Set` with `item` added.
111
111
  # Otherwise, return `false`.
@@ -197,8 +197,8 @@ module Immutable
197
197
  trie = @trie.select { |key, _| yield(key) }
198
198
  new_trie(trie)
199
199
  end
200
- alias :find_all :select
201
- alias :keep_if :select
200
+ alias find_all select
201
+ alias keep_if select
202
202
 
203
203
  # Call the block once for each item in this `Set`. All the values returned
204
204
  # from the block will be gathered into a new `Set`. If no block is given,
@@ -215,7 +215,7 @@ module Immutable
215
215
  return self if empty?
216
216
  self.class.new(super)
217
217
  end
218
- alias :collect :map
218
+ alias collect map
219
219
 
220
220
  # Return `true` if the given item is present in this `Set`. More precisely,
221
221
  # return `true` if an object with the same `#hash` code, and which is also `#eql?`
@@ -230,7 +230,7 @@ module Immutable
230
230
  def include?(object)
231
231
  @trie.key?(object)
232
232
  end
233
- alias :member? :include?
233
+ alias member? include?
234
234
 
235
235
  # Return a member of this `Set`. The member chosen will be the first one which
236
236
  # would be yielded by {#each}. If the set is empty, return `nil`.
@@ -258,7 +258,7 @@ module Immutable
258
258
  # equal.
259
259
  # @return [SortedSet]
260
260
  def sort(&comparator)
261
- SortedSet.new(self.to_a, &comparator)
261
+ SortedSet.new(to_a, &comparator)
262
262
  end
263
263
 
264
264
  # Return a {SortedSet} which contains the same items as this `Set`, ordered
@@ -276,7 +276,7 @@ module Immutable
276
276
  # @yieldreturn [Object] sort key for the item
277
277
  # @return [SortedSet]
278
278
  def sort_by(&mapper)
279
- SortedSet.new(self.to_a, &mapper)
279
+ SortedSet.new(to_a, &mapper)
280
280
  end
281
281
 
282
282
  # Return a new `Set` which contains all the members of both this `Set` and `other`.
@@ -308,9 +308,9 @@ module Immutable
308
308
  trie = large_set_trie.bulk_put(small_set_pairs)
309
309
  new_trie(trie)
310
310
  end
311
- alias :| :union
312
- alias :+ :union
313
- alias :merge :union
311
+ alias | union
312
+ alias + union
313
+ alias merge union
314
314
 
315
315
  # Return a new `Set` which contains all the items which are members of both
316
316
  # this `Set` and `other`. `other` can be any `Enumerable` object.
@@ -333,7 +333,7 @@ module Immutable
333
333
  end
334
334
  new_trie(trie)
335
335
  end
336
- alias :& :intersection
336
+ alias & intersection
337
337
 
338
338
  # Return a new `Set` with all the items in `other` removed. `other` can be
339
339
  # any `Enumerable` object.
@@ -351,8 +351,8 @@ module Immutable
351
351
  end
352
352
  new_trie(trie)
353
353
  end
354
- alias :subtract :difference
355
- alias :- :difference
354
+ alias subtract difference
355
+ alias - difference
356
356
 
357
357
  # Return a new `Set` which contains all the items which are members of this
358
358
  # `Set` or of `other`, but not both. `other` can be any `Enumerable` object.
@@ -365,7 +365,7 @@ module Immutable
365
365
  def exclusion(other)
366
366
  ((self | other) - (self & other))
367
367
  end
368
- alias :^ :exclusion
368
+ alias ^ exclusion
369
369
 
370
370
  # Return `true` if all items in this `Set` are also in `other`.
371
371
  #
@@ -391,7 +391,7 @@ module Immutable
391
391
  end
392
392
  all? { |item| other.include?(item) }
393
393
  end
394
- alias :<= :subset?
394
+ alias <= subset?
395
395
 
396
396
  # Return `true` if all items in `other` are also in this `Set`.
397
397
  #
@@ -403,7 +403,7 @@ module Immutable
403
403
  def superset?(other)
404
404
  other.subset?(self)
405
405
  end
406
- alias :>= :superset?
406
+ alias >= superset?
407
407
 
408
408
  # Returns `true` if `other` contains all the items in this `Set`, plus at least
409
409
  # one item which is not in this set.
@@ -422,7 +422,7 @@ module Immutable
422
422
  end
423
423
  all? { |item| other.include?(item) }
424
424
  end
425
- alias :< :proper_subset?
425
+ alias < proper_subset?
426
426
 
427
427
  # Returns `true` if this `Set` contains all the items in `other`, plus at least
428
428
  # one item which is not in `other`.
@@ -436,7 +436,7 @@ module Immutable
436
436
  def proper_superset?(other)
437
437
  other.proper_subset?(self)
438
438
  end
439
- alias :> :proper_superset?
439
+ alias > proper_superset?
440
440
 
441
441
  # Return `true` if this `Set` and `other` do not share any items.
442
442
  #
@@ -484,8 +484,8 @@ module Immutable
484
484
  end
485
485
  end
486
486
 
487
- alias :group :group_by
488
- alias :classify :group_by
487
+ alias group group_by
488
+ alias classify group_by
489
489
 
490
490
  # Return a randomly chosen item from this `Set`. If the set is empty, return `nil`.
491
491
  #
@@ -519,7 +519,7 @@ module Immutable
519
519
  end
520
520
  true
521
521
  end
522
- alias :== :eql?
522
+ alias == eql?
523
523
 
524
524
  # See `Object#hash`.
525
525
  # @return [Integer]
@@ -533,7 +533,7 @@ module Immutable
533
533
  def dup
534
534
  self
535
535
  end
536
- alias :clone :dup
536
+ alias clone dup
537
537
 
538
538
  undef :"<=>" # Sets are not ordered, so Enumerable#<=> will give a meaningless result
539
539
  undef :each_index # Set members cannot be accessed by 'index', so #each_index is not meaningful
@@ -1,4 +1,4 @@
1
- require "immutable/enumerable"
1
+ require 'immutable/enumerable'
2
2
 
3
3
  module Immutable
4
4
 
@@ -65,7 +65,7 @@ module Immutable
65
65
  #
66
66
  # @return [SortedSet]
67
67
  def empty
68
- @empty ||= self.alloc(PlainAVLNode::EmptyNode)
68
+ @empty ||= alloc(PlainAVLNode::EmptyNode)
69
69
  end
70
70
 
71
71
  # "Raw" allocation of a new `SortedSet`. Used internally to create a new
@@ -101,14 +101,17 @@ module Immutable
101
101
  def initialize(items=[], &block)
102
102
  items = items.to_a
103
103
  if block
104
- if block.arity == 1 || block.arity == -1
104
+ # In Ruby 2, &:method blocks have arity -1; in Ruby 3, it's -2
105
+ if block.arity == 1 || block.arity == -1 || block.arity == -2
105
106
  items = items.uniq(&block)
106
107
  items.sort_by!(&block)
107
108
  comparator = lambda { |a,b| block.call(a) <=> block.call(b) }
108
- else
109
+ elsif block.arity == 2 || block.arity == -3
109
110
  items = items.sort(&block)
110
111
  SortedSet.uniq_by_comparator!(items, block)
111
112
  comparator = block
113
+ else
114
+ raise "Comparator block for Immutable::SortedSet must accept 1 or 2 arguments"
112
115
  end
113
116
  @node = AVLNode.from_items(items, comparator)
114
117
  else
@@ -133,7 +136,7 @@ module Immutable
133
136
  def size
134
137
  @node.size
135
138
  end
136
- alias :length :size
139
+ alias length size
137
140
 
138
141
  # Return a new `SortedSet` with `item` added. If `item` is already in the set,
139
142
  # return `self`.
@@ -151,7 +154,7 @@ module Immutable
151
154
  end
152
155
  self
153
156
  end
154
- alias :<< :add
157
+ alias << add
155
158
 
156
159
  # If `item` is not a member of this `SortedSet`, return a new `SortedSet` with
157
160
  # `item` added. Otherwise, return `false`.
@@ -343,7 +346,7 @@ module Immutable
343
346
  subsequence(arg, length)
344
347
  end
345
348
  end
346
- alias :[] :slice
349
+ alias [] slice
347
350
 
348
351
  # Return a new `SortedSet` with only the elements at the given `indices`.
349
352
  # If any of the `indices` do not exist, they will be skipped.
@@ -451,8 +454,8 @@ module Immutable
451
454
  each { |item| items_to_delete << item unless yield(item) }
452
455
  derive_new_sorted_set(@node.bulk_delete(items_to_delete))
453
456
  end
454
- alias :find_all :select
455
- alias :keep_if :select
457
+ alias find_all select
458
+ alias keep_if select
456
459
 
457
460
  # Invoke the given block once for each item in the set, and return a new
458
461
  # `SortedSet` containing the values returned by the block. If no block is
@@ -469,7 +472,7 @@ module Immutable
469
472
  return self if empty?
470
473
  self.class.alloc(@node.from_items(super))
471
474
  end
472
- alias :collect :map
475
+ alias collect map
473
476
 
474
477
  # Return `true` if the given item is present in this `SortedSet`. More precisely,
475
478
  # return `true` if an object which compares as "equal" using this set's
@@ -483,7 +486,7 @@ module Immutable
483
486
  def include?(item)
484
487
  @node.include?(item)
485
488
  end
486
- alias :member? :include?
489
+ alias member? include?
487
490
 
488
491
  # Return a new `SortedSet` with the same items, but a sort order determined
489
492
  # by the given block.
@@ -497,14 +500,14 @@ module Immutable
497
500
  # @return [SortedSet]
498
501
  def sort(&block)
499
502
  if block
500
- self.class.new(self.to_a, &block)
503
+ self.class.new(to_a, &block)
501
504
  elsif @node.natural_order?
502
505
  self
503
506
  else
504
507
  self.class.new(self)
505
508
  end
506
509
  end
507
- alias :sort_by :sort
510
+ alias sort_by sort
508
511
 
509
512
  # Find the index of a given object or an element that satisfies the given
510
513
  # block.
@@ -550,7 +553,7 @@ module Immutable
550
553
  super(&block)
551
554
  end
552
555
  end
553
- alias :index :find_index
556
+ alias index find_index
554
557
 
555
558
  # Drop the first `n` elements and return the rest in a new `SortedSet`.
556
559
  #
@@ -628,9 +631,9 @@ module Immutable
628
631
  def union(other)
629
632
  self.class.alloc(@node.bulk_insert(other))
630
633
  end
631
- alias :| :union
632
- alias :+ :union
633
- alias :merge :union
634
+ alias | union
635
+ alias + union
636
+ alias merge union
634
637
 
635
638
  # Return a new `SortedSet` which contains all the items which are members of both
636
639
  # this set and `other`. `other` can be any `Enumerable` object.
@@ -644,7 +647,7 @@ module Immutable
644
647
  def intersection(other)
645
648
  self.class.alloc(@node.keep_only(other))
646
649
  end
647
- alias :& :intersection
650
+ alias & intersection
648
651
 
649
652
  # Return a new `SortedSet` with all the items in `other` removed. `other` can be
650
653
  # any `Enumerable` object.
@@ -658,8 +661,8 @@ module Immutable
658
661
  def difference(other)
659
662
  self.class.alloc(@node.bulk_delete(other))
660
663
  end
661
- alias :subtract :difference
662
- alias :- :difference
664
+ alias subtract difference
665
+ alias - difference
663
666
 
664
667
  # Return a new `SortedSet` with all the items which are members of this
665
668
  # set or of `other`, but not both. `other` can be any `Enumerable` object.
@@ -673,7 +676,7 @@ module Immutable
673
676
  def exclusion(other)
674
677
  ((self | other) - (self & other))
675
678
  end
676
- alias :^ :exclusion
679
+ alias ^ exclusion
677
680
 
678
681
  # Return `true` if all items in this set are also in `other`.
679
682
  #
@@ -752,8 +755,8 @@ module Immutable
752
755
  !disjoint?(other)
753
756
  end
754
757
 
755
- alias :group :group_by
756
- alias :classify :group_by
758
+ alias group group_by
759
+ alias classify group_by
757
760
 
758
761
  # Select elements greater than a value.
759
762
  #
@@ -947,10 +950,11 @@ module Immutable
947
950
  return true if other.equal?(self)
948
951
  return false if not instance_of?(other.class)
949
952
  return false if size != other.size
950
- a, b = self.to_enum, other.to_enum
951
- while true
953
+ a, b = to_enum, other.to_enum
954
+ loop do
952
955
  return false if !a.next.eql?(b.next)
953
956
  end
957
+ true
954
958
  rescue StopIteration
955
959
  true
956
960
  end
@@ -967,7 +971,7 @@ module Immutable
967
971
  def dup
968
972
  self
969
973
  end
970
- alias :clone :dup
974
+ alias clone dup
971
975
 
972
976
  # @return [::Array]
973
977
  # @private
@@ -2,7 +2,7 @@ module Immutable
2
2
  # @private
3
3
  class Trie
4
4
  def self.[](pairs)
5
- result = self.new(0)
5
+ result = new(0)
6
6
  pairs.each { |key, val| result.put!(key, val) }
7
7
  result
8
8
  end
@@ -269,7 +269,7 @@ module Immutable
269
269
  end
270
270
  true
271
271
  end
272
- alias :== :eql?
272
+ alias == eql?
273
273
 
274
274
  protected
275
275
 
@@ -1,8 +1,7 @@
1
- require "immutable/enumerable"
2
- require "immutable/hash"
1
+ require 'immutable/enumerable'
2
+ require 'immutable/hash'
3
3
 
4
4
  module Immutable
5
-
6
5
  # A `Vector` is an ordered, integer-indexed collection of objects. Like
7
6
  # Ruby's `Array`, `Vector` indexing starts at zero and negative indexes count
8
7
  # back from the end.
@@ -48,7 +47,7 @@ module Immutable
48
47
  # Return the number of items in this `Vector`
49
48
  # @return [Integer]
50
49
  attr_reader :size
51
- alias :length :size
50
+ alias length size
52
51
 
53
52
  class << self
54
53
  # Create a new `Vector` populated with the given items.
@@ -62,7 +61,7 @@ module Immutable
62
61
  #
63
62
  # @return [Vector]
64
63
  def empty
65
- @empty ||= self.new
64
+ @empty ||= new
66
65
  end
67
66
 
68
67
  # "Raw" allocation of a new `Vector`. Used internally to create a new
@@ -132,8 +131,8 @@ module Immutable
132
131
  def add(item)
133
132
  update_root(@size, item)
134
133
  end
135
- alias :<< :add
136
- alias :push :add
134
+ alias << add
135
+ alias push add
137
136
 
138
137
  # Return a new `Vector` with a new value at the given `index`. If `index`
139
138
  # is greater than the length of the vector, the returned vector will be
@@ -197,7 +196,7 @@ module Immutable
197
196
  # @return [Vector]
198
197
  def update_in(*key_path, &block)
199
198
  if key_path.empty?
200
- raise ArgumentError, "must have at least one key in path"
199
+ raise ArgumentError, 'must have at least one key in path'
201
200
  end
202
201
  key = key_path[0]
203
202
  if key_path.size == 1
@@ -226,7 +225,7 @@ module Immutable
226
225
  return nil if index >= @size || index < 0
227
226
  leaf_node_for(@root, @levels * BITS_PER_LEVEL, index)[index & INDEX_MASK]
228
227
  end
229
- alias :at :get
228
+ alias at get
230
229
 
231
230
  # Retrieve the value at `index` with optional default.
232
231
  #
@@ -355,7 +354,7 @@ module Immutable
355
354
  subsequence(arg, length)
356
355
  end
357
356
  end
358
- alias :[] :slice
357
+ alias [] slice
359
358
 
360
359
  # Return a new `Vector` with the given values inserted before the element
361
360
  # at `index`. If `index` is greater than the current length, `nil` values
@@ -402,7 +401,7 @@ module Immutable
402
401
  index += @size if index < 0
403
402
 
404
403
  suffix = flatten_suffix(@root, @levels * BITS_PER_LEVEL, index, [])
405
- replace_suffix(index, suffix.tap { |a| a.shift })
404
+ replace_suffix(index, suffix.tap(&:shift))
406
405
  end
407
406
 
408
407
  # Return a new `Vector` with the last element removed. Return `self` if
@@ -490,8 +489,8 @@ module Immutable
490
489
  return enum_for(:select) unless block_given?
491
490
  reduce(self.class.empty) { |vector, item| yield(item) ? vector.add(item) : vector }
492
491
  end
493
- alias :find_all :select
494
- alias :keep_if :select
492
+ alias find_all select
493
+ alias keep_if select
495
494
 
496
495
  # Return a new `Vector` with all items which are equal to `obj` removed.
497
496
  # `#==` is used for checking equality.
@@ -518,7 +517,7 @@ module Immutable
518
517
  return self if empty?
519
518
  self.class.new(super)
520
519
  end
521
- alias :collect :map
520
+ alias collect map
522
521
 
523
522
  # Return a new `Vector` with the concatenated results of running the block once
524
523
  # for every element in this `Vector`.
@@ -553,7 +552,7 @@ module Immutable
553
552
  #
554
553
  # @return [Vector]
555
554
  def uniq(&block)
556
- array = self.to_a
555
+ array = to_a
557
556
  if array.frozen?
558
557
  self.class.new(array.uniq(&block).freeze)
559
558
  elsif array.uniq!(&block) # returns nil if no changes were made
@@ -609,7 +608,7 @@ module Immutable
609
608
  # @return [Vector]
610
609
  def flatten(level = -1)
611
610
  return self if level == 0
612
- array = self.to_a
611
+ array = to_a
613
612
  if array.frozen?
614
613
  self.class.new(array.flatten(level).freeze)
615
614
  elsif array.flatten!(level) # returns nil if no changes were made
@@ -633,7 +632,7 @@ module Immutable
633
632
  other = other.dup if other.frozen?
634
633
  replace_suffix(@size, other)
635
634
  end
636
- alias :concat :+
635
+ alias concat +
637
636
 
638
637
  # Combine two vectors by "zipping" them together. `others` should be arrays
639
638
  # and/or vectors. The corresponding elements from this `Vector` and each of
@@ -721,7 +720,7 @@ module Immutable
721
720
  def drop(n)
722
721
  return self if n == 0
723
722
  return self.class.empty if n >= @size
724
- raise ArgumentError, "attempt to drop negative size" if n < 0
723
+ raise ArgumentError, 'attempt to drop negative size' if n < 0
725
724
  self.class.new(flatten_suffix(@root, @levels * BITS_PER_LEVEL, n, []))
726
725
  end
727
726
 
@@ -862,7 +861,7 @@ module Immutable
862
861
  elsif n == 1
863
862
  each { |item| yield [item] }
864
863
  elsif n == @size
865
- yield self.to_a
864
+ yield to_a
866
865
  else
867
866
  combos = lambda do |result,index,remaining|
868
867
  while @size - index > remaining
@@ -969,15 +968,14 @@ module Immutable
969
968
  used, result = [], []
970
969
  perms = lambda do |index|
971
970
  0.upto(@size-1) do |i|
972
- if !used[i]
973
- result[index] = get(i)
974
- if index < n-1
975
- used[i] = true
976
- perms[index+1]
977
- used[i] = false
978
- else
979
- yield result.dup
980
- end
971
+ next if used[i]
972
+ result[index] = get(i)
973
+ if index < n-1
974
+ used[i] = true
975
+ perms[index+1]
976
+ used[i] = false
977
+ else
978
+ yield result.dup
981
979
  end
982
980
  end
983
981
  end
@@ -1085,13 +1083,13 @@ module Immutable
1085
1083
  end
1086
1084
 
1087
1085
  if block_given?
1088
- while true
1086
+ loop do
1089
1087
  yield build_array[]
1090
1088
  return self if bump_counters[]
1091
1089
  end
1092
1090
  else
1093
1091
  result = []
1094
- while true
1092
+ loop do
1095
1093
  result << build_array[]
1096
1094
  return result if bump_counters[]
1097
1095
  end
@@ -1114,7 +1112,7 @@ module Immutable
1114
1112
  #
1115
1113
  # @return [Vector]
1116
1114
  # @raise [IndexError] if elements are not of the same size.
1117
- # @raise [TypeError] if an element can not be implicitly converted to an array (using `#to_ary`)
1115
+ # @raise [TypeError] if an element does not respond to #size and #[]
1118
1116
  def transpose
1119
1117
  return self.class.empty if empty?
1120
1118
  result = Array.new(first.size) { [] }
@@ -1132,6 +1130,13 @@ module Immutable
1132
1130
 
1133
1131
  result.map! { |a| self.class.new(a) }
1134
1132
  self.class.new(result)
1133
+ rescue NoMethodError
1134
+ if any? { |x| !x.respond_to?(:size) || !x.respond_to?(:[]) }
1135
+ bad = find { |x| !x.respond_to?(:size) || !x.respond_to?(:[]) }
1136
+ raise TypeError, "'#{bad.inspect}' must respond to #size and #[] to be transposed"
1137
+ else
1138
+ raise
1139
+ end
1135
1140
  end
1136
1141
 
1137
1142
  # Finds a value from this `Vector` which meets the condition defined by the
@@ -1301,7 +1306,7 @@ module Immutable
1301
1306
  flatten_node(@root, @levels * BITS_PER_LEVEL, [])
1302
1307
  end
1303
1308
  end
1304
- alias :to_ary :to_a
1309
+ alias to_ary to_a
1305
1310
 
1306
1311
  # Return true if `other` has the same type and contents as this `Vector`.
1307
1312
  #
@@ -1325,7 +1330,7 @@ module Immutable
1325
1330
  def dup
1326
1331
  self
1327
1332
  end
1328
- alias :clone :dup
1333
+ alias clone dup
1329
1334
 
1330
1335
  # @return [::Array]
1331
1336
  # @private
@@ -1454,7 +1459,7 @@ module Immutable
1454
1459
  from_slot.upto(node.size-1) do |i|
1455
1460
  flatten_node(node[i], bitshift - BITS_PER_LEVEL, result)
1456
1461
  end
1457
- elsif child = node[from_slot]
1462
+ elsif (child = node[from_slot])
1458
1463
  flatten_suffix(child, bitshift - BITS_PER_LEVEL, from, result)
1459
1464
  (from_slot+1).upto(node.size-1) do |i|
1460
1465
  flatten_node(node[i], bitshift - BITS_PER_LEVEL, result)
@@ -1524,7 +1529,7 @@ module Immutable
1524
1529
  end
1525
1530
  result.concat(remainder)
1526
1531
  end
1527
- elsif child = node[from_slot]
1532
+ elsif (child = node[from_slot])
1528
1533
  result = node.take(from_slot)
1529
1534
  result.push(replace_node_suffix(child, bitshift - BITS_PER_LEVEL, from, suffix))
1530
1535
  remainder = suffix.shift((31 - from_slot) * (1 << bitshift))
@@ -1,5 +1,5 @@
1
1
  module Immutable
2
2
  # Current released gem version. Note that master will often have the same
3
3
  # value as a release gem but with different code.
4
- VERSION = "0.0.4"
4
+ VERSION = '0.1.0'
5
5
  end
data/lib/immutable.rb CHANGED
@@ -1,9 +1,9 @@
1
- require "immutable/core_ext"
2
- require "immutable/list"
3
- require "immutable/deque"
4
- require "immutable/hash"
5
- require "immutable/set"
6
- require "immutable/vector"
7
- require "immutable/sorted_set"
8
- require "immutable/nested"
9
- require "immutable/version"
1
+ require 'immutable/core_ext'
2
+ require 'immutable/list'
3
+ require 'immutable/deque'
4
+ require 'immutable/hash'
5
+ require 'immutable/set'
6
+ require 'immutable/vector'
7
+ require 'immutable/sorted_set'
8
+ require 'immutable/nested'
9
+ require 'immutable/version'