immutable-ruby 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (345) hide show
  1. checksums.yaml +5 -5
  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 +50 -15
  6. data/lib/immutable/enumerable.rb +19 -10
  7. data/lib/immutable/hash.rb +128 -28
  8. data/lib/immutable/list.rb +48 -48
  9. data/lib/immutable/nested.rb +10 -7
  10. data/lib/immutable/set.rb +30 -30
  11. data/lib/immutable/sorted_set.rb +77 -37
  12. data/lib/immutable/trie.rb +21 -29
  13. data/lib/immutable/vector.rb +61 -46
  14. data/lib/immutable/version.rb +1 -1
  15. data/lib/immutable.rb +9 -9
  16. metadata +44 -687
  17. data/spec/fixtures/io_spec.txt +0 -3
  18. data/spec/lib/immutable/core_ext/array_spec.rb +0 -13
  19. data/spec/lib/immutable/core_ext/enumerable_spec.rb +0 -29
  20. data/spec/lib/immutable/core_ext/io_spec.rb +0 -28
  21. data/spec/lib/immutable/deque/clear_spec.rb +0 -33
  22. data/spec/lib/immutable/deque/construction_spec.rb +0 -29
  23. data/spec/lib/immutable/deque/copying_spec.rb +0 -19
  24. data/spec/lib/immutable/deque/dequeue_spec.rb +0 -34
  25. data/spec/lib/immutable/deque/empty_spec.rb +0 -39
  26. data/spec/lib/immutable/deque/enqueue_spec.rb +0 -27
  27. data/spec/lib/immutable/deque/first_spec.rb +0 -17
  28. data/spec/lib/immutable/deque/inspect_spec.rb +0 -23
  29. data/spec/lib/immutable/deque/last_spec.rb +0 -17
  30. data/spec/lib/immutable/deque/marshal_spec.rb +0 -33
  31. data/spec/lib/immutable/deque/new_spec.rb +0 -43
  32. data/spec/lib/immutable/deque/pop_spec.rb +0 -36
  33. data/spec/lib/immutable/deque/pretty_print_spec.rb +0 -23
  34. data/spec/lib/immutable/deque/push_spec.rb +0 -36
  35. data/spec/lib/immutable/deque/random_modification_spec.rb +0 -33
  36. data/spec/lib/immutable/deque/shift_spec.rb +0 -29
  37. data/spec/lib/immutable/deque/size_spec.rb +0 -19
  38. data/spec/lib/immutable/deque/to_a_spec.rb +0 -26
  39. data/spec/lib/immutable/deque/to_ary_spec.rb +0 -35
  40. data/spec/lib/immutable/deque/to_list_spec.rb +0 -24
  41. data/spec/lib/immutable/deque/unshift_spec.rb +0 -30
  42. data/spec/lib/immutable/hash/all_spec.rb +0 -53
  43. data/spec/lib/immutable/hash/any_spec.rb +0 -53
  44. data/spec/lib/immutable/hash/assoc_spec.rb +0 -51
  45. data/spec/lib/immutable/hash/clear_spec.rb +0 -42
  46. data/spec/lib/immutable/hash/construction_spec.rb +0 -38
  47. data/spec/lib/immutable/hash/copying_spec.rb +0 -13
  48. data/spec/lib/immutable/hash/default_proc_spec.rb +0 -72
  49. data/spec/lib/immutable/hash/delete_spec.rb +0 -39
  50. data/spec/lib/immutable/hash/each_spec.rb +0 -77
  51. data/spec/lib/immutable/hash/each_with_index_spec.rb +0 -29
  52. data/spec/lib/immutable/hash/empty_spec.rb +0 -43
  53. data/spec/lib/immutable/hash/eql_spec.rb +0 -69
  54. data/spec/lib/immutable/hash/except_spec.rb +0 -42
  55. data/spec/lib/immutable/hash/fetch_spec.rb +0 -57
  56. data/spec/lib/immutable/hash/find_spec.rb +0 -43
  57. data/spec/lib/immutable/hash/flat_map_spec.rb +0 -35
  58. data/spec/lib/immutable/hash/flatten_spec.rb +0 -98
  59. data/spec/lib/immutable/hash/get_spec.rb +0 -79
  60. data/spec/lib/immutable/hash/has_key_spec.rb +0 -31
  61. data/spec/lib/immutable/hash/has_value_spec.rb +0 -27
  62. data/spec/lib/immutable/hash/hash_spec.rb +0 -29
  63. data/spec/lib/immutable/hash/inspect_spec.rb +0 -30
  64. data/spec/lib/immutable/hash/invert_spec.rb +0 -30
  65. data/spec/lib/immutable/hash/key_spec.rb +0 -27
  66. data/spec/lib/immutable/hash/keys_spec.rb +0 -15
  67. data/spec/lib/immutable/hash/map_spec.rb +0 -45
  68. data/spec/lib/immutable/hash/marshal_spec.rb +0 -28
  69. data/spec/lib/immutable/hash/merge_spec.rb +0 -82
  70. data/spec/lib/immutable/hash/min_max_spec.rb +0 -45
  71. data/spec/lib/immutable/hash/new_spec.rb +0 -70
  72. data/spec/lib/immutable/hash/none_spec.rb +0 -48
  73. data/spec/lib/immutable/hash/partition_spec.rb +0 -35
  74. data/spec/lib/immutable/hash/pretty_print_spec.rb +0 -34
  75. data/spec/lib/immutable/hash/put_spec.rb +0 -102
  76. data/spec/lib/immutable/hash/reduce_spec.rb +0 -35
  77. data/spec/lib/immutable/hash/reject_spec.rb +0 -61
  78. data/spec/lib/immutable/hash/reverse_each_spec.rb +0 -27
  79. data/spec/lib/immutable/hash/sample_spec.rb +0 -13
  80. data/spec/lib/immutable/hash/select_spec.rb +0 -57
  81. data/spec/lib/immutable/hash/size_spec.rb +0 -51
  82. data/spec/lib/immutable/hash/slice_spec.rb +0 -44
  83. data/spec/lib/immutable/hash/sort_spec.rb +0 -26
  84. data/spec/lib/immutable/hash/store_spec.rb +0 -75
  85. data/spec/lib/immutable/hash/take_spec.rb +0 -35
  86. data/spec/lib/immutable/hash/to_a_spec.rb +0 -13
  87. data/spec/lib/immutable/hash/to_hash_spec.rb +0 -21
  88. data/spec/lib/immutable/hash/update_in_spec.rb +0 -79
  89. data/spec/lib/immutable/hash/values_at_spec.rb +0 -13
  90. data/spec/lib/immutable/hash/values_spec.rb +0 -23
  91. data/spec/lib/immutable/list/add_spec.rb +0 -25
  92. data/spec/lib/immutable/list/all_spec.rb +0 -57
  93. data/spec/lib/immutable/list/any_spec.rb +0 -49
  94. data/spec/lib/immutable/list/append_spec.rb +0 -38
  95. data/spec/lib/immutable/list/at_spec.rb +0 -29
  96. data/spec/lib/immutable/list/break_spec.rb +0 -69
  97. data/spec/lib/immutable/list/cadr_spec.rb +0 -38
  98. data/spec/lib/immutable/list/chunk_spec.rb +0 -28
  99. data/spec/lib/immutable/list/clear_spec.rb +0 -24
  100. data/spec/lib/immutable/list/combination_spec.rb +0 -33
  101. data/spec/lib/immutable/list/compact_spec.rb +0 -34
  102. data/spec/lib/immutable/list/compare_spec.rb +0 -30
  103. data/spec/lib/immutable/list/cons_spec.rb +0 -25
  104. data/spec/lib/immutable/list/construction_spec.rb +0 -110
  105. data/spec/lib/immutable/list/copying_spec.rb +0 -19
  106. data/spec/lib/immutable/list/count_spec.rb +0 -36
  107. data/spec/lib/immutable/list/cycle_spec.rb +0 -28
  108. data/spec/lib/immutable/list/delete_at_spec.rb +0 -18
  109. data/spec/lib/immutable/list/delete_spec.rb +0 -16
  110. data/spec/lib/immutable/list/drop_spec.rb +0 -30
  111. data/spec/lib/immutable/list/drop_while_spec.rb +0 -38
  112. data/spec/lib/immutable/list/each_slice_spec.rb +0 -51
  113. data/spec/lib/immutable/list/each_spec.rb +0 -40
  114. data/spec/lib/immutable/list/each_with_index_spec.rb +0 -28
  115. data/spec/lib/immutable/list/empty_spec.rb +0 -23
  116. data/spec/lib/immutable/list/eql_spec.rb +0 -61
  117. data/spec/lib/immutable/list/fill_spec.rb +0 -49
  118. data/spec/lib/immutable/list/find_all_spec.rb +0 -70
  119. data/spec/lib/immutable/list/find_index_spec.rb +0 -35
  120. data/spec/lib/immutable/list/find_spec.rb +0 -42
  121. data/spec/lib/immutable/list/flat_map_spec.rb +0 -51
  122. data/spec/lib/immutable/list/flatten_spec.rb +0 -30
  123. data/spec/lib/immutable/list/grep_spec.rb +0 -46
  124. data/spec/lib/immutable/list/group_by_spec.rb +0 -41
  125. data/spec/lib/immutable/list/hash_spec.rb +0 -21
  126. data/spec/lib/immutable/list/head_spec.rb +0 -19
  127. data/spec/lib/immutable/list/include_spec.rb +0 -35
  128. data/spec/lib/immutable/list/index_spec.rb +0 -33
  129. data/spec/lib/immutable/list/indices_spec.rb +0 -61
  130. data/spec/lib/immutable/list/init_spec.rb +0 -28
  131. data/spec/lib/immutable/list/inits_spec.rb +0 -28
  132. data/spec/lib/immutable/list/insert_spec.rb +0 -46
  133. data/spec/lib/immutable/list/inspect_spec.rb +0 -29
  134. data/spec/lib/immutable/list/intersperse_spec.rb +0 -28
  135. data/spec/lib/immutable/list/join_spec.rb +0 -63
  136. data/spec/lib/immutable/list/last_spec.rb +0 -23
  137. data/spec/lib/immutable/list/ltlt_spec.rb +0 -19
  138. data/spec/lib/immutable/list/map_spec.rb +0 -45
  139. data/spec/lib/immutable/list/maximum_spec.rb +0 -39
  140. data/spec/lib/immutable/list/merge_by_spec.rb +0 -51
  141. data/spec/lib/immutable/list/merge_spec.rb +0 -59
  142. data/spec/lib/immutable/list/minimum_spec.rb +0 -39
  143. data/spec/lib/immutable/list/multithreading_spec.rb +0 -47
  144. data/spec/lib/immutable/list/none_spec.rb +0 -47
  145. data/spec/lib/immutable/list/one_spec.rb +0 -49
  146. data/spec/lib/immutable/list/partition_spec.rb +0 -115
  147. data/spec/lib/immutable/list/permutation_spec.rb +0 -55
  148. data/spec/lib/immutable/list/pop_spec.rb +0 -25
  149. data/spec/lib/immutable/list/product_spec.rb +0 -23
  150. data/spec/lib/immutable/list/reduce_spec.rb +0 -53
  151. data/spec/lib/immutable/list/reject_spec.rb +0 -45
  152. data/spec/lib/immutable/list/reverse_spec.rb +0 -34
  153. data/spec/lib/immutable/list/rotate_spec.rb +0 -36
  154. data/spec/lib/immutable/list/sample_spec.rb +0 -13
  155. data/spec/lib/immutable/list/select_spec.rb +0 -70
  156. data/spec/lib/immutable/list/size_spec.rb +0 -25
  157. data/spec/lib/immutable/list/slice_spec.rb +0 -229
  158. data/spec/lib/immutable/list/sorting_spec.rb +0 -46
  159. data/spec/lib/immutable/list/span_spec.rb +0 -76
  160. data/spec/lib/immutable/list/split_at_spec.rb +0 -43
  161. data/spec/lib/immutable/list/subsequences_spec.rb +0 -23
  162. data/spec/lib/immutable/list/sum_spec.rb +0 -23
  163. data/spec/lib/immutable/list/tail_spec.rb +0 -30
  164. data/spec/lib/immutable/list/tails_spec.rb +0 -28
  165. data/spec/lib/immutable/list/take_spec.rb +0 -30
  166. data/spec/lib/immutable/list/take_while_spec.rb +0 -46
  167. data/spec/lib/immutable/list/to_a_spec.rb +0 -39
  168. data/spec/lib/immutable/list/to_ary_spec.rb +0 -41
  169. data/spec/lib/immutable/list/to_list_spec.rb +0 -19
  170. data/spec/lib/immutable/list/to_set_spec.rb +0 -17
  171. data/spec/lib/immutable/list/transpose_spec.rb +0 -19
  172. data/spec/lib/immutable/list/union_spec.rb +0 -31
  173. data/spec/lib/immutable/list/uniq_spec.rb +0 -35
  174. data/spec/lib/immutable/list/zip_spec.rb +0 -23
  175. data/spec/lib/immutable/nested/construction_spec.rb +0 -95
  176. data/spec/lib/immutable/set/add_spec.rb +0 -75
  177. data/spec/lib/immutable/set/all_spec.rb +0 -51
  178. data/spec/lib/immutable/set/any_spec.rb +0 -51
  179. data/spec/lib/immutable/set/clear_spec.rb +0 -33
  180. data/spec/lib/immutable/set/compact_spec.rb +0 -30
  181. data/spec/lib/immutable/set/construction_spec.rb +0 -18
  182. data/spec/lib/immutable/set/copying_spec.rb +0 -13
  183. data/spec/lib/immutable/set/count_spec.rb +0 -36
  184. data/spec/lib/immutable/set/delete_spec.rb +0 -71
  185. data/spec/lib/immutable/set/difference_spec.rb +0 -49
  186. data/spec/lib/immutable/set/disjoint_spec.rb +0 -25
  187. data/spec/lib/immutable/set/each_spec.rb +0 -45
  188. data/spec/lib/immutable/set/empty_spec.rb +0 -44
  189. data/spec/lib/immutable/set/eqeq_spec.rb +0 -103
  190. data/spec/lib/immutable/set/eql_spec.rb +0 -109
  191. data/spec/lib/immutable/set/exclusion_spec.rb +0 -47
  192. data/spec/lib/immutable/set/find_spec.rb +0 -35
  193. data/spec/lib/immutable/set/first_spec.rb +0 -28
  194. data/spec/lib/immutable/set/flatten_spec.rb +0 -46
  195. data/spec/lib/immutable/set/grep_spec.rb +0 -57
  196. data/spec/lib/immutable/set/group_by_spec.rb +0 -59
  197. data/spec/lib/immutable/set/hash_spec.rb +0 -22
  198. data/spec/lib/immutable/set/include_spec.rb +0 -60
  199. data/spec/lib/immutable/set/inspect_spec.rb +0 -47
  200. data/spec/lib/immutable/set/intersect_spec.rb +0 -25
  201. data/spec/lib/immutable/set/intersection_spec.rb +0 -52
  202. data/spec/lib/immutable/set/join_spec.rb +0 -64
  203. data/spec/lib/immutable/set/map_spec.rb +0 -59
  204. data/spec/lib/immutable/set/marshal_spec.rb +0 -28
  205. data/spec/lib/immutable/set/maximum_spec.rb +0 -36
  206. data/spec/lib/immutable/set/minimum_spec.rb +0 -36
  207. data/spec/lib/immutable/set/new_spec.rb +0 -53
  208. data/spec/lib/immutable/set/none_spec.rb +0 -47
  209. data/spec/lib/immutable/set/one_spec.rb +0 -47
  210. data/spec/lib/immutable/set/partition_spec.rb +0 -52
  211. data/spec/lib/immutable/set/product_spec.rb +0 -23
  212. data/spec/lib/immutable/set/reduce_spec.rb +0 -55
  213. data/spec/lib/immutable/set/reject_spec.rb +0 -50
  214. data/spec/lib/immutable/set/reverse_each_spec.rb +0 -38
  215. data/spec/lib/immutable/set/sample_spec.rb +0 -13
  216. data/spec/lib/immutable/set/select_spec.rb +0 -73
  217. data/spec/lib/immutable/set/size_spec.rb +0 -17
  218. data/spec/lib/immutable/set/sorting_spec.rb +0 -59
  219. data/spec/lib/immutable/set/subset_spec.rb +0 -51
  220. data/spec/lib/immutable/set/sum_spec.rb +0 -23
  221. data/spec/lib/immutable/set/superset_spec.rb +0 -51
  222. data/spec/lib/immutable/set/to_a_spec.rb +0 -30
  223. data/spec/lib/immutable/set/to_list_spec.rb +0 -35
  224. data/spec/lib/immutable/set/to_set_spec.rb +0 -19
  225. data/spec/lib/immutable/set/union_spec.rb +0 -63
  226. data/spec/lib/immutable/sorted_set/above_spec.rb +0 -51
  227. data/spec/lib/immutable/sorted_set/add_spec.rb +0 -62
  228. data/spec/lib/immutable/sorted_set/at_spec.rb +0 -24
  229. data/spec/lib/immutable/sorted_set/below_spec.rb +0 -51
  230. data/spec/lib/immutable/sorted_set/between_spec.rb +0 -51
  231. data/spec/lib/immutable/sorted_set/clear_spec.rb +0 -43
  232. data/spec/lib/immutable/sorted_set/copying_spec.rb +0 -20
  233. data/spec/lib/immutable/sorted_set/delete_at_spec.rb +0 -18
  234. data/spec/lib/immutable/sorted_set/delete_spec.rb +0 -89
  235. data/spec/lib/immutable/sorted_set/difference_spec.rb +0 -22
  236. data/spec/lib/immutable/sorted_set/disjoint_spec.rb +0 -25
  237. data/spec/lib/immutable/sorted_set/drop_spec.rb +0 -55
  238. data/spec/lib/immutable/sorted_set/drop_while_spec.rb +0 -34
  239. data/spec/lib/immutable/sorted_set/each_spec.rb +0 -28
  240. data/spec/lib/immutable/sorted_set/empty_spec.rb +0 -34
  241. data/spec/lib/immutable/sorted_set/eql_spec.rb +0 -120
  242. data/spec/lib/immutable/sorted_set/exclusion_spec.rb +0 -22
  243. data/spec/lib/immutable/sorted_set/fetch_spec.rb +0 -64
  244. data/spec/lib/immutable/sorted_set/find_index_spec.rb +0 -40
  245. data/spec/lib/immutable/sorted_set/first_spec.rb +0 -18
  246. data/spec/lib/immutable/sorted_set/from_spec.rb +0 -51
  247. data/spec/lib/immutable/sorted_set/group_by_spec.rb +0 -57
  248. data/spec/lib/immutable/sorted_set/include_spec.rb +0 -23
  249. data/spec/lib/immutable/sorted_set/inspect_spec.rb +0 -37
  250. data/spec/lib/immutable/sorted_set/intersect_spec.rb +0 -25
  251. data/spec/lib/immutable/sorted_set/intersection_spec.rb +0 -28
  252. data/spec/lib/immutable/sorted_set/last_spec.rb +0 -36
  253. data/spec/lib/immutable/sorted_set/map_spec.rb +0 -43
  254. data/spec/lib/immutable/sorted_set/marshal_spec.rb +0 -36
  255. data/spec/lib/immutable/sorted_set/maximum_spec.rb +0 -36
  256. data/spec/lib/immutable/sorted_set/minimum_spec.rb +0 -19
  257. data/spec/lib/immutable/sorted_set/new_spec.rb +0 -71
  258. data/spec/lib/immutable/sorted_set/reverse_each_spec.rb +0 -28
  259. data/spec/lib/immutable/sorted_set/sample_spec.rb +0 -13
  260. data/spec/lib/immutable/sorted_set/select_spec.rb +0 -61
  261. data/spec/lib/immutable/sorted_set/size_spec.rb +0 -17
  262. data/spec/lib/immutable/sorted_set/slice_spec.rb +0 -256
  263. data/spec/lib/immutable/sorted_set/sorting_spec.rb +0 -44
  264. data/spec/lib/immutable/sorted_set/subset_spec.rb +0 -47
  265. data/spec/lib/immutable/sorted_set/superset_spec.rb +0 -47
  266. data/spec/lib/immutable/sorted_set/take_spec.rb +0 -54
  267. data/spec/lib/immutable/sorted_set/take_while_spec.rb +0 -33
  268. data/spec/lib/immutable/sorted_set/to_set_spec.rb +0 -17
  269. data/spec/lib/immutable/sorted_set/union_spec.rb +0 -27
  270. data/spec/lib/immutable/sorted_set/up_to_spec.rb +0 -52
  271. data/spec/lib/immutable/sorted_set/values_at_spec.rb +0 -33
  272. data/spec/lib/immutable/vector/add_spec.rb +0 -67
  273. data/spec/lib/immutable/vector/any_spec.rb +0 -69
  274. data/spec/lib/immutable/vector/assoc_spec.rb +0 -45
  275. data/spec/lib/immutable/vector/bsearch_spec.rb +0 -65
  276. data/spec/lib/immutable/vector/clear_spec.rb +0 -33
  277. data/spec/lib/immutable/vector/combination_spec.rb +0 -81
  278. data/spec/lib/immutable/vector/compact_spec.rb +0 -29
  279. data/spec/lib/immutable/vector/compare_spec.rb +0 -31
  280. data/spec/lib/immutable/vector/concat_spec.rb +0 -34
  281. data/spec/lib/immutable/vector/copying_spec.rb +0 -20
  282. data/spec/lib/immutable/vector/count_spec.rb +0 -17
  283. data/spec/lib/immutable/vector/delete_at_spec.rb +0 -53
  284. data/spec/lib/immutable/vector/delete_spec.rb +0 -30
  285. data/spec/lib/immutable/vector/drop_spec.rb +0 -41
  286. data/spec/lib/immutable/vector/drop_while_spec.rb +0 -54
  287. data/spec/lib/immutable/vector/each_index_spec.rb +0 -40
  288. data/spec/lib/immutable/vector/each_spec.rb +0 -44
  289. data/spec/lib/immutable/vector/each_with_index_spec.rb +0 -39
  290. data/spec/lib/immutable/vector/empty_spec.rb +0 -41
  291. data/spec/lib/immutable/vector/eql_spec.rb +0 -76
  292. data/spec/lib/immutable/vector/fetch_spec.rb +0 -64
  293. data/spec/lib/immutable/vector/fill_spec.rb +0 -88
  294. data/spec/lib/immutable/vector/first_spec.rb +0 -18
  295. data/spec/lib/immutable/vector/flat_map_spec.rb +0 -50
  296. data/spec/lib/immutable/vector/flatten_spec.rb +0 -58
  297. data/spec/lib/immutable/vector/get_spec.rb +0 -74
  298. data/spec/lib/immutable/vector/group_by_spec.rb +0 -57
  299. data/spec/lib/immutable/vector/include_spec.rb +0 -30
  300. data/spec/lib/immutable/vector/insert_spec.rb +0 -68
  301. data/spec/lib/immutable/vector/inspect_spec.rb +0 -49
  302. data/spec/lib/immutable/vector/join_spec.rb +0 -58
  303. data/spec/lib/immutable/vector/last_spec.rb +0 -45
  304. data/spec/lib/immutable/vector/length_spec.rb +0 -45
  305. data/spec/lib/immutable/vector/ltlt_spec.rb +0 -65
  306. data/spec/lib/immutable/vector/map_spec.rb +0 -51
  307. data/spec/lib/immutable/vector/marshal_spec.rb +0 -31
  308. data/spec/lib/immutable/vector/maximum_spec.rb +0 -33
  309. data/spec/lib/immutable/vector/minimum_spec.rb +0 -33
  310. data/spec/lib/immutable/vector/multiply_spec.rb +0 -47
  311. data/spec/lib/immutable/vector/new_spec.rb +0 -50
  312. data/spec/lib/immutable/vector/partition_spec.rb +0 -52
  313. data/spec/lib/immutable/vector/permutation_spec.rb +0 -91
  314. data/spec/lib/immutable/vector/pop_spec.rb +0 -26
  315. data/spec/lib/immutable/vector/product_spec.rb +0 -70
  316. data/spec/lib/immutable/vector/reduce_spec.rb +0 -55
  317. data/spec/lib/immutable/vector/reject_spec.rb +0 -43
  318. data/spec/lib/immutable/vector/repeated_combination_spec.rb +0 -77
  319. data/spec/lib/immutable/vector/repeated_permutation_spec.rb +0 -93
  320. data/spec/lib/immutable/vector/reverse_each_spec.rb +0 -31
  321. data/spec/lib/immutable/vector/reverse_spec.rb +0 -21
  322. data/spec/lib/immutable/vector/rindex_spec.rb +0 -36
  323. data/spec/lib/immutable/vector/rotate_spec.rb +0 -73
  324. data/spec/lib/immutable/vector/sample_spec.rb +0 -13
  325. data/spec/lib/immutable/vector/select_spec.rb +0 -63
  326. data/spec/lib/immutable/vector/set_spec.rb +0 -174
  327. data/spec/lib/immutable/vector/shift_spec.rb +0 -27
  328. data/spec/lib/immutable/vector/shuffle_spec.rb +0 -43
  329. data/spec/lib/immutable/vector/slice_spec.rb +0 -240
  330. data/spec/lib/immutable/vector/sorting_spec.rb +0 -56
  331. data/spec/lib/immutable/vector/sum_spec.rb +0 -17
  332. data/spec/lib/immutable/vector/take_spec.rb +0 -42
  333. data/spec/lib/immutable/vector/take_while_spec.rb +0 -34
  334. data/spec/lib/immutable/vector/to_a_spec.rb +0 -41
  335. data/spec/lib/immutable/vector/to_ary_spec.rb +0 -34
  336. data/spec/lib/immutable/vector/to_list_spec.rb +0 -30
  337. data/spec/lib/immutable/vector/to_set_spec.rb +0 -21
  338. data/spec/lib/immutable/vector/transpose_spec.rb +0 -48
  339. data/spec/lib/immutable/vector/uniq_spec.rb +0 -76
  340. data/spec/lib/immutable/vector/unshift_spec.rb +0 -28
  341. data/spec/lib/immutable/vector/update_in_spec.rb +0 -82
  342. data/spec/lib/immutable/vector/values_at_spec.rb +0 -33
  343. data/spec/lib/immutable/vector/zip_spec.rb +0 -57
  344. data/spec/lib/load_spec.rb +0 -42
  345. data/spec/spec_helper.rb +0 -92
