immutable-ruby 0.0.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/immutable/_core.rb +3067 -0
- data/lib/immutable/core_ext/enumerable.rb +1 -1
- data/lib/immutable/core_ext/io.rb +1 -1
- data/lib/immutable/core_ext.rb +2 -2
- data/lib/immutable/deque.rb +17 -17
- data/lib/immutable/enumerable.rb +10 -10
- data/lib/immutable/hash.rb +4 -941
- data/lib/immutable/list.rb +36 -36
- data/lib/immutable/nested.rb +8 -8
- data/lib/immutable/set.rb +3 -583
- data/lib/immutable/sorted_set.rb +29 -27
- data/lib/immutable/trie.rb +2 -2
- data/lib/immutable/vector.rb +3 -1549
- data/lib/immutable/version.rb +1 -1
- data/lib/immutable.rb +9 -9
- metadata +34 -696
- data/lib/immutable/core_ext/struct.rb +0 -9
- data/spec/fixtures/io_spec.txt +0 -3
- data/spec/lib/immutable/core_ext/array_spec.rb +0 -13
- data/spec/lib/immutable/core_ext/enumerable_spec.rb +0 -29
- data/spec/lib/immutable/core_ext/io_spec.rb +0 -28
- data/spec/lib/immutable/deque/clear_spec.rb +0 -33
- data/spec/lib/immutable/deque/construction_spec.rb +0 -29
- data/spec/lib/immutable/deque/copying_spec.rb +0 -19
- data/spec/lib/immutable/deque/dequeue_spec.rb +0 -34
- data/spec/lib/immutable/deque/empty_spec.rb +0 -39
- data/spec/lib/immutable/deque/enqueue_spec.rb +0 -27
- data/spec/lib/immutable/deque/first_spec.rb +0 -17
- data/spec/lib/immutable/deque/inspect_spec.rb +0 -23
- data/spec/lib/immutable/deque/last_spec.rb +0 -17
- data/spec/lib/immutable/deque/marshal_spec.rb +0 -33
- data/spec/lib/immutable/deque/new_spec.rb +0 -43
- data/spec/lib/immutable/deque/pop_spec.rb +0 -36
- data/spec/lib/immutable/deque/pretty_print_spec.rb +0 -23
- data/spec/lib/immutable/deque/push_spec.rb +0 -36
- data/spec/lib/immutable/deque/random_modification_spec.rb +0 -33
- data/spec/lib/immutable/deque/rotate_spec.rb +0 -68
- data/spec/lib/immutable/deque/shift_spec.rb +0 -29
- data/spec/lib/immutable/deque/size_spec.rb +0 -19
- data/spec/lib/immutable/deque/to_a_spec.rb +0 -26
- data/spec/lib/immutable/deque/to_ary_spec.rb +0 -35
- data/spec/lib/immutable/deque/to_list_spec.rb +0 -24
- data/spec/lib/immutable/deque/unshift_spec.rb +0 -30
- data/spec/lib/immutable/hash/all_spec.rb +0 -53
- data/spec/lib/immutable/hash/any_spec.rb +0 -53
- data/spec/lib/immutable/hash/assoc_spec.rb +0 -51
- data/spec/lib/immutable/hash/clear_spec.rb +0 -42
- data/spec/lib/immutable/hash/construction_spec.rb +0 -38
- data/spec/lib/immutable/hash/copying_spec.rb +0 -13
- data/spec/lib/immutable/hash/default_proc_spec.rb +0 -72
- data/spec/lib/immutable/hash/delete_spec.rb +0 -39
- data/spec/lib/immutable/hash/dig_spec.rb +0 -34
- data/spec/lib/immutable/hash/each_spec.rb +0 -77
- data/spec/lib/immutable/hash/each_with_index_spec.rb +0 -29
- data/spec/lib/immutable/hash/empty_spec.rb +0 -43
- data/spec/lib/immutable/hash/eql_spec.rb +0 -75
- data/spec/lib/immutable/hash/except_spec.rb +0 -42
- data/spec/lib/immutable/hash/fetch_spec.rb +0 -57
- data/spec/lib/immutable/hash/fetch_values_spec.rb +0 -22
- data/spec/lib/immutable/hash/find_spec.rb +0 -43
- data/spec/lib/immutable/hash/flat_map_spec.rb +0 -35
- data/spec/lib/immutable/hash/flatten_spec.rb +0 -98
- data/spec/lib/immutable/hash/get_spec.rb +0 -79
- data/spec/lib/immutable/hash/has_key_spec.rb +0 -31
- data/spec/lib/immutable/hash/has_value_spec.rb +0 -27
- data/spec/lib/immutable/hash/hash_spec.rb +0 -29
- data/spec/lib/immutable/hash/inspect_spec.rb +0 -30
- data/spec/lib/immutable/hash/invert_spec.rb +0 -30
- data/spec/lib/immutable/hash/key_spec.rb +0 -27
- data/spec/lib/immutable/hash/keys_spec.rb +0 -15
- data/spec/lib/immutable/hash/map_spec.rb +0 -45
- data/spec/lib/immutable/hash/marshal_spec.rb +0 -28
- data/spec/lib/immutable/hash/merge_spec.rb +0 -82
- data/spec/lib/immutable/hash/min_max_spec.rb +0 -45
- data/spec/lib/immutable/hash/new_spec.rb +0 -70
- data/spec/lib/immutable/hash/none_spec.rb +0 -48
- data/spec/lib/immutable/hash/partition_spec.rb +0 -35
- data/spec/lib/immutable/hash/pretty_print_spec.rb +0 -34
- data/spec/lib/immutable/hash/put_spec.rb +0 -111
- data/spec/lib/immutable/hash/reduce_spec.rb +0 -35
- data/spec/lib/immutable/hash/reject_spec.rb +0 -61
- data/spec/lib/immutable/hash/reverse_each_spec.rb +0 -27
- data/spec/lib/immutable/hash/sample_spec.rb +0 -13
- data/spec/lib/immutable/hash/select_spec.rb +0 -57
- data/spec/lib/immutable/hash/size_spec.rb +0 -51
- data/spec/lib/immutable/hash/slice_spec.rb +0 -44
- data/spec/lib/immutable/hash/sort_spec.rb +0 -26
- data/spec/lib/immutable/hash/store_spec.rb +0 -75
- data/spec/lib/immutable/hash/subset_spec.rb +0 -42
- data/spec/lib/immutable/hash/superset_spec.rb +0 -42
- data/spec/lib/immutable/hash/take_spec.rb +0 -35
- data/spec/lib/immutable/hash/to_a_spec.rb +0 -13
- data/spec/lib/immutable/hash/to_hash_spec.rb +0 -21
- data/spec/lib/immutable/hash/to_proc_spec.rb +0 -39
- data/spec/lib/immutable/hash/update_in_spec.rb +0 -79
- data/spec/lib/immutable/hash/values_at_spec.rb +0 -33
- data/spec/lib/immutable/hash/values_spec.rb +0 -23
- data/spec/lib/immutable/list/add_spec.rb +0 -25
- data/spec/lib/immutable/list/all_spec.rb +0 -57
- data/spec/lib/immutable/list/any_spec.rb +0 -49
- data/spec/lib/immutable/list/append_spec.rb +0 -38
- data/spec/lib/immutable/list/at_spec.rb +0 -29
- data/spec/lib/immutable/list/break_spec.rb +0 -69
- data/spec/lib/immutable/list/cadr_spec.rb +0 -38
- data/spec/lib/immutable/list/chunk_spec.rb +0 -28
- data/spec/lib/immutable/list/clear_spec.rb +0 -24
- data/spec/lib/immutable/list/combination_spec.rb +0 -33
- data/spec/lib/immutable/list/compact_spec.rb +0 -34
- data/spec/lib/immutable/list/compare_spec.rb +0 -30
- data/spec/lib/immutable/list/cons_spec.rb +0 -25
- data/spec/lib/immutable/list/construction_spec.rb +0 -110
- data/spec/lib/immutable/list/copying_spec.rb +0 -19
- data/spec/lib/immutable/list/count_spec.rb +0 -36
- data/spec/lib/immutable/list/cycle_spec.rb +0 -28
- data/spec/lib/immutable/list/delete_at_spec.rb +0 -18
- data/spec/lib/immutable/list/delete_spec.rb +0 -16
- data/spec/lib/immutable/list/drop_spec.rb +0 -30
- data/spec/lib/immutable/list/drop_while_spec.rb +0 -38
- data/spec/lib/immutable/list/each_slice_spec.rb +0 -51
- data/spec/lib/immutable/list/each_spec.rb +0 -40
- data/spec/lib/immutable/list/each_with_index_spec.rb +0 -28
- data/spec/lib/immutable/list/empty_spec.rb +0 -23
- data/spec/lib/immutable/list/eql_spec.rb +0 -61
- data/spec/lib/immutable/list/fill_spec.rb +0 -49
- data/spec/lib/immutable/list/find_all_spec.rb +0 -70
- data/spec/lib/immutable/list/find_index_spec.rb +0 -35
- data/spec/lib/immutable/list/find_spec.rb +0 -42
- data/spec/lib/immutable/list/flat_map_spec.rb +0 -51
- data/spec/lib/immutable/list/flatten_spec.rb +0 -30
- data/spec/lib/immutable/list/grep_spec.rb +0 -46
- data/spec/lib/immutable/list/group_by_spec.rb +0 -41
- data/spec/lib/immutable/list/hash_spec.rb +0 -21
- data/spec/lib/immutable/list/head_spec.rb +0 -19
- data/spec/lib/immutable/list/include_spec.rb +0 -35
- data/spec/lib/immutable/list/index_spec.rb +0 -37
- data/spec/lib/immutable/list/indices_spec.rb +0 -61
- data/spec/lib/immutable/list/init_spec.rb +0 -28
- data/spec/lib/immutable/list/inits_spec.rb +0 -28
- data/spec/lib/immutable/list/insert_spec.rb +0 -46
- data/spec/lib/immutable/list/inspect_spec.rb +0 -29
- data/spec/lib/immutable/list/intersperse_spec.rb +0 -28
- data/spec/lib/immutable/list/join_spec.rb +0 -63
- data/spec/lib/immutable/list/last_spec.rb +0 -23
- data/spec/lib/immutable/list/ltlt_spec.rb +0 -19
- data/spec/lib/immutable/list/map_spec.rb +0 -45
- data/spec/lib/immutable/list/maximum_spec.rb +0 -39
- data/spec/lib/immutable/list/merge_by_spec.rb +0 -51
- data/spec/lib/immutable/list/merge_spec.rb +0 -59
- data/spec/lib/immutable/list/minimum_spec.rb +0 -39
- data/spec/lib/immutable/list/multithreading_spec.rb +0 -47
- data/spec/lib/immutable/list/none_spec.rb +0 -47
- data/spec/lib/immutable/list/one_spec.rb +0 -49
- data/spec/lib/immutable/list/partition_spec.rb +0 -115
- data/spec/lib/immutable/list/permutation_spec.rb +0 -55
- data/spec/lib/immutable/list/pop_spec.rb +0 -25
- data/spec/lib/immutable/list/product_spec.rb +0 -23
- data/spec/lib/immutable/list/reduce_spec.rb +0 -53
- data/spec/lib/immutable/list/reject_spec.rb +0 -45
- data/spec/lib/immutable/list/reverse_spec.rb +0 -34
- data/spec/lib/immutable/list/rotate_spec.rb +0 -36
- data/spec/lib/immutable/list/sample_spec.rb +0 -13
- data/spec/lib/immutable/list/select_spec.rb +0 -70
- data/spec/lib/immutable/list/size_spec.rb +0 -25
- data/spec/lib/immutable/list/slice_spec.rb +0 -229
- data/spec/lib/immutable/list/sorting_spec.rb +0 -46
- data/spec/lib/immutable/list/span_spec.rb +0 -76
- data/spec/lib/immutable/list/split_at_spec.rb +0 -43
- data/spec/lib/immutable/list/subsequences_spec.rb +0 -23
- data/spec/lib/immutable/list/sum_spec.rb +0 -23
- data/spec/lib/immutable/list/tail_spec.rb +0 -30
- data/spec/lib/immutable/list/tails_spec.rb +0 -28
- data/spec/lib/immutable/list/take_spec.rb +0 -30
- data/spec/lib/immutable/list/take_while_spec.rb +0 -46
- data/spec/lib/immutable/list/to_a_spec.rb +0 -39
- data/spec/lib/immutable/list/to_ary_spec.rb +0 -41
- data/spec/lib/immutable/list/to_list_spec.rb +0 -19
- data/spec/lib/immutable/list/to_set_spec.rb +0 -17
- data/spec/lib/immutable/list/transpose_spec.rb +0 -19
- data/spec/lib/immutable/list/union_spec.rb +0 -31
- data/spec/lib/immutable/list/uniq_spec.rb +0 -35
- data/spec/lib/immutable/list/zip_spec.rb +0 -23
- data/spec/lib/immutable/nested/construction_spec.rb +0 -101
- data/spec/lib/immutable/set/add_spec.rb +0 -77
- data/spec/lib/immutable/set/all_spec.rb +0 -51
- data/spec/lib/immutable/set/any_spec.rb +0 -51
- data/spec/lib/immutable/set/clear_spec.rb +0 -33
- data/spec/lib/immutable/set/compact_spec.rb +0 -30
- data/spec/lib/immutable/set/construction_spec.rb +0 -18
- data/spec/lib/immutable/set/copying_spec.rb +0 -13
- data/spec/lib/immutable/set/count_spec.rb +0 -36
- data/spec/lib/immutable/set/delete_spec.rb +0 -71
- data/spec/lib/immutable/set/difference_spec.rb +0 -49
- data/spec/lib/immutable/set/disjoint_spec.rb +0 -25
- data/spec/lib/immutable/set/each_spec.rb +0 -45
- data/spec/lib/immutable/set/empty_spec.rb +0 -44
- data/spec/lib/immutable/set/eqeq_spec.rb +0 -103
- data/spec/lib/immutable/set/eql_spec.rb +0 -109
- data/spec/lib/immutable/set/exclusion_spec.rb +0 -47
- data/spec/lib/immutable/set/find_spec.rb +0 -35
- data/spec/lib/immutable/set/first_spec.rb +0 -28
- data/spec/lib/immutable/set/flatten_spec.rb +0 -46
- data/spec/lib/immutable/set/grep_spec.rb +0 -57
- data/spec/lib/immutable/set/grep_v_spec.rb +0 -59
- data/spec/lib/immutable/set/group_by_spec.rb +0 -59
- data/spec/lib/immutable/set/hash_spec.rb +0 -22
- data/spec/lib/immutable/set/include_spec.rb +0 -60
- data/spec/lib/immutable/set/inspect_spec.rb +0 -47
- data/spec/lib/immutable/set/intersect_spec.rb +0 -25
- data/spec/lib/immutable/set/intersection_spec.rb +0 -52
- data/spec/lib/immutable/set/join_spec.rb +0 -64
- data/spec/lib/immutable/set/map_spec.rb +0 -59
- data/spec/lib/immutable/set/marshal_spec.rb +0 -28
- data/spec/lib/immutable/set/maximum_spec.rb +0 -36
- data/spec/lib/immutable/set/minimum_spec.rb +0 -36
- data/spec/lib/immutable/set/new_spec.rb +0 -53
- data/spec/lib/immutable/set/none_spec.rb +0 -47
- data/spec/lib/immutable/set/one_spec.rb +0 -47
- data/spec/lib/immutable/set/partition_spec.rb +0 -52
- data/spec/lib/immutable/set/product_spec.rb +0 -23
- data/spec/lib/immutable/set/reduce_spec.rb +0 -55
- data/spec/lib/immutable/set/reject_spec.rb +0 -50
- data/spec/lib/immutable/set/reverse_each_spec.rb +0 -38
- data/spec/lib/immutable/set/sample_spec.rb +0 -13
- data/spec/lib/immutable/set/select_spec.rb +0 -73
- data/spec/lib/immutable/set/size_spec.rb +0 -17
- data/spec/lib/immutable/set/sorting_spec.rb +0 -65
- data/spec/lib/immutable/set/subset_spec.rb +0 -51
- data/spec/lib/immutable/set/sum_spec.rb +0 -23
- data/spec/lib/immutable/set/superset_spec.rb +0 -51
- data/spec/lib/immutable/set/to_a_spec.rb +0 -30
- data/spec/lib/immutable/set/to_list_spec.rb +0 -35
- data/spec/lib/immutable/set/to_set_spec.rb +0 -19
- data/spec/lib/immutable/set/union_spec.rb +0 -63
- data/spec/lib/immutable/sorted_set/above_spec.rb +0 -51
- data/spec/lib/immutable/sorted_set/add_spec.rb +0 -62
- data/spec/lib/immutable/sorted_set/at_spec.rb +0 -24
- data/spec/lib/immutable/sorted_set/below_spec.rb +0 -51
- data/spec/lib/immutable/sorted_set/between_spec.rb +0 -51
- data/spec/lib/immutable/sorted_set/clear_spec.rb +0 -43
- data/spec/lib/immutable/sorted_set/copying_spec.rb +0 -20
- data/spec/lib/immutable/sorted_set/delete_at_spec.rb +0 -18
- data/spec/lib/immutable/sorted_set/delete_spec.rb +0 -89
- data/spec/lib/immutable/sorted_set/difference_spec.rb +0 -22
- data/spec/lib/immutable/sorted_set/disjoint_spec.rb +0 -25
- data/spec/lib/immutable/sorted_set/drop_spec.rb +0 -55
- data/spec/lib/immutable/sorted_set/drop_while_spec.rb +0 -34
- data/spec/lib/immutable/sorted_set/each_spec.rb +0 -28
- data/spec/lib/immutable/sorted_set/empty_spec.rb +0 -34
- data/spec/lib/immutable/sorted_set/eql_spec.rb +0 -120
- data/spec/lib/immutable/sorted_set/exclusion_spec.rb +0 -22
- data/spec/lib/immutable/sorted_set/fetch_spec.rb +0 -64
- data/spec/lib/immutable/sorted_set/find_index_spec.rb +0 -40
- data/spec/lib/immutable/sorted_set/first_spec.rb +0 -18
- data/spec/lib/immutable/sorted_set/from_spec.rb +0 -51
- data/spec/lib/immutable/sorted_set/group_by_spec.rb +0 -57
- data/spec/lib/immutable/sorted_set/include_spec.rb +0 -23
- data/spec/lib/immutable/sorted_set/inspect_spec.rb +0 -37
- data/spec/lib/immutable/sorted_set/intersect_spec.rb +0 -25
- data/spec/lib/immutable/sorted_set/intersection_spec.rb +0 -28
- data/spec/lib/immutable/sorted_set/last_spec.rb +0 -36
- data/spec/lib/immutable/sorted_set/map_spec.rb +0 -51
- data/spec/lib/immutable/sorted_set/marshal_spec.rb +0 -36
- data/spec/lib/immutable/sorted_set/maximum_spec.rb +0 -36
- data/spec/lib/immutable/sorted_set/minimum_spec.rb +0 -19
- data/spec/lib/immutable/sorted_set/new_spec.rb +0 -137
- data/spec/lib/immutable/sorted_set/reverse_each_spec.rb +0 -28
- data/spec/lib/immutable/sorted_set/sample_spec.rb +0 -13
- data/spec/lib/immutable/sorted_set/select_spec.rb +0 -61
- data/spec/lib/immutable/sorted_set/size_spec.rb +0 -17
- data/spec/lib/immutable/sorted_set/slice_spec.rb +0 -256
- data/spec/lib/immutable/sorted_set/sorting_spec.rb +0 -56
- data/spec/lib/immutable/sorted_set/subset_spec.rb +0 -47
- data/spec/lib/immutable/sorted_set/superset_spec.rb +0 -47
- data/spec/lib/immutable/sorted_set/take_spec.rb +0 -54
- data/spec/lib/immutable/sorted_set/take_while_spec.rb +0 -33
- data/spec/lib/immutable/sorted_set/to_set_spec.rb +0 -17
- data/spec/lib/immutable/sorted_set/union_spec.rb +0 -58
- data/spec/lib/immutable/sorted_set/up_to_spec.rb +0 -52
- data/spec/lib/immutable/sorted_set/util_spec.rb +0 -48
- data/spec/lib/immutable/sorted_set/values_at_spec.rb +0 -33
- data/spec/lib/immutable/vector/add_spec.rb +0 -67
- data/spec/lib/immutable/vector/any_spec.rb +0 -69
- data/spec/lib/immutable/vector/assoc_spec.rb +0 -45
- data/spec/lib/immutable/vector/bsearch_spec.rb +0 -65
- data/spec/lib/immutable/vector/clear_spec.rb +0 -33
- data/spec/lib/immutable/vector/combination_spec.rb +0 -81
- data/spec/lib/immutable/vector/compact_spec.rb +0 -29
- data/spec/lib/immutable/vector/compare_spec.rb +0 -31
- data/spec/lib/immutable/vector/concat_spec.rb +0 -34
- data/spec/lib/immutable/vector/copying_spec.rb +0 -20
- data/spec/lib/immutable/vector/count_spec.rb +0 -17
- data/spec/lib/immutable/vector/delete_at_spec.rb +0 -53
- data/spec/lib/immutable/vector/delete_spec.rb +0 -30
- data/spec/lib/immutable/vector/dig_spec.rb +0 -30
- data/spec/lib/immutable/vector/drop_spec.rb +0 -41
- data/spec/lib/immutable/vector/drop_while_spec.rb +0 -54
- data/spec/lib/immutable/vector/each_index_spec.rb +0 -40
- data/spec/lib/immutable/vector/each_spec.rb +0 -44
- data/spec/lib/immutable/vector/each_with_index_spec.rb +0 -39
- data/spec/lib/immutable/vector/empty_spec.rb +0 -41
- data/spec/lib/immutable/vector/eql_spec.rb +0 -76
- data/spec/lib/immutable/vector/fetch_spec.rb +0 -64
- data/spec/lib/immutable/vector/fill_spec.rb +0 -88
- data/spec/lib/immutable/vector/first_spec.rb +0 -18
- data/spec/lib/immutable/vector/flat_map_spec.rb +0 -50
- data/spec/lib/immutable/vector/flatten_spec.rb +0 -58
- data/spec/lib/immutable/vector/get_spec.rb +0 -74
- data/spec/lib/immutable/vector/group_by_spec.rb +0 -57
- data/spec/lib/immutable/vector/include_spec.rb +0 -30
- data/spec/lib/immutable/vector/insert_spec.rb +0 -68
- data/spec/lib/immutable/vector/inspect_spec.rb +0 -49
- data/spec/lib/immutable/vector/join_spec.rb +0 -58
- data/spec/lib/immutable/vector/last_spec.rb +0 -45
- data/spec/lib/immutable/vector/length_spec.rb +0 -45
- data/spec/lib/immutable/vector/ltlt_spec.rb +0 -65
- data/spec/lib/immutable/vector/map_spec.rb +0 -51
- data/spec/lib/immutable/vector/marshal_spec.rb +0 -31
- data/spec/lib/immutable/vector/maximum_spec.rb +0 -33
- data/spec/lib/immutable/vector/minimum_spec.rb +0 -33
- data/spec/lib/immutable/vector/multiply_spec.rb +0 -47
- data/spec/lib/immutable/vector/new_spec.rb +0 -50
- data/spec/lib/immutable/vector/partition_spec.rb +0 -52
- data/spec/lib/immutable/vector/permutation_spec.rb +0 -91
- data/spec/lib/immutable/vector/pop_spec.rb +0 -26
- data/spec/lib/immutable/vector/product_spec.rb +0 -70
- data/spec/lib/immutable/vector/reduce_spec.rb +0 -55
- data/spec/lib/immutable/vector/reject_spec.rb +0 -43
- data/spec/lib/immutable/vector/repeated_combination_spec.rb +0 -77
- data/spec/lib/immutable/vector/repeated_permutation_spec.rb +0 -93
- data/spec/lib/immutable/vector/reverse_each_spec.rb +0 -31
- data/spec/lib/immutable/vector/reverse_spec.rb +0 -21
- data/spec/lib/immutable/vector/rindex_spec.rb +0 -36
- data/spec/lib/immutable/vector/rotate_spec.rb +0 -73
- data/spec/lib/immutable/vector/sample_spec.rb +0 -13
- data/spec/lib/immutable/vector/select_spec.rb +0 -63
- data/spec/lib/immutable/vector/set_spec.rb +0 -174
- data/spec/lib/immutable/vector/shift_spec.rb +0 -27
- data/spec/lib/immutable/vector/shuffle_spec.rb +0 -43
- data/spec/lib/immutable/vector/slice_spec.rb +0 -240
- data/spec/lib/immutable/vector/sorting_spec.rb +0 -56
- data/spec/lib/immutable/vector/sum_spec.rb +0 -17
- data/spec/lib/immutable/vector/take_spec.rb +0 -42
- data/spec/lib/immutable/vector/take_while_spec.rb +0 -34
- data/spec/lib/immutable/vector/to_a_spec.rb +0 -41
- data/spec/lib/immutable/vector/to_ary_spec.rb +0 -34
- data/spec/lib/immutable/vector/to_list_spec.rb +0 -30
- data/spec/lib/immutable/vector/to_set_spec.rb +0 -21
- data/spec/lib/immutable/vector/transpose_spec.rb +0 -48
- data/spec/lib/immutable/vector/uniq_spec.rb +0 -76
- data/spec/lib/immutable/vector/unshift_spec.rb +0 -28
- data/spec/lib/immutable/vector/update_in_spec.rb +0 -82
- data/spec/lib/immutable/vector/values_at_spec.rb +0 -33
- data/spec/lib/immutable/vector/zip_spec.rb +0 -57
- data/spec/lib/load_spec.rb +0 -42
- data/spec/spec_helper.rb +0 -96
data/lib/immutable/list.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'thread'
|
2
|
+
require 'set'
|
3
|
+
require 'concurrent'
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
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
|
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
|
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
|
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
|
-
|
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
|
279
|
-
alias
|
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
|
384
|
-
alias
|
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?
|
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,
|
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
|
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
|
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
|
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
|
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
|
-
|
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
|
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 =
|
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,
|
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
|
1293
|
+
alias length size
|
1294
1294
|
|
1295
1295
|
def cached_size?
|
1296
1296
|
@size != nil
|
@@ -1319,7 +1319,7 @@ module Immutable
|
|
1319
1319
|
realize if @atomic.value != 2
|
1320
1320
|
@head
|
1321
1321
|
end
|
1322
|
-
alias
|
1322
|
+
alias first head
|
1323
1323
|
|
1324
1324
|
def tail
|
1325
1325
|
realize if @atomic.value != 2
|
@@ -1334,7 +1334,7 @@ module Immutable
|
|
1334
1334
|
def size
|
1335
1335
|
@size ||= super
|
1336
1336
|
end
|
1337
|
-
alias
|
1337
|
+
alias length size
|
1338
1338
|
|
1339
1339
|
def cached_size?
|
1340
1340
|
@size != nil
|
@@ -1346,7 +1346,7 @@ module Immutable
|
|
1346
1346
|
MUTEX = Mutex.new
|
1347
1347
|
|
1348
1348
|
def realize
|
1349
|
-
|
1349
|
+
loop do
|
1350
1350
|
# try to "claim" the right to run the block which realizes target
|
1351
1351
|
if @atomic.compare_and_set(0,1) # full memory barrier here
|
1352
1352
|
begin
|
@@ -1392,7 +1392,7 @@ module Immutable
|
|
1392
1392
|
realize if @head == Undefined
|
1393
1393
|
@head
|
1394
1394
|
end
|
1395
|
-
alias
|
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
|
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
|
-
|
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
|
-
|
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
|
1571
|
+
alias first head
|
1572
1572
|
|
1573
1573
|
# There are no subsequent elements, so return an empty list.
|
1574
1574
|
# @return [self]
|
@@ -1585,7 +1585,7 @@ module Immutable
|
|
1585
1585
|
def size
|
1586
1586
|
0
|
1587
1587
|
end
|
1588
|
-
alias
|
1588
|
+
alias length size
|
1589
1589
|
|
1590
1590
|
def cached_size?
|
1591
1591
|
true
|
data/lib/immutable/nested.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
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'
|
9
9
|
|
10
10
|
module Immutable
|
11
11
|
class << self
|