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.
- checksums.yaml +5 -5
- 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 +50 -15
- data/lib/immutable/enumerable.rb +19 -10
- data/lib/immutable/hash.rb +128 -28
- data/lib/immutable/list.rb +48 -48
- data/lib/immutable/nested.rb +10 -7
- data/lib/immutable/set.rb +30 -30
- data/lib/immutable/sorted_set.rb +77 -37
- data/lib/immutable/trie.rb +21 -29
- data/lib/immutable/vector.rb +61 -46
- data/lib/immutable/version.rb +1 -1
- data/lib/immutable.rb +9 -9
- metadata +44 -687
- 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/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/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 -69
- 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/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 -102
- 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/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/update_in_spec.rb +0 -79
- data/spec/lib/immutable/hash/values_at_spec.rb +0 -13
- 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 -33
- 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 -95
- data/spec/lib/immutable/set/add_spec.rb +0 -75
- 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/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 -59
- 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 -43
- 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 -71
- 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 -44
- 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 -27
- data/spec/lib/immutable/sorted_set/up_to_spec.rb +0 -52
- 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/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 -92
data/lib/immutable/vector.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
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
|
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 ||=
|
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
|
136
|
-
alias
|
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,
|
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
|
228
|
+
alias at get
|
230
229
|
|
231
230
|
# Retrieve the value at `index` with optional default.
|
232
231
|
#
|
@@ -279,6 +278,24 @@ module Immutable
|
|
279
278
|
end
|
280
279
|
end
|
281
280
|
|
281
|
+
# Return the value of successively indexing into a nested collection.
|
282
|
+
# If any of the keys is not present, return `nil`.
|
283
|
+
#
|
284
|
+
# @example
|
285
|
+
# v = Immutable::Vector[9, Immutable::Hash[c: 'a', d: 4]]
|
286
|
+
# v.dig(1, :c) # => "a"
|
287
|
+
# v.dig(1, :f) # => nil
|
288
|
+
#
|
289
|
+
# @return [Object]
|
290
|
+
def dig(key, *rest)
|
291
|
+
value = self[key]
|
292
|
+
if rest.empty? || value.nil?
|
293
|
+
value
|
294
|
+
else
|
295
|
+
value.dig(*rest)
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
282
299
|
# Return specific objects from the `Vector`. All overloads return `nil` if
|
283
300
|
# the starting index is out of range.
|
284
301
|
#
|
@@ -337,7 +354,7 @@ module Immutable
|
|
337
354
|
subsequence(arg, length)
|
338
355
|
end
|
339
356
|
end
|
340
|
-
alias
|
357
|
+
alias [] slice
|
341
358
|
|
342
359
|
# Return a new `Vector` with the given values inserted before the element
|
343
360
|
# at `index`. If `index` is greater than the current length, `nil` values
|
@@ -384,7 +401,7 @@ module Immutable
|
|
384
401
|
index += @size if index < 0
|
385
402
|
|
386
403
|
suffix = flatten_suffix(@root, @levels * BITS_PER_LEVEL, index, [])
|
387
|
-
replace_suffix(index, suffix.tap
|
404
|
+
replace_suffix(index, suffix.tap(&:shift))
|
388
405
|
end
|
389
406
|
|
390
407
|
# Return a new `Vector` with the last element removed. Return `self` if
|
@@ -472,8 +489,8 @@ module Immutable
|
|
472
489
|
return enum_for(:select) unless block_given?
|
473
490
|
reduce(self.class.empty) { |vector, item| yield(item) ? vector.add(item) : vector }
|
474
491
|
end
|
475
|
-
alias
|
476
|
-
alias
|
492
|
+
alias find_all select
|
493
|
+
alias keep_if select
|
477
494
|
|
478
495
|
# Return a new `Vector` with all items which are equal to `obj` removed.
|
479
496
|
# `#==` is used for checking equality.
|
@@ -500,7 +517,7 @@ module Immutable
|
|
500
517
|
return self if empty?
|
501
518
|
self.class.new(super)
|
502
519
|
end
|
503
|
-
alias
|
520
|
+
alias collect map
|
504
521
|
|
505
522
|
# Return a new `Vector` with the concatenated results of running the block once
|
506
523
|
# for every element in this `Vector`.
|
@@ -535,18 +552,10 @@ module Immutable
|
|
535
552
|
#
|
536
553
|
# @return [Vector]
|
537
554
|
def uniq(&block)
|
538
|
-
array =
|
539
|
-
if
|
540
|
-
|
541
|
-
|
542
|
-
elsif array.uniq!(&block) # returns nil if no changes were made
|
543
|
-
self.class.new(array.freeze)
|
544
|
-
else
|
545
|
-
self
|
546
|
-
end
|
547
|
-
elsif array.frozen?
|
548
|
-
self.class.new(array.uniq.freeze)
|
549
|
-
elsif array.uniq! # returns nil if no changes were made
|
555
|
+
array = to_a
|
556
|
+
if array.frozen?
|
557
|
+
self.class.new(array.uniq(&block).freeze)
|
558
|
+
elsif array.uniq!(&block) # returns nil if no changes were made
|
550
559
|
self.class.new(array.freeze)
|
551
560
|
else
|
552
561
|
self
|
@@ -599,7 +608,7 @@ module Immutable
|
|
599
608
|
# @return [Vector]
|
600
609
|
def flatten(level = -1)
|
601
610
|
return self if level == 0
|
602
|
-
array =
|
611
|
+
array = to_a
|
603
612
|
if array.frozen?
|
604
613
|
self.class.new(array.flatten(level).freeze)
|
605
614
|
elsif array.flatten!(level) # returns nil if no changes were made
|
@@ -623,7 +632,7 @@ module Immutable
|
|
623
632
|
other = other.dup if other.frozen?
|
624
633
|
replace_suffix(@size, other)
|
625
634
|
end
|
626
|
-
alias
|
635
|
+
alias concat +
|
627
636
|
|
628
637
|
# Combine two vectors by "zipping" them together. `others` should be arrays
|
629
638
|
# and/or vectors. The corresponding elements from this `Vector` and each of
|
@@ -711,7 +720,7 @@ module Immutable
|
|
711
720
|
def drop(n)
|
712
721
|
return self if n == 0
|
713
722
|
return self.class.empty if n >= @size
|
714
|
-
raise ArgumentError,
|
723
|
+
raise ArgumentError, 'attempt to drop negative size' if n < 0
|
715
724
|
self.class.new(flatten_suffix(@root, @levels * BITS_PER_LEVEL, n, []))
|
716
725
|
end
|
717
726
|
|
@@ -852,7 +861,7 @@ module Immutable
|
|
852
861
|
elsif n == 1
|
853
862
|
each { |item| yield [item] }
|
854
863
|
elsif n == @size
|
855
|
-
yield
|
864
|
+
yield to_a
|
856
865
|
else
|
857
866
|
combos = lambda do |result,index,remaining|
|
858
867
|
while @size - index > remaining
|
@@ -959,15 +968,14 @@ module Immutable
|
|
959
968
|
used, result = [], []
|
960
969
|
perms = lambda do |index|
|
961
970
|
0.upto(@size-1) do |i|
|
962
|
-
if
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
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
|
971
979
|
end
|
972
980
|
end
|
973
981
|
end
|
@@ -1075,13 +1083,13 @@ module Immutable
|
|
1075
1083
|
end
|
1076
1084
|
|
1077
1085
|
if block_given?
|
1078
|
-
|
1086
|
+
loop do
|
1079
1087
|
yield build_array[]
|
1080
1088
|
return self if bump_counters[]
|
1081
1089
|
end
|
1082
1090
|
else
|
1083
1091
|
result = []
|
1084
|
-
|
1092
|
+
loop do
|
1085
1093
|
result << build_array[]
|
1086
1094
|
return result if bump_counters[]
|
1087
1095
|
end
|
@@ -1104,7 +1112,7 @@ module Immutable
|
|
1104
1112
|
#
|
1105
1113
|
# @return [Vector]
|
1106
1114
|
# @raise [IndexError] if elements are not of the same size.
|
1107
|
-
# @raise [TypeError] if an element
|
1115
|
+
# @raise [TypeError] if an element does not respond to #size and #[]
|
1108
1116
|
def transpose
|
1109
1117
|
return self.class.empty if empty?
|
1110
1118
|
result = Array.new(first.size) { [] }
|
@@ -1122,6 +1130,13 @@ module Immutable
|
|
1122
1130
|
|
1123
1131
|
result.map! { |a| self.class.new(a) }
|
1124
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
|
1125
1140
|
end
|
1126
1141
|
|
1127
1142
|
# Finds a value from this `Vector` which meets the condition defined by the
|
@@ -1291,7 +1306,7 @@ module Immutable
|
|
1291
1306
|
flatten_node(@root, @levels * BITS_PER_LEVEL, [])
|
1292
1307
|
end
|
1293
1308
|
end
|
1294
|
-
alias
|
1309
|
+
alias to_ary to_a
|
1295
1310
|
|
1296
1311
|
# Return true if `other` has the same type and contents as this `Vector`.
|
1297
1312
|
#
|
@@ -1315,7 +1330,7 @@ module Immutable
|
|
1315
1330
|
def dup
|
1316
1331
|
self
|
1317
1332
|
end
|
1318
|
-
alias
|
1333
|
+
alias clone dup
|
1319
1334
|
|
1320
1335
|
# @return [::Array]
|
1321
1336
|
# @private
|
@@ -1444,7 +1459,7 @@ module Immutable
|
|
1444
1459
|
from_slot.upto(node.size-1) do |i|
|
1445
1460
|
flatten_node(node[i], bitshift - BITS_PER_LEVEL, result)
|
1446
1461
|
end
|
1447
|
-
elsif child = node[from_slot]
|
1462
|
+
elsif (child = node[from_slot])
|
1448
1463
|
flatten_suffix(child, bitshift - BITS_PER_LEVEL, from, result)
|
1449
1464
|
(from_slot+1).upto(node.size-1) do |i|
|
1450
1465
|
flatten_node(node[i], bitshift - BITS_PER_LEVEL, result)
|
@@ -1514,7 +1529,7 @@ module Immutable
|
|
1514
1529
|
end
|
1515
1530
|
result.concat(remainder)
|
1516
1531
|
end
|
1517
|
-
elsif child = node[from_slot]
|
1532
|
+
elsif (child = node[from_slot])
|
1518
1533
|
result = node.take(from_slot)
|
1519
1534
|
result.push(replace_node_suffix(child, bitshift - BITS_PER_LEVEL, from, suffix))
|
1520
1535
|
remainder = suffix.shift((31 - from_slot) * (1 << bitshift))
|
data/lib/immutable/version.rb
CHANGED
data/lib/immutable.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
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'
|