@@ -1,11 +1,11 @@
1
- require "thread"
2
- require "set"
3
- require "concurrent/atomics"
1
+ require 'thread'
2
+ require 'set'
3
+ require 'concurrent'
4
4
 
5
- require "immutable/undefined"
6
- require "immutable/enumerable"
7
- require "immutable/hash"
8
- require "immutable/set"
5
+ require 'immutable/undefined'
6
+ require 'immutable/enumerable'
7
+ require 'immutable/hash'
8
+ require 'immutable/set'
9
9
 
10
10
  module Immutable
11
11
  class << self
@@ -175,7 +175,7 @@ module Immutable
175
175
  end
176
176
  result
177
177
  end
178
- alias :length :size
178
+ alias length size
179
179
 
180
180
  # Create a new `List` with `item` added at the front. This is a constant
181
181
  # time operation.
@@ -189,7 +189,7 @@ module Immutable
189
189
  def add(item)
190
190
  Cons.new(item, self)
191
191
  end
192
- alias :cons :add
192
+ alias cons add
193
193
 
194
194
  # Create a new `List` with `item` added at the end. This is much less efficient
195
195
  # than adding items at the front.
@@ -235,7 +235,7 @@ module Immutable
235
235
  Cons.new(yield(head), tail.map(&block))
236
236
  end
237
237
  end
238
- alias :collect :map
238
+ alias collect map
239
239
 
240
240
  # Return a `List` which is realized by transforming each item into a `List`,
241
241
  # and flattening the resulting lists.
@@ -268,15 +268,15 @@ module Immutable
268
268
  return enum_for(:select) unless block_given?
269
269
  LazyList.new do
270
270
  list = self
271
- while true
271
+ loop do
272
272
  break list if list.empty?
273
273
  break Cons.new(list.head, list.tail.select(&block)) if yield(list.head)
274
274
  list = list.tail
275
275
  end
276
276
  end
277
277
  end
278
- alias :find_all :select
279
- alias :keep_if :select
278
+ alias find_all select
279
+ alias keep_if select
280
280
 
281
281
  # Return a `List` which contains all elements up to, but not including, the
282
282
  # first element for which the block returns `nil` or `false`.
@@ -380,8 +380,8 @@ module Immutable
380
380
  Cons.new(head, tail.append(other))
381
381
  end
382
382
  end
383
- alias :concat :append
384
- alias :+ :append
383
+ alias concat append
384
+ alias + append
385
385
 
386
386
  # Return a `List` with the same items, but in reverse order.
387
387
  #
@@ -440,7 +440,7 @@ module Immutable
440
440
  def transpose
441
441
  return EmptyList if empty?
442
442
  LazyList.new do
443
- next EmptyList if any? { |list| list.empty? }
443
+ next EmptyList if any?(&:empty?)
444
444
  heads, tails = EmptyList, EmptyList
445
445
  reverse_each { |list| heads, tails = heads.cons(list.head), tails.cons(list.tail) }
446
446
  Cons.new(heads, tails.transpose)
@@ -477,7 +477,7 @@ module Immutable
477
477
  # @return [Vector]
478
478
  # @raise [TypeError] if count is not an integer.
479
479
  def rotate(count = 1)
480
- raise TypeError, "expected Integer" if not count.is_a?(Integer)
480
+ raise TypeError, 'expected Integer' if not count.is_a?(Integer)
481
481
  return self if empty? || (count % size) == 0
482
482
  count = (count >= 0) ? count % size : (size - (~count % size) - 1)
483
483
  drop(count).append(take(count))
@@ -640,7 +640,7 @@ module Immutable
640
640
  Cons.new(head, tail.union(other, items.add(head)))
641
641
  end
642
642
  end
643
- alias :| :union
643
+ alias | union
644
644
 
645
645
  # Return a `List` with all elements except the last one.
646
646
  #
@@ -742,7 +742,7 @@ module Immutable
742
742
  chunk(number).each(&block)
743
743
  self
744
744
  end
745
- alias :each_slice :each_chunk
745
+ alias each_slice each_chunk
746
746
 
747
747
  # Return a new `List` with all nested lists recursively "flattened out",
748
748
  # that is, their elements inserted into the new `List` in the place where
@@ -776,7 +776,7 @@ module Immutable
776
776
  def group_by(&block)
777
777
  group_by_with(EmptyList, &block)
778
778
  end
779
- alias :group :group_by
779
+ alias group group_by
780
780
 
781
781
  # Retrieve the item at `index`. Negative indices count back from the end of
782
782
  # the list (-1 is the last item). If `index` is invalid (either too high or
@@ -868,7 +868,7 @@ module Immutable
868
868
  list.take(length)
869
869
  end
870
870
  end
871
- alias :[] :slice
871
+ alias [] slice
872
872
 
873
873
  # Return a `List` of indices of matching objects.
874
874
  #
@@ -895,7 +895,7 @@ module Immutable
895
895
  return EmptyList if empty?
896
896
  LazyList.new do
897
897
  node = self
898
- while true
898
+ loop do
899
899
  break Cons.new(i, node.tail.indices(Undefined, i + 1, &block)) if yield(node.head)
900
900
  node = node.tail
901
901
  break EmptyList if node.empty?
@@ -1187,7 +1187,7 @@ module Immutable
1187
1187
  def dup
1188
1188
  self
1189
1189
  end
1190
- alias :clone :dup
1190
+ alias clone dup
1191
1191
 
1192
1192
  # Return `self`.
1193
1193
  # @return [List]
@@ -1201,9 +1201,9 @@ module Immutable
1201
1201
  #
1202
1202
  # @return [String]
1203
1203
  def inspect
1204
- result = "Immutable::List["
1204
+ result = 'Immutable::List['
1205
1205
  each_with_index { |obj, i| result << ', ' if i > 0; result << obj.inspect }
1206
- result << "]"
1206
+ result << ']'
1207
1207
  end
1208
1208
 
1209
1209
  # Allows this `List` to be printed at the `pry` console, or using `pp` (from the
@@ -1213,7 +1213,7 @@ module Immutable
1213
1213
  #
1214
1214
  # @private
1215
1215
  def pretty_print(pp)
1216
- pp.group(1, "Immutable::List[", "]") do
1216
+ pp.group(1, 'Immutable::List[', ']') do
1217
1217
  pp.breakable ''
1218
1218
  pp.seplist(self) { |obj| obj.pretty_print(pp) }
1219
1219
  end
@@ -1290,7 +1290,7 @@ module Immutable
1290
1290
  def size
1291
1291
  @size ||= super
1292
1292
  end
1293
- alias :length :size
1293
+ alias length size
1294
1294
 
1295
1295
  def cached_size?
1296
1296
  @size != nil
@@ -1311,30 +1311,30 @@ module Immutable
1311
1311
  def initialize(&block)
1312
1312
  @head = block # doubles as storage for block while yet unrealized
1313
1313
  @tail = nil
1314
- @atomic = Concurrent::Atomic.new(0) # haven't yet run block
1314
+ @atomic = Concurrent::Atom.new(0) # haven't yet run block
1315
1315
  @size = nil
1316
1316
  end
1317
1317
 
1318
1318
  def head
1319
- realize if @atomic.get != 2
1319
+ realize if @atomic.value != 2
1320
1320
  @head
1321
1321
  end
1322
- alias :first :head
1322
+ alias first head
1323
1323
 
1324
1324
  def tail
1325
- realize if @atomic.get != 2
1325
+ realize if @atomic.value != 2
1326
1326
  @tail
1327
1327
  end
1328
1328
 
1329
1329
  def empty?
1330
- realize if @atomic.get != 2
1330
+ realize if @atomic.value != 2
1331
1331
  @size == 0
1332
1332
  end
1333
1333
 
1334
1334
  def size
1335
1335
  @size ||= super
1336
1336
  end
1337
- alias :length :size
1337
+ alias length size
1338
1338
 
1339
1339
  def cached_size?
1340
1340
  @size != nil
@@ -1346,9 +1346,9 @@ module Immutable
1346
1346
  MUTEX = Mutex.new
1347
1347
 
1348
1348
  def realize
1349
- while true
1349
+ loop do
1350
1350
  # try to "claim" the right to run the block which realizes target
1351
- if @atomic.compare_and_swap(0,1) # full memory barrier here
1351
+ if @atomic.compare_and_set(0,1) # full memory barrier here
1352
1352
  begin
1353
1353
  list = @head.call
1354
1354
  if list.empty?
@@ -1357,22 +1357,22 @@ module Immutable
1357
1357
  @head, @tail = list.head, list.tail
1358
1358
  end
1359
1359
  rescue
1360
- @atomic.set(0)
1360
+ @atomic.reset(0)
1361
1361
  MUTEX.synchronize { QUEUE.broadcast }
1362
1362
  raise
1363
1363
  end
1364
- @atomic.set(2)
1364
+ @atomic.reset(2)
1365
1365
  MUTEX.synchronize { QUEUE.broadcast }
1366
1366
  return
1367
1367
  end
1368
1368
  # we failed to "claim" it, another thread must be running it
1369
- if @atomic.get == 1 # another thread is running the block
1369
+ if @atomic.value == 1 # another thread is running the block
1370
1370
  MUTEX.synchronize do
1371
1371
  # check value of @atomic again, in case another thread already changed it
1372
1372
  # *and* went past the call to QUEUE.broadcast before we got here
1373
- QUEUE.wait(MUTEX) if @atomic.get == 1
1373
+ QUEUE.wait(MUTEX) if @atomic.value == 1
1374
1374
  end
1375
- elsif @atomic.get == 2 # another thread finished the block
1375
+ elsif @atomic.value == 2 # another thread finished the block
1376
1376
  return
1377
1377
  end
1378
1378
  end
@@ -1392,7 +1392,7 @@ module Immutable
1392
1392
  realize if @head == Undefined
1393
1393
  @head
1394
1394
  end
1395
- alias :first :head
1395
+ alias first head
1396
1396
 
1397
1397
  def tail
1398
1398
  realize if @tail == Undefined
@@ -1407,7 +1407,7 @@ module Immutable
1407
1407
  def size
1408
1408
  @size ||= super
1409
1409
  end
1410
- alias :length :size
1410
+ alias length size
1411
1411
 
1412
1412
  def cached_size?
1413
1413
  @size != nil
@@ -1455,7 +1455,7 @@ module Immutable
1455
1455
  mutex = @mutex
1456
1456
  mutex && mutex.synchronize do
1457
1457
  return if @head != Undefined # another thread got ahead of us
1458
- while true
1458
+ loop do
1459
1459
  if !@buffer.empty?
1460
1460
  @head = @buffer.shift
1461
1461
  @tail = Partitioned.new(@partitioner, @buffer, @mutex)
@@ -1516,7 +1516,7 @@ module Immutable
1516
1516
  mutex = @mutex
1517
1517
  mutex && mutex.synchronize do
1518
1518
  return if @head != Undefined # another thread got ahead of us
1519
- while true
1519
+ loop do
1520
1520
  if !@buffer.empty?
1521
1521
  @head = @buffer.shift
1522
1522
  @tail = Left.new(@splitter, @buffer, @mutex)
@@ -1568,7 +1568,7 @@ module Immutable
1568
1568
  def head
1569
1569
  nil
1570
1570
  end
1571
- alias :first :head
1571
+ alias first head
1572
1572
 
1573
1573
  # There are no subsequent elements, so return an empty list.
1574
1574
  # @return [self]
@@ -1585,11 +1585,11 @@ module Immutable
1585
1585
  def size
1586
1586
  0
1587
1587
  end
1588
- alias :length :size
1588
+ alias length size
1589
1589
 
1590
1590
  def cached_size?
1591
1591
  true
1592
1592
  end
1593
1593
  end
1594
- end
1595
- end.freeze
1594
+ end.freeze
1595
+ end
@@ -1,10 +1,11 @@
1
- require "set"
2
- require "immutable/hash"
3
- require "immutable/set"
4
- require "immutable/vector"
5
- require "immutable/sorted_set"
6
- require "immutable/list"
7
- require "immutable/deque"
1
+ require 'set'
2
+ require 'sorted_set'
3
+ require 'immutable/hash'
4
+ require 'immutable/set'
5
+ require 'immutable/vector'
6
+ require 'immutable/sorted_set'
7
+ require 'immutable/list'
8
+ require 'immutable/deque'
8
9
 
9
10
  module Immutable
10
11
  class << self
@@ -30,6 +31,8 @@ module Immutable
30
31
  when ::Array
31
32
  res = obj.map { |element| from(element) }
32
33
  Immutable::Vector.new(res)
34
+ when ::Struct
35
+ from(obj.to_h)
33
36
  when ::SortedSet
34
37
  # This clause must go before ::Set clause, since ::SortedSet is a ::Set.
35
38
  res = obj.map { |element| from(element) }
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