hamster 0.4.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/hamster.rb +11 -9
- data/lib/hamster/core_ext.rb +2 -3
- data/lib/hamster/core_ext/enumerable.rb +18 -27
- data/lib/hamster/core_ext/io.rb +16 -25
- data/lib/hamster/deque.rb +252 -0
- data/lib/hamster/enumerable.rb +123 -112
- data/lib/hamster/experimental/mutable_queue.rb +5 -14
- data/lib/hamster/experimental/mutable_set.rb +7 -14
- data/lib/hamster/hash.rb +732 -102
- data/lib/hamster/immutable.rb +4 -10
- data/lib/hamster/list.rb +1155 -215
- data/lib/hamster/{experimental/mutable_hash.rb → mutable_hash.rb} +11 -14
- data/lib/hamster/nested.rb +36 -0
- data/lib/hamster/{experimental/read_copy_update.rb → read_copy_update.rb} +10 -8
- data/lib/hamster/set.rb +488 -90
- data/lib/hamster/sorted_set.rb +1397 -0
- data/lib/hamster/trie.rb +210 -65
- data/lib/hamster/undefined.rb +1 -7
- data/lib/hamster/vector.rb +1329 -83
- data/lib/hamster/version.rb +1 -3
- data/spec/{hamster/core_ext → fixtures}/io_spec.txt +0 -0
- data/spec/lib/hamster/core_ext/array_spec.rb +14 -0
- data/spec/lib/hamster/core_ext/enumerable_spec.rb +30 -0
- data/spec/lib/hamster/core_ext/io_spec.rb +29 -0
- data/spec/lib/hamster/deque/clear_spec.rb +34 -0
- data/spec/lib/hamster/deque/construction_spec.rb +30 -0
- data/spec/lib/hamster/deque/copying_spec.rb +20 -0
- data/spec/lib/hamster/deque/dequeue_spec.rb +35 -0
- data/spec/lib/hamster/deque/empty_spec.rb +40 -0
- data/spec/lib/hamster/deque/enqueue_spec.rb +28 -0
- data/spec/lib/hamster/deque/first_spec.rb +18 -0
- data/spec/lib/hamster/deque/inspect_spec.rb +24 -0
- data/spec/lib/hamster/deque/last_spec.rb +18 -0
- data/spec/lib/hamster/deque/marshal_spec.rb +34 -0
- data/spec/lib/hamster/deque/new_spec.rb +44 -0
- data/spec/lib/hamster/deque/pop_spec.rb +33 -0
- data/spec/lib/hamster/deque/pretty_print_spec.rb +24 -0
- data/spec/lib/hamster/deque/random_modification_spec.rb +34 -0
- data/spec/lib/hamster/deque/size_spec.rb +20 -0
- data/spec/lib/hamster/deque/to_a_spec.rb +27 -0
- data/spec/lib/hamster/deque/to_ary_spec.rb +36 -0
- data/spec/lib/hamster/deque/to_list_spec.rb +26 -0
- data/spec/lib/hamster/deque/unshift_spec.rb +26 -0
- data/spec/lib/hamster/experimental/mutable_set/add_qm_spec.rb +39 -0
- data/spec/lib/hamster/experimental/mutable_set/add_spec.rb +37 -0
- data/spec/lib/hamster/experimental/mutable_set/delete_qm_spec.rb +38 -0
- data/spec/lib/hamster/experimental/mutable_set/delete_spec.rb +37 -0
- data/spec/lib/hamster/hash/all_spec.rb +54 -0
- data/spec/lib/hamster/hash/any_spec.rb +54 -0
- data/spec/lib/hamster/hash/assoc_spec.rb +52 -0
- data/spec/lib/hamster/hash/clear_spec.rb +43 -0
- data/spec/lib/hamster/hash/construction_spec.rb +39 -0
- data/spec/lib/hamster/hash/copying_spec.rb +14 -0
- data/spec/lib/hamster/hash/default_proc_spec.rb +73 -0
- data/spec/lib/hamster/hash/delete_spec.rb +40 -0
- data/spec/lib/hamster/hash/each_spec.rb +78 -0
- data/spec/lib/hamster/hash/each_with_index_spec.rb +30 -0
- data/spec/lib/hamster/hash/empty_spec.rb +44 -0
- data/spec/lib/hamster/hash/eql_spec.rb +70 -0
- data/spec/lib/hamster/hash/except_spec.rb +43 -0
- data/spec/lib/hamster/hash/fetch_spec.rb +58 -0
- data/spec/lib/hamster/hash/find_spec.rb +44 -0
- data/spec/lib/hamster/hash/flat_map_spec.rb +36 -0
- data/spec/lib/hamster/hash/flatten_spec.rb +99 -0
- data/spec/lib/hamster/hash/get_spec.rb +80 -0
- data/spec/lib/hamster/hash/has_key_spec.rb +32 -0
- data/spec/lib/hamster/hash/has_value_spec.rb +28 -0
- data/spec/lib/hamster/hash/hash_spec.rb +30 -0
- data/spec/{hamster → lib/hamster}/hash/immutable_spec.rb +3 -6
- data/spec/lib/hamster/hash/inspect_spec.rb +31 -0
- data/spec/lib/hamster/hash/invert_spec.rb +31 -0
- data/spec/lib/hamster/hash/key_spec.rb +28 -0
- data/spec/lib/hamster/hash/keys_spec.rb +17 -0
- data/spec/lib/hamster/hash/map_spec.rb +46 -0
- data/spec/lib/hamster/hash/marshal_spec.rb +29 -0
- data/spec/lib/hamster/hash/merge_spec.rb +83 -0
- data/spec/lib/hamster/hash/min_max_spec.rb +46 -0
- data/spec/lib/hamster/hash/new_spec.rb +71 -0
- data/spec/lib/hamster/hash/none_spec.rb +49 -0
- data/spec/lib/hamster/hash/partition_spec.rb +36 -0
- data/spec/lib/hamster/hash/pretty_print_spec.rb +35 -0
- data/spec/lib/hamster/hash/put_spec.rb +103 -0
- data/spec/lib/hamster/hash/reduce_spec.rb +36 -0
- data/spec/lib/hamster/hash/reject_spec.rb +62 -0
- data/spec/lib/hamster/hash/reverse_each_spec.rb +28 -0
- data/spec/lib/hamster/hash/sample_spec.rb +14 -0
- data/spec/lib/hamster/hash/select_spec.rb +58 -0
- data/spec/{hamster → lib/hamster}/hash/size_spec.rb +9 -18
- data/spec/lib/hamster/hash/slice_spec.rb +45 -0
- data/spec/lib/hamster/hash/sort_spec.rb +27 -0
- data/spec/lib/hamster/hash/store_spec.rb +76 -0
- data/spec/lib/hamster/hash/take_spec.rb +36 -0
- data/spec/lib/hamster/hash/to_a_spec.rb +14 -0
- data/spec/lib/hamster/hash/to_hash_spec.rb +22 -0
- data/spec/lib/hamster/hash/update_in_spec.rb +80 -0
- data/spec/lib/hamster/hash/values_at_spec.rb +14 -0
- data/spec/lib/hamster/hash/values_spec.rb +25 -0
- data/spec/{hamster → lib/hamster}/immutable/copying_spec.rb +3 -10
- data/spec/{hamster → lib/hamster}/immutable/immutable_spec.rb +3 -16
- data/spec/lib/hamster/immutable/memoize_spec.rb +56 -0
- data/spec/lib/hamster/immutable/new_spec.rb +14 -0
- data/spec/lib/hamster/immutable/transform_spec.rb +26 -0
- data/spec/lib/hamster/immutable/transform_unless_spec.rb +44 -0
- data/spec/lib/hamster/list/add_spec.rb +26 -0
- data/spec/lib/hamster/list/all_spec.rb +58 -0
- data/spec/lib/hamster/list/any_spec.rb +50 -0
- data/spec/lib/hamster/list/append_spec.rb +39 -0
- data/spec/lib/hamster/list/at_spec.rb +30 -0
- data/spec/lib/hamster/list/break_spec.rb +70 -0
- data/spec/lib/hamster/list/cadr_spec.rb +39 -0
- data/spec/lib/hamster/list/chunk_spec.rb +29 -0
- data/spec/lib/hamster/list/clear_spec.rb +25 -0
- data/spec/lib/hamster/list/combination_spec.rb +34 -0
- data/spec/lib/hamster/list/compact_spec.rb +35 -0
- data/spec/lib/hamster/list/compare_spec.rb +31 -0
- data/spec/lib/hamster/list/cons_spec.rb +26 -0
- data/spec/lib/hamster/list/construction_spec.rb +111 -0
- data/spec/lib/hamster/list/copying_spec.rb +20 -0
- data/spec/lib/hamster/list/count_spec.rb +37 -0
- data/spec/lib/hamster/list/cycle_spec.rb +29 -0
- data/spec/lib/hamster/list/delete_at_spec.rb +19 -0
- data/spec/lib/hamster/list/delete_spec.rb +17 -0
- data/spec/lib/hamster/list/drop_spec.rb +31 -0
- data/spec/lib/hamster/list/drop_while_spec.rb +39 -0
- data/spec/lib/hamster/list/each_slice_spec.rb +52 -0
- data/spec/lib/hamster/list/each_spec.rb +41 -0
- data/spec/lib/hamster/list/each_with_index_spec.rb +29 -0
- data/spec/lib/hamster/list/empty_spec.rb +24 -0
- data/spec/lib/hamster/list/eql_spec.rb +62 -0
- data/spec/lib/hamster/list/fill_spec.rb +50 -0
- data/spec/lib/hamster/list/find_all_spec.rb +71 -0
- data/spec/{hamster → lib/hamster}/list/find_index_spec.rb +7 -29
- data/spec/{hamster → lib/hamster}/list/find_spec.rb +13 -35
- data/spec/lib/hamster/list/flat_map_spec.rb +52 -0
- data/spec/lib/hamster/list/flatten_spec.rb +31 -0
- data/spec/lib/hamster/list/grep_spec.rb +47 -0
- data/spec/lib/hamster/list/group_by_spec.rb +42 -0
- data/spec/lib/hamster/list/hash_spec.rb +22 -0
- data/spec/{hamster → lib/hamster}/list/head_spec.rb +6 -21
- data/spec/{hamster → lib/hamster}/list/include_spec.rb +8 -29
- data/spec/lib/hamster/list/index_spec.rb +34 -0
- data/spec/lib/hamster/list/indices_spec.rb +62 -0
- data/spec/lib/hamster/list/init_spec.rb +29 -0
- data/spec/lib/hamster/list/inits_spec.rb +29 -0
- data/spec/lib/hamster/list/insert_spec.rb +47 -0
- data/spec/lib/hamster/list/inspect_spec.rb +30 -0
- data/spec/lib/hamster/list/intersperse_spec.rb +29 -0
- data/spec/lib/hamster/list/join_spec.rb +64 -0
- data/spec/lib/hamster/list/last_spec.rb +24 -0
- data/spec/lib/hamster/list/ltlt_spec.rb +20 -0
- data/spec/lib/hamster/list/map_spec.rb +46 -0
- data/spec/lib/hamster/list/maximum_spec.rb +40 -0
- data/spec/{hamster → lib/hamster}/list/merge_by_spec.rb +9 -36
- data/spec/{hamster → lib/hamster}/list/merge_spec.rb +5 -24
- data/spec/lib/hamster/list/minimum_spec.rb +40 -0
- data/spec/lib/hamster/list/multithreading_spec.rb +48 -0
- data/spec/{hamster → lib/hamster}/list/none_spec.rb +14 -41
- data/spec/{hamster → lib/hamster}/list/one_spec.rb +15 -40
- data/spec/lib/hamster/list/partition_spec.rb +116 -0
- data/spec/lib/hamster/list/permutation_spec.rb +56 -0
- data/spec/lib/hamster/list/pop_spec.rb +26 -0
- data/spec/lib/hamster/list/product_spec.rb +24 -0
- data/spec/lib/hamster/list/reduce_spec.rb +54 -0
- data/spec/lib/hamster/list/reject_spec.rb +46 -0
- data/spec/lib/hamster/list/reverse_spec.rb +35 -0
- data/spec/lib/hamster/list/rotate_spec.rb +37 -0
- data/spec/lib/hamster/list/sample_spec.rb +14 -0
- data/spec/lib/hamster/list/select_spec.rb +71 -0
- data/spec/lib/hamster/list/size_spec.rb +26 -0
- data/spec/lib/hamster/list/slice_spec.rb +230 -0
- data/spec/lib/hamster/list/sorting_spec.rb +47 -0
- data/spec/lib/hamster/list/span_spec.rb +77 -0
- data/spec/lib/hamster/list/split_at_spec.rb +44 -0
- data/spec/lib/hamster/list/subsequences_spec.rb +24 -0
- data/spec/lib/hamster/list/sum_spec.rb +24 -0
- data/spec/lib/hamster/list/tail_spec.rb +31 -0
- data/spec/lib/hamster/list/tails_spec.rb +29 -0
- data/spec/lib/hamster/list/take_spec.rb +31 -0
- data/spec/lib/hamster/list/take_while_spec.rb +47 -0
- data/spec/lib/hamster/list/to_a_spec.rb +40 -0
- data/spec/lib/hamster/list/to_ary_spec.rb +42 -0
- data/spec/lib/hamster/list/to_list_spec.rb +20 -0
- data/spec/lib/hamster/list/to_set_spec.rb +19 -0
- data/spec/lib/hamster/list/transpose_spec.rb +20 -0
- data/spec/lib/hamster/list/union_spec.rb +32 -0
- data/spec/lib/hamster/list/uniq_spec.rb +30 -0
- data/spec/lib/hamster/list/zip_spec.rb +24 -0
- data/spec/lib/hamster/nested/construction_spec.rb +44 -0
- data/spec/lib/hamster/set/add_spec.rb +76 -0
- data/spec/lib/hamster/set/all_spec.rb +52 -0
- data/spec/lib/hamster/set/any_spec.rb +52 -0
- data/spec/lib/hamster/set/clear_spec.rb +34 -0
- data/spec/{hamster → lib/hamster}/set/compact_spec.rb +9 -20
- data/spec/lib/hamster/set/construction_spec.rb +19 -0
- data/spec/lib/hamster/set/copying_spec.rb +14 -0
- data/spec/lib/hamster/set/count_spec.rb +37 -0
- data/spec/lib/hamster/set/delete_spec.rb +72 -0
- data/spec/lib/hamster/set/difference_spec.rb +50 -0
- data/spec/lib/hamster/set/disjoint_spec.rb +26 -0
- data/spec/lib/hamster/set/each_spec.rb +46 -0
- data/spec/lib/hamster/set/empty_spec.rb +45 -0
- data/spec/lib/hamster/set/eqeq_spec.rb +104 -0
- data/spec/lib/hamster/set/eql_spec.rb +110 -0
- data/spec/lib/hamster/set/exclusion_spec.rb +48 -0
- data/spec/{hamster → lib/hamster}/set/find_spec.rb +10 -27
- data/spec/lib/hamster/set/first_spec.rb +29 -0
- data/spec/lib/hamster/set/flatten_spec.rb +47 -0
- data/spec/lib/hamster/set/grep_spec.rb +58 -0
- data/spec/lib/hamster/set/group_by_spec.rb +60 -0
- data/spec/lib/hamster/set/hash_spec.rb +23 -0
- data/spec/{hamster → lib/hamster}/set/immutable_spec.rb +4 -7
- data/spec/lib/hamster/set/include_spec.rb +61 -0
- data/spec/lib/hamster/set/inspect_spec.rb +48 -0
- data/spec/lib/hamster/set/intersect_spec.rb +26 -0
- data/spec/lib/hamster/set/intersection_spec.rb +53 -0
- data/spec/lib/hamster/set/join_spec.rb +65 -0
- data/spec/lib/hamster/set/map_spec.rb +60 -0
- data/spec/lib/hamster/set/marshal_spec.rb +29 -0
- data/spec/lib/hamster/set/maximum_spec.rb +37 -0
- data/spec/lib/hamster/set/minimum_spec.rb +37 -0
- data/spec/lib/hamster/set/new_spec.rb +54 -0
- data/spec/{hamster → lib/hamster}/set/none_spec.rb +17 -32
- data/spec/{hamster → lib/hamster}/set/one_spec.rb +16 -31
- data/spec/lib/hamster/set/partition_spec.rb +53 -0
- data/spec/lib/hamster/set/product_spec.rb +24 -0
- data/spec/lib/hamster/set/reduce_spec.rb +56 -0
- data/spec/lib/hamster/set/reject_spec.rb +51 -0
- data/spec/lib/hamster/set/reverse_each_spec.rb +39 -0
- data/spec/lib/hamster/set/sample_spec.rb +14 -0
- data/spec/lib/hamster/set/select_spec.rb +74 -0
- data/spec/{hamster → lib/hamster}/set/size_spec.rb +4 -13
- data/spec/lib/hamster/set/sorting_spec.rb +49 -0
- data/spec/lib/hamster/set/subset_spec.rb +52 -0
- data/spec/lib/hamster/set/sum_spec.rb +24 -0
- data/spec/lib/hamster/set/superset_spec.rb +52 -0
- data/spec/lib/hamster/set/to_a_spec.rb +31 -0
- data/spec/lib/hamster/set/to_list_spec.rb +37 -0
- data/spec/lib/hamster/set/to_set_spec.rb +20 -0
- data/spec/lib/hamster/set/union_spec.rb +64 -0
- data/spec/lib/hamster/sorted_set/above_spec.rb +52 -0
- data/spec/lib/hamster/sorted_set/add_spec.rb +63 -0
- data/spec/lib/hamster/sorted_set/at_spec.rb +25 -0
- data/spec/lib/hamster/sorted_set/below_spec.rb +52 -0
- data/spec/lib/hamster/sorted_set/between_spec.rb +52 -0
- data/spec/lib/hamster/sorted_set/clear_spec.rb +44 -0
- data/spec/lib/hamster/sorted_set/construction_spec.rb +29 -0
- data/spec/lib/hamster/sorted_set/delete_at_spec.rb +19 -0
- data/spec/lib/hamster/sorted_set/delete_spec.rb +90 -0
- data/spec/lib/hamster/sorted_set/difference_spec.rb +23 -0
- data/spec/lib/hamster/sorted_set/disjoint_spec.rb +26 -0
- data/spec/lib/hamster/sorted_set/drop_spec.rb +56 -0
- data/spec/lib/hamster/sorted_set/drop_while_spec.rb +35 -0
- data/spec/lib/hamster/sorted_set/each_spec.rb +29 -0
- data/spec/lib/hamster/sorted_set/empty_spec.rb +35 -0
- data/spec/lib/hamster/sorted_set/eql_spec.rb +121 -0
- data/spec/lib/hamster/sorted_set/exclusion_spec.rb +23 -0
- data/spec/lib/hamster/sorted_set/fetch_spec.rb +65 -0
- data/spec/lib/hamster/sorted_set/find_index_spec.rb +41 -0
- data/spec/lib/hamster/sorted_set/first_spec.rb +19 -0
- data/spec/lib/hamster/sorted_set/from_spec.rb +52 -0
- data/spec/lib/hamster/sorted_set/group_by_spec.rb +58 -0
- data/spec/lib/hamster/sorted_set/include_spec.rb +24 -0
- data/spec/lib/hamster/sorted_set/inspect_spec.rb +38 -0
- data/spec/lib/hamster/sorted_set/intersect_spec.rb +26 -0
- data/spec/lib/hamster/sorted_set/intersection_spec.rb +29 -0
- data/spec/lib/hamster/sorted_set/last_spec.rb +37 -0
- data/spec/lib/hamster/sorted_set/map_spec.rb +36 -0
- data/spec/lib/hamster/sorted_set/marshal_spec.rb +37 -0
- data/spec/lib/hamster/sorted_set/maximum_spec.rb +37 -0
- data/spec/lib/hamster/sorted_set/minimum_spec.rb +20 -0
- data/spec/lib/hamster/sorted_set/new_spec.rb +52 -0
- data/spec/lib/hamster/sorted_set/reverse_each_spec.rb +29 -0
- data/spec/lib/hamster/sorted_set/sample_spec.rb +14 -0
- data/spec/lib/hamster/sorted_set/select_spec.rb +62 -0
- data/spec/{hamster/vector → lib/hamster/sorted_set}/size_spec.rb +6 -15
- data/spec/lib/hamster/sorted_set/slice_spec.rb +257 -0
- data/spec/lib/hamster/sorted_set/sorting_spec.rb +45 -0
- data/spec/lib/hamster/sorted_set/subset_spec.rb +48 -0
- data/spec/lib/hamster/sorted_set/superset_spec.rb +48 -0
- data/spec/lib/hamster/sorted_set/take_spec.rb +55 -0
- data/spec/lib/hamster/sorted_set/take_while_spec.rb +34 -0
- data/spec/lib/hamster/sorted_set/to_set_spec.rb +19 -0
- data/spec/lib/hamster/sorted_set/union_spec.rb +28 -0
- data/spec/lib/hamster/sorted_set/up_to_spec.rb +52 -0
- data/spec/lib/hamster/sorted_set/values_at_spec.rb +34 -0
- data/spec/lib/hamster/vector/add_spec.rb +68 -0
- data/spec/lib/hamster/vector/any_spec.rb +70 -0
- data/spec/lib/hamster/vector/assoc_spec.rb +36 -0
- data/spec/lib/hamster/vector/bsearch_spec.rb +58 -0
- data/spec/lib/hamster/vector/clear_spec.rb +34 -0
- data/spec/lib/hamster/vector/combination_spec.rb +82 -0
- data/spec/lib/hamster/vector/compact_spec.rb +30 -0
- data/spec/lib/hamster/vector/compare_spec.rb +32 -0
- data/spec/lib/hamster/vector/concat_spec.rb +35 -0
- data/spec/lib/hamster/vector/copying_spec.rb +21 -0
- data/spec/lib/hamster/vector/count_spec.rb +18 -0
- data/spec/lib/hamster/vector/delete_at_spec.rb +54 -0
- data/spec/lib/hamster/vector/delete_spec.rb +31 -0
- data/spec/lib/hamster/vector/drop_spec.rb +42 -0
- data/spec/lib/hamster/vector/drop_while_spec.rb +55 -0
- data/spec/lib/hamster/vector/each_index_spec.rb +41 -0
- data/spec/lib/hamster/vector/each_spec.rb +45 -0
- data/spec/lib/hamster/vector/each_with_index_spec.rb +40 -0
- data/spec/lib/hamster/vector/empty_spec.rb +42 -0
- data/spec/lib/hamster/vector/eql_spec.rb +77 -0
- data/spec/lib/hamster/vector/fetch_spec.rb +65 -0
- data/spec/lib/hamster/vector/fill_spec.rb +89 -0
- data/spec/lib/hamster/vector/first_spec.rb +19 -0
- data/spec/lib/hamster/vector/flat_map_spec.rb +51 -0
- data/spec/lib/hamster/vector/flatten_spec.rb +44 -0
- data/spec/lib/hamster/vector/get_spec.rb +75 -0
- data/spec/lib/hamster/vector/group_by_spec.rb +58 -0
- data/spec/{hamster → lib/hamster}/vector/include_spec.rb +6 -20
- data/spec/lib/hamster/vector/insert_spec.rb +69 -0
- data/spec/lib/hamster/vector/inspect_spec.rb +50 -0
- data/spec/{hamster/set → lib/hamster/vector}/join_spec.rb +24 -34
- data/spec/lib/hamster/vector/last_spec.rb +46 -0
- data/spec/lib/hamster/vector/length_spec.rb +46 -0
- data/spec/lib/hamster/vector/ltlt_spec.rb +66 -0
- data/spec/lib/hamster/vector/map_spec.rb +52 -0
- data/spec/lib/hamster/vector/marshal_spec.rb +32 -0
- data/spec/lib/hamster/vector/maximum_spec.rb +34 -0
- data/spec/lib/hamster/vector/minimum_spec.rb +34 -0
- data/spec/lib/hamster/vector/multiply_spec.rb +48 -0
- data/spec/lib/hamster/vector/new_spec.rb +51 -0
- data/spec/lib/hamster/vector/partition_spec.rb +53 -0
- data/spec/lib/hamster/vector/permutation_spec.rb +92 -0
- data/spec/lib/hamster/vector/pop_spec.rb +27 -0
- data/spec/lib/hamster/vector/product_spec.rb +71 -0
- data/spec/{hamster → lib/hamster}/vector/reduce_spec.rb +18 -49
- data/spec/lib/hamster/vector/reject_spec.rb +44 -0
- data/spec/lib/hamster/vector/repeated_combination_spec.rb +78 -0
- data/spec/lib/hamster/vector/repeated_permutation_spec.rb +94 -0
- data/spec/lib/hamster/vector/reverse_each_spec.rb +32 -0
- data/spec/lib/hamster/vector/reverse_spec.rb +22 -0
- data/spec/lib/hamster/vector/rindex_spec.rb +37 -0
- data/spec/lib/hamster/vector/rotate_spec.rb +74 -0
- data/spec/lib/hamster/vector/sample_spec.rb +14 -0
- data/spec/lib/hamster/vector/select_spec.rb +64 -0
- data/spec/lib/hamster/vector/set_spec.rb +175 -0
- data/spec/lib/hamster/vector/shift_spec.rb +28 -0
- data/spec/lib/hamster/vector/shuffle_spec.rb +44 -0
- data/spec/lib/hamster/vector/slice_spec.rb +241 -0
- data/spec/lib/hamster/vector/sorting_spec.rb +57 -0
- data/spec/{hamster/set → lib/hamster/vector}/sum_spec.rb +5 -19
- data/spec/lib/hamster/vector/take_spec.rb +43 -0
- data/spec/lib/hamster/vector/take_while_spec.rb +35 -0
- data/spec/lib/hamster/vector/to_a_spec.rb +42 -0
- data/spec/lib/hamster/vector/to_ary_spec.rb +35 -0
- data/spec/lib/hamster/vector/to_list_spec.rb +32 -0
- data/spec/lib/hamster/vector/to_set_spec.rb +23 -0
- data/spec/lib/hamster/vector/transpose_spec.rb +49 -0
- data/spec/lib/hamster/vector/uniq_spec.rb +56 -0
- data/spec/lib/hamster/vector/unshift_spec.rb +29 -0
- data/spec/lib/hamster/vector/update_in_spec.rb +83 -0
- data/spec/lib/hamster/vector/values_at_spec.rb +34 -0
- data/spec/lib/hamster/vector/zip_spec.rb +58 -0
- data/spec/spec_helper.rb +45 -13
- metadata +807 -458
- data/History.rdoc +0 -419
- data/LICENSE +0 -20
- data/README.rdoc +0 -236
- data/Rakefile +0 -5
- data/lib/hamster/core_ext/enumerator.rb +0 -30
- data/lib/hamster/experimental/mutable_stack.rb +0 -35
- data/lib/hamster/queue.rb +0 -93
- data/lib/hamster/sorter.rb +0 -32
- data/lib/hamster/stack.rb +0 -82
- data/lib/hamster/tuple.rb +0 -45
- data/spec/hamster/core_ext/array_spec.rb +0 -20
- data/spec/hamster/core_ext/coverage/assets/0.4.4/app.js +0 -66
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/blank.gif +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_close.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_loading.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_nav_left.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_nav_right.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_shadow_e.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_shadow_n.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_shadow_ne.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_shadow_nw.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_shadow_s.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_shadow_se.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_shadow_sw.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_shadow_w.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_title_left.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_title_main.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_title_over.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_title_right.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancybox-x.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancybox-y.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancybox.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/jquery.fancybox-1.3.1.css +0 -363
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/jquery.fancybox-1.3.1.pack.js +0 -44
- data/spec/hamster/core_ext/coverage/assets/0.4.4/favicon.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/jquery-1.4.2.min.js +0 -155
- data/spec/hamster/core_ext/coverage/assets/0.4.4/jquery.dataTables.min.js +0 -152
- data/spec/hamster/core_ext/coverage/assets/0.4.4/jquery.timeago.js +0 -141
- data/spec/hamster/core_ext/coverage/assets/0.4.4/jquery.url.js +0 -174
- data/spec/hamster/core_ext/coverage/assets/0.4.4/loading.gif +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/magnify.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/jquery-ui-1.8.4.custom.css +0 -295
- data/spec/hamster/core_ext/coverage/assets/0.4.4/stylesheet.css +0 -341
- data/spec/hamster/core_ext/coverage/covered_percent +0 -1
- data/spec/hamster/core_ext/coverage/index.html +0 -71
- data/spec/hamster/core_ext/coverage/resultset.yml +0 -10
- data/spec/hamster/core_ext/enumerable_spec.rb +0 -34
- data/spec/hamster/core_ext/enumerator_spec.rb +0 -25
- data/spec/hamster/core_ext/io_spec.rb +0 -29
- data/spec/hamster/experimental/mutable_set/add?_spec.rb +0 -47
- data/spec/hamster/experimental/mutable_set/add_spec.rb +0 -51
- data/spec/hamster/experimental/mutable_set/delete?_spec.rb +0 -47
- data/spec/hamster/experimental/mutable_set/delete_spec.rb +0 -47
- data/spec/hamster/experimental/mutable_stack/pop_spec.rb +0 -41
- data/spec/hamster/experimental/mutable_stack/push_spec.rb +0 -41
- data/spec/hamster/hash/all_spec.rb +0 -59
- data/spec/hamster/hash/any_spec.rb +0 -68
- data/spec/hamster/hash/clear_spec.rb +0 -36
- data/spec/hamster/hash/construction_spec.rb +0 -35
- data/spec/hamster/hash/copying_spec.rb +0 -23
- data/spec/hamster/hash/delete_spec.rb +0 -47
- data/spec/hamster/hash/each_spec.rb +0 -41
- data/spec/hamster/hash/empty_spec.rb +0 -27
- data/spec/hamster/hash/eql_spec.rb +0 -62
- data/spec/hamster/hash/except_spec.rb +0 -31
- data/spec/hamster/hash/fetch_spec.rb +0 -95
- data/spec/hamster/hash/filter_spec.rb +0 -63
- data/spec/hamster/hash/find_spec.rb +0 -58
- data/spec/hamster/hash/get_spec.rb +0 -68
- data/spec/hamster/hash/has_key_spec.rb +0 -35
- data/spec/hamster/hash/hash_spec.rb +0 -54
- data/spec/hamster/hash/inspect_spec.rb +0 -32
- data/spec/hamster/hash/keys_spec.rb +0 -21
- data/spec/hamster/hash/map_spec.rb +0 -64
- data/spec/hamster/hash/merge_spec.rb +0 -36
- data/spec/hamster/hash/none_spec.rb +0 -64
- data/spec/hamster/hash/put_spec.rb +0 -65
- data/spec/hamster/hash/reduce_spec.rb +0 -60
- data/spec/hamster/hash/remove_spec.rb +0 -63
- data/spec/hamster/hash/slice_spec.rb +0 -31
- data/spec/hamster/hash/uniq_spec.rb +0 -23
- data/spec/hamster/hash/values_spec.rb +0 -34
- data/spec/hamster/immutable/memoize_spec.rb +0 -64
- data/spec/hamster/immutable/new_spec.rb +0 -28
- data/spec/hamster/immutable/transform_spec.rb +0 -31
- data/spec/hamster/immutable/transform_unless_spec.rb +0 -55
- data/spec/hamster/list/all_spec.rb +0 -111
- data/spec/hamster/list/any_spec.rb +0 -79
- data/spec/hamster/list/append_spec.rb +0 -50
- data/spec/hamster/list/at_spec.rb +0 -49
- data/spec/hamster/list/break_spec.rb +0 -85
- data/spec/hamster/list/cadr_spec.rb +0 -50
- data/spec/hamster/list/chunk_spec.rb +0 -40
- data/spec/hamster/list/clear_spec.rb +0 -36
- data/spec/hamster/list/combinations_spec.rb +0 -51
- data/spec/hamster/list/compact_spec.rb +0 -46
- data/spec/hamster/list/cons_spec.rb +0 -41
- data/spec/hamster/list/construction_spec.rb +0 -140
- data/spec/hamster/list/copying_spec.rb +0 -32
- data/spec/hamster/list/count_spec.rb +0 -66
- data/spec/hamster/list/coverage/assets/0.4.4/app.js +0 -66
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/blank.gif +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_close.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_loading.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_nav_left.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_nav_right.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_shadow_e.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_shadow_n.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_shadow_ne.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_shadow_nw.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_shadow_s.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_shadow_se.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_shadow_sw.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_shadow_w.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_title_left.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_title_main.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_title_over.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_title_right.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancybox-x.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancybox-y.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancybox.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/jquery.fancybox-1.3.1.css +0 -363
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/jquery.fancybox-1.3.1.pack.js +0 -44
- data/spec/hamster/list/coverage/assets/0.4.4/favicon.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/jquery-1.4.2.min.js +0 -155
- data/spec/hamster/list/coverage/assets/0.4.4/jquery.dataTables.min.js +0 -152
- data/spec/hamster/list/coverage/assets/0.4.4/jquery.timeago.js +0 -141
- data/spec/hamster/list/coverage/assets/0.4.4/jquery.url.js +0 -174
- data/spec/hamster/list/coverage/assets/0.4.4/loading.gif +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/magnify.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/jquery-ui-1.8.4.custom.css +0 -295
- data/spec/hamster/list/coverage/assets/0.4.4/stylesheet.css +0 -341
- data/spec/hamster/list/coverage/covered_percent +0 -1
- data/spec/hamster/list/coverage/index.html +0 -71
- data/spec/hamster/list/coverage/resultset.yml +0 -225
- data/spec/hamster/list/cycle_spec.rb +0 -45
- data/spec/hamster/list/drop_spec.rb +0 -42
- data/spec/hamster/list/drop_while_spec.rb +0 -59
- data/spec/hamster/list/each_slice_spec.rb +0 -80
- data/spec/hamster/list/each_spec.rb +0 -72
- data/spec/hamster/list/each_with_index_spec.rb +0 -42
- data/spec/hamster/list/elem_index_spec.rb +0 -58
- data/spec/hamster/list/elem_indices_spec.rb +0 -45
- data/spec/hamster/list/empty_spec.rb +0 -47
- data/spec/hamster/list/eql_spec.rb +0 -78
- data/spec/hamster/list/filter_spec.rb +0 -61
- data/spec/hamster/list/find_indices_spec.rb +0 -45
- data/spec/hamster/list/flatten_spec.rb +0 -42
- data/spec/hamster/list/grep_spec.rb +0 -70
- data/spec/hamster/list/group_by_spec.rb +0 -77
- data/spec/hamster/list/hash_spec.rb +0 -43
- data/spec/hamster/list/init_spec.rb +0 -40
- data/spec/hamster/list/inits_spec.rb +0 -42
- data/spec/hamster/list/inspect_spec.rb +0 -43
- data/spec/hamster/list/intersperse_spec.rb +0 -40
- data/spec/hamster/list/join_spec.rb +0 -81
- data/spec/hamster/list/last_spec.rb +0 -44
- data/spec/hamster/list/map_spec.rb +0 -69
- data/spec/hamster/list/maximum_spec.rb +0 -77
- data/spec/hamster/list/minimum_spec.rb +0 -77
- data/spec/hamster/list/partition_spec.rb +0 -75
- data/spec/hamster/list/product_spec.rb +0 -44
- data/spec/hamster/list/reduce_spec.rb +0 -99
- data/spec/hamster/list/remove_spec.rb +0 -67
- data/spec/hamster/list/reverse_spec.rb +0 -52
- data/spec/hamster/list/size_spec.rb +0 -47
- data/spec/hamster/list/slice_spec.rb +0 -50
- data/spec/hamster/list/sorting_spec.rb +0 -70
- data/spec/hamster/list/span_spec.rb +0 -86
- data/spec/hamster/list/split_at_spec.rb +0 -53
- data/spec/hamster/list/sum_spec.rb +0 -44
- data/spec/hamster/list/tail_spec.rb +0 -48
- data/spec/hamster/list/tails_spec.rb +0 -42
- data/spec/hamster/list/take_spec.rb +0 -42
- data/spec/hamster/list/take_while_spec.rb +0 -62
- data/spec/hamster/list/to_a_spec.rb +0 -54
- data/spec/hamster/list/to_ary_spec.rb +0 -56
- data/spec/hamster/list/to_list_spec.rb +0 -32
- data/spec/hamster/list/to_set_spec.rb +0 -33
- data/spec/hamster/list/union_spec.rb +0 -49
- data/spec/hamster/list/uniq_spec.rb +0 -45
- data/spec/hamster/list/zip_spec.rb +0 -39
- data/spec/hamster/queue/clear_spec.rb +0 -36
- data/spec/hamster/queue/construction_spec.rb +0 -43
- data/spec/hamster/queue/dequeue_spec.rb +0 -40
- data/spec/hamster/queue/empty_spec.rb +0 -47
- data/spec/hamster/queue/enqueue_spec.rb +0 -41
- data/spec/hamster/queue/head_spec.rb +0 -35
- data/spec/hamster/queue/inspect_spec.rb +0 -31
- data/spec/hamster/queue/size_spec.rb +0 -35
- data/spec/hamster/queue/to_a_spec.rb +0 -42
- data/spec/hamster/queue/to_ary_spec.rb +0 -44
- data/spec/hamster/queue/to_list_spec.rb +0 -44
- data/spec/hamster/set/add_spec.rb +0 -51
- data/spec/hamster/set/all_spec.rb +0 -67
- data/spec/hamster/set/any_spec.rb +0 -67
- data/spec/hamster/set/clear_spec.rb +0 -36
- data/spec/hamster/set/construction_spec.rb +0 -31
- data/spec/hamster/set/copying_spec.rb +0 -23
- data/spec/hamster/set/count_spec.rb +0 -54
- data/spec/hamster/set/coverage/assets/0.4.4/app.js +0 -66
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/blank.gif +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_close.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_loading.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_nav_left.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_nav_right.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_shadow_e.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_shadow_n.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_shadow_ne.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_shadow_nw.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_shadow_s.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_shadow_se.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_shadow_sw.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_shadow_w.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_title_left.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_title_main.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_title_over.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_title_right.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancybox-x.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancybox-y.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancybox.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/jquery.fancybox-1.3.1.css +0 -363
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/jquery.fancybox-1.3.1.pack.js +0 -44
- data/spec/hamster/set/coverage/assets/0.4.4/favicon.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/jquery-1.4.2.min.js +0 -155
- data/spec/hamster/set/coverage/assets/0.4.4/jquery.dataTables.min.js +0 -152
- data/spec/hamster/set/coverage/assets/0.4.4/jquery.timeago.js +0 -141
- data/spec/hamster/set/coverage/assets/0.4.4/jquery.url.js +0 -174
- data/spec/hamster/set/coverage/assets/0.4.4/loading.gif +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/magnify.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/jquery-ui-1.8.4.custom.css +0 -295
- data/spec/hamster/set/coverage/assets/0.4.4/stylesheet.css +0 -341
- data/spec/hamster/set/coverage/covered_percent +0 -1
- data/spec/hamster/set/coverage/index.html +0 -71
- data/spec/hamster/set/coverage/resultset.yml +0 -13
- data/spec/hamster/set/delete_spec.rb +0 -47
- data/spec/hamster/set/difference_spec.rb +0 -37
- data/spec/hamster/set/each_spec.rb +0 -42
- data/spec/hamster/set/empty_spec.rb +0 -35
- data/spec/hamster/set/eql_spec.rb +0 -62
- data/spec/hamster/set/exclusion_spec.rb +0 -38
- data/spec/hamster/set/filter_spec.rb +0 -79
- data/spec/hamster/set/flatten_spec.rb +0 -49
- data/spec/hamster/set/grep_spec.rb +0 -62
- data/spec/hamster/set/group_by_spec.rb +0 -65
- data/spec/hamster/set/hash_spec.rb +0 -31
- data/spec/hamster/set/head_spec.rb +0 -39
- data/spec/hamster/set/include_spec.rb +0 -35
- data/spec/hamster/set/inspect_spec.rb +0 -32
- data/spec/hamster/set/intersection_spec.rb +0 -46
- data/spec/hamster/set/map_spec.rb +0 -64
- data/spec/hamster/set/maximum_spec.rb +0 -65
- data/spec/hamster/set/minimum_spec.rb +0 -65
- data/spec/hamster/set/partition_spec.rb +0 -71
- data/spec/hamster/set/product_spec.rb +0 -32
- data/spec/hamster/set/reduce_spec.rb +0 -87
- data/spec/hamster/set/remove_spec.rb +0 -63
- data/spec/hamster/set/sorting_spec.rb +0 -58
- data/spec/hamster/set/subset_spec.rb +0 -39
- data/spec/hamster/set/superset_spec.rb +0 -39
- data/spec/hamster/set/to_a_spec.rb +0 -42
- data/spec/hamster/set/to_list_spec.rb +0 -47
- data/spec/hamster/set/to_set_spec.rb +0 -32
- data/spec/hamster/set/union_spec.rb +0 -45
- data/spec/hamster/set/uniq_spec.rb +0 -23
- data/spec/hamster/sorter/coverage/assets/0.4.4/app.js +0 -66
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/blank.gif +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_close.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_loading.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_nav_left.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_nav_right.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_shadow_e.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_shadow_n.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_shadow_ne.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_shadow_nw.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_shadow_s.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_shadow_se.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_shadow_sw.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_shadow_w.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_title_left.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_title_main.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_title_over.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_title_right.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancybox-x.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancybox-y.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancybox.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/jquery.fancybox-1.3.1.css +0 -363
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/jquery.fancybox-1.3.1.pack.js +0 -44
- data/spec/hamster/sorter/coverage/assets/0.4.4/favicon.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/jquery-1.4.2.min.js +0 -155
- data/spec/hamster/sorter/coverage/assets/0.4.4/jquery.dataTables.min.js +0 -152
- data/spec/hamster/sorter/coverage/assets/0.4.4/jquery.timeago.js +0 -141
- data/spec/hamster/sorter/coverage/assets/0.4.4/jquery.url.js +0 -174
- data/spec/hamster/sorter/coverage/assets/0.4.4/loading.gif +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/magnify.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/jquery-ui-1.8.4.custom.css +0 -295
- data/spec/hamster/sorter/coverage/assets/0.4.4/stylesheet.css +0 -341
- data/spec/hamster/sorter/coverage/covered_percent +0 -1
- data/spec/hamster/sorter/coverage/index.html +0 -71
- data/spec/hamster/sorter/coverage/resultset.yml +0 -22
- data/spec/hamster/sorter/immutable_spec.rb +0 -12
- data/spec/hamster/stack/clear_spec.rb +0 -36
- data/spec/hamster/stack/construction_spec.rb +0 -43
- data/spec/hamster/stack/copying_spec.rb +0 -31
- data/spec/hamster/stack/empty_spec.rb +0 -31
- data/spec/hamster/stack/eql_spec.rb +0 -60
- data/spec/hamster/stack/immutable_spec.rb +0 -12
- data/spec/hamster/stack/inspect_spec.rb +0 -31
- data/spec/hamster/stack/peek_spec.rb +0 -40
- data/spec/hamster/stack/pop_spec.rb +0 -41
- data/spec/hamster/stack/push_spec.rb +0 -41
- data/spec/hamster/stack/size_spec.rb +0 -35
- data/spec/hamster/stack/to_a_spec.rb +0 -42
- data/spec/hamster/stack/to_ary.rb +0 -44
- data/spec/hamster/stack/to_list_spec.rb +0 -33
- data/spec/hamster/trie/remove_spec.rb +0 -117
- data/spec/hamster/tuple/copying_spec.rb +0 -24
- data/spec/hamster/tuple/eql_spec.rb +0 -61
- data/spec/hamster/tuple/first_spec.rb +0 -19
- data/spec/hamster/tuple/immutable_spec.rb +0 -12
- data/spec/hamster/tuple/inspect_spec.rb +0 -19
- data/spec/hamster/tuple/last_spec.rb +0 -19
- data/spec/hamster/tuple/to_a_spec.rb +0 -38
- data/spec/hamster/tuple/to_ary_spec.rb +0 -44
- data/spec/hamster/undefined/erase_spec.rb +0 -47
- data/spec/hamster/vector/add_spec.rb +0 -41
- data/spec/hamster/vector/any_spec.rb +0 -67
- data/spec/hamster/vector/clear_spec.rb +0 -36
- data/spec/hamster/vector/copying_spec.rb +0 -32
- data/spec/hamster/vector/each_spec.rb +0 -46
- data/spec/hamster/vector/each_with_index_spec.rb +0 -42
- data/spec/hamster/vector/empty_spec.rb +0 -35
- data/spec/hamster/vector/eql_spec.rb +0 -65
- data/spec/hamster/vector/filter_spec.rb +0 -63
- data/spec/hamster/vector/first_spec.rb +0 -35
- data/spec/hamster/vector/get_spec.rb +0 -81
- data/spec/hamster/vector/inspect_spec.rb +0 -31
- data/spec/hamster/vector/last_spec.rb +0 -32
- data/spec/hamster/vector/map_spec.rb +0 -64
- data/spec/hamster/vector/set_spec.rb +0 -153
- data/spec/hamster/vector/to_a_spec.rb +0 -42
- data/spec/hamster/vector/to_ary_spec.rb +0 -44
- data/tasks/bundler.rb +0 -2
- data/tasks/publish.rb +0 -12
- data/tasks/spec.rb +0 -13
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a968ce4123ad40d563b7db0aa56b2b64b633c484
|
4
|
+
data.tar.gz: c2447b5cc66229a4f0020f406a2c576759bf8392
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dbf628e0bc57eecb1114bc1079ec4275042ffc8c960407a4431b4abafeb968c354e1ff66eb753dc0bc22f976484f073b61bbbaceb7fd988706bf487f52c77982
|
7
|
+
data.tar.gz: 711c88053c81c50a6ba25eb5c5e3fb8eed58f7faff38f0f6146e86a55240e6606c4dcfd73957acda560b780df8763c9fb3bc2cb66616483257dc3d0461fa7cb2
|
data/lib/hamster.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
1
|
+
require "hamster/core_ext"
|
2
|
+
require "hamster/immutable"
|
3
|
+
require "hamster/list"
|
4
|
+
require "hamster/deque"
|
5
|
+
require "hamster/hash"
|
6
|
+
require "hamster/set"
|
7
|
+
require "hamster/vector"
|
8
|
+
require "hamster/sorted_set"
|
9
|
+
require "hamster/mutable_hash"
|
10
|
+
require "hamster/nested"
|
11
|
+
require "hamster/version"
|
data/lib/hamster/core_ext.rb
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require 'hamster/core_ext/io'
|
1
|
+
require "hamster/core_ext/enumerable"
|
2
|
+
require "hamster/core_ext/io"
|
@@ -1,30 +1,21 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
module Hamster
|
4
|
-
|
5
|
-
module CoreExt
|
6
|
-
|
7
|
-
module Enumerable
|
8
|
-
|
9
|
-
def self.included(base)
|
10
|
-
base.class_eval do
|
11
|
-
def to_list
|
12
|
-
list = EmptyList
|
13
|
-
reverse_each { |item| list = list.cons(item) }
|
14
|
-
list
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
1
|
+
require "hamster/list"
|
19
2
|
|
3
|
+
# Ruby's built-in `Enumerable` module.
|
4
|
+
# @see http://www.ruby-doc.org/core/Enumerable.html
|
5
|
+
module Enumerable
|
6
|
+
# Return a new {Hamster::List} populated with the items in this `Enumerable` object.
|
7
|
+
# @return [List]
|
8
|
+
def to_list
|
9
|
+
# use destructive operations to build up a new list, like Common Lisp's NCONC
|
10
|
+
# this is a very fast way to build up a linked list
|
11
|
+
list = tail = Hamster::Cons.allocate
|
12
|
+
each do |item|
|
13
|
+
new_node = Hamster::Cons.allocate
|
14
|
+
new_node.instance_variable_set(:@head, item)
|
15
|
+
tail.instance_variable_set(:@tail, new_node)
|
16
|
+
tail = new_node
|
20
17
|
end
|
21
|
-
|
18
|
+
tail.instance_variable_set(:@tail, Hamster::EmptyList)
|
19
|
+
list.tail
|
22
20
|
end
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
module Enumerable
|
27
|
-
|
28
|
-
include Hamster::CoreExt::Enumerable
|
29
|
-
|
30
|
-
end
|
21
|
+
end
|
data/lib/hamster/core_ext/io.rb
CHANGED
@@ -1,30 +1,21 @@
|
|
1
|
-
require
|
1
|
+
require "hamster/list"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
3
|
+
# Ruby's built-in `IO` class.
|
4
|
+
# @see http://www.ruby-doc.org/core/IO.html
|
5
|
+
class IO
|
6
|
+
# Return a lazy list of "records" read from this IO stream.
|
7
|
+
# "Records" are delimited by `$/`, the global input record separator string.
|
8
|
+
# By default, it is `"\n"`, a newline.
|
9
|
+
#
|
10
|
+
# @return [List]
|
11
|
+
def to_list(sep = $/) # global input record separator
|
12
|
+
Hamster::LazyList.new do
|
13
|
+
line = gets(sep)
|
14
|
+
if line
|
15
|
+
Hamster::Cons.new(line, to_list)
|
16
|
+
else
|
17
|
+
EmptyList
|
18
18
|
end
|
19
|
-
|
20
19
|
end
|
21
|
-
|
22
20
|
end
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
class IO
|
27
|
-
|
28
|
-
include Hamster::CoreExt::IO
|
29
|
-
|
30
21
|
end
|
@@ -0,0 +1,252 @@
|
|
1
|
+
require "hamster/immutable"
|
2
|
+
require "hamster/list"
|
3
|
+
|
4
|
+
module Hamster
|
5
|
+
# Create a new `Deque` populated with the given items.
|
6
|
+
# @return [Deque]
|
7
|
+
def self.deque(*items)
|
8
|
+
items.empty? ? EmptyDeque : Deque.new(items)
|
9
|
+
end
|
10
|
+
|
11
|
+
# A `Deque` (or double-ended queue) is an ordered, sequential collection of objects,
|
12
|
+
# which allows elements to be efficiently added and removed at the front and end of
|
13
|
+
# the sequence. Retrieving the elements at the front and end is also efficient. This
|
14
|
+
# makes `Deque` perfect for use as an immutable queue *or* stack.
|
15
|
+
#
|
16
|
+
# A `Deque` differs from a {Vector} in that vectors allow indexed access to any
|
17
|
+
# element in the collection. `Deque`s only allow access to the first and last
|
18
|
+
# element. But adding and removing from the ends of a `Deque` is faster than
|
19
|
+
# adding and removing from the ends of a {Vector}.
|
20
|
+
#
|
21
|
+
# To create a new `Deque`:
|
22
|
+
#
|
23
|
+
# Hamster.deque('a', 'b', 'c')
|
24
|
+
# Hamster::Deque.new([:first, :second, :third])
|
25
|
+
# Hamster::Deque[1, 2, 3, 4, 5]
|
26
|
+
#
|
27
|
+
# Or you can start with an empty deque and build it up:
|
28
|
+
#
|
29
|
+
# Hamster::Deque.empty.push('b').push('c').unshift('a')
|
30
|
+
#
|
31
|
+
# Like all Hamster collections, `Deque` is immutable. The 4 basic operations which
|
32
|
+
# "modify" deques ({#push}, {#pop}, {#shift}, and {#unshift}) all return a new
|
33
|
+
# collection and leave the existing one unchanged.
|
34
|
+
#
|
35
|
+
# @example
|
36
|
+
# deque = Hamster::Deque.empty # => Hamster::Deque[]
|
37
|
+
# deque = deque.push('a').push('b').push('c') # => Hamster::Deque['a', 'b', 'c']
|
38
|
+
# deque.first # => 'a'
|
39
|
+
# deque.last # => 'c'
|
40
|
+
# deque = deque.shift # => Hamster::Deque['b', 'c']
|
41
|
+
#
|
42
|
+
# @see http://en.wikipedia.org/wiki/Deque "Deque" on Wikipedia
|
43
|
+
#
|
44
|
+
class Deque
|
45
|
+
include Immutable
|
46
|
+
|
47
|
+
class << self
|
48
|
+
# Create a new `Deque` populated with the given items.
|
49
|
+
# @return [Deque]
|
50
|
+
def [](*items)
|
51
|
+
items.empty? ? empty : new(items)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Return an empty `Deque`. If used on a subclass, returns an empty instance
|
55
|
+
# of that class.
|
56
|
+
#
|
57
|
+
# @return [Deque]
|
58
|
+
def empty
|
59
|
+
@empty ||= self.new
|
60
|
+
end
|
61
|
+
|
62
|
+
# "Raw" allocation of a new `Deque`. Used internally to create a new
|
63
|
+
# instance quickly after consing onto the front/rear lists or taking their
|
64
|
+
# tails.
|
65
|
+
#
|
66
|
+
# @return [Deque]
|
67
|
+
# @private
|
68
|
+
def alloc(front, rear)
|
69
|
+
result = allocate
|
70
|
+
result.instance_variable_set(:@front, front)
|
71
|
+
result.instance_variable_set(:@rear, rear)
|
72
|
+
result
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def initialize(items=[])
|
77
|
+
@front = items.to_list
|
78
|
+
@rear = EmptyList
|
79
|
+
end
|
80
|
+
|
81
|
+
# Return `true` if this `Deque` contains no items.
|
82
|
+
# @return [Boolean]
|
83
|
+
def empty?
|
84
|
+
@front.empty? && @rear.empty?
|
85
|
+
end
|
86
|
+
|
87
|
+
# Return the number of items in this `Deque`.
|
88
|
+
#
|
89
|
+
# @example
|
90
|
+
# Hamster::Deque["A", "B", "C"].size #=> 3
|
91
|
+
#
|
92
|
+
# @return [Integer]
|
93
|
+
def size
|
94
|
+
@front.size + @rear.size
|
95
|
+
end
|
96
|
+
alias :length :size
|
97
|
+
|
98
|
+
# Return the first item in the `Deque`. If the deque is empty, return `nil`.
|
99
|
+
#
|
100
|
+
# @example
|
101
|
+
# Hamster::Deque["A", "B", "C"].first #=> "A"
|
102
|
+
#
|
103
|
+
# @return [Object]
|
104
|
+
def first
|
105
|
+
return @front.head unless @front.empty?
|
106
|
+
@rear.last # memoize?
|
107
|
+
end
|
108
|
+
|
109
|
+
# Return the last item in the `Deque`. If the deque is empty, return `nil`.
|
110
|
+
#
|
111
|
+
# @example
|
112
|
+
# Hamster::Deque["A", "B", "C"].last #=> "C"
|
113
|
+
#
|
114
|
+
# @return [Object]
|
115
|
+
def last
|
116
|
+
return @rear.head unless @rear.empty?
|
117
|
+
@front.last # memoize?
|
118
|
+
end
|
119
|
+
|
120
|
+
# Return a new `Deque` with `item` added at the end.
|
121
|
+
#
|
122
|
+
# @example
|
123
|
+
# Hamster::Deque["A", "B", "C"].add("Z")
|
124
|
+
# # => Hamster::Deque["A", "B", "C", "Z"]
|
125
|
+
#
|
126
|
+
# @param item [Object] The item to add
|
127
|
+
# @return [Deque]
|
128
|
+
def push(item)
|
129
|
+
self.class.alloc(@front, @rear.cons(item))
|
130
|
+
end
|
131
|
+
alias :enqueue :push
|
132
|
+
|
133
|
+
# Return a new `Deque` with the last item removed.
|
134
|
+
#
|
135
|
+
# @example
|
136
|
+
# Hamster::Deque["A", "B", "C"].pop
|
137
|
+
# # => Hamster::Deque["A", "B"]
|
138
|
+
#
|
139
|
+
# @return [Deque]
|
140
|
+
def pop
|
141
|
+
front, rear = @front, @rear
|
142
|
+
|
143
|
+
if rear.empty?
|
144
|
+
return self.class.empty if front.empty?
|
145
|
+
front, rear = EmptyList, front.reverse
|
146
|
+
end
|
147
|
+
|
148
|
+
self.class.alloc(front, rear.tail)
|
149
|
+
end
|
150
|
+
|
151
|
+
# Return a new `Deque` with `item` added at the front.
|
152
|
+
#
|
153
|
+
# @example
|
154
|
+
# Hamster::Deque["A", "B", "C"].unshift("Z")
|
155
|
+
# # => Hamster::Deque["Z", "A", "B", "C"]
|
156
|
+
#
|
157
|
+
# @param item [Object] The item to add
|
158
|
+
# @return [Deque]
|
159
|
+
def unshift(item)
|
160
|
+
self.class.alloc(@front.cons(item), @rear)
|
161
|
+
end
|
162
|
+
|
163
|
+
# Return a new `Deque` with the first item removed.
|
164
|
+
#
|
165
|
+
# @example
|
166
|
+
# Hamster::Deque["A", "B", "C"].shift
|
167
|
+
# # => Hamster::Deque["B", "C"]
|
168
|
+
#
|
169
|
+
# @return [Deque]
|
170
|
+
def shift
|
171
|
+
front, rear = @front, @rear
|
172
|
+
|
173
|
+
if front.empty?
|
174
|
+
return self.class.empty if rear.empty?
|
175
|
+
front, rear = rear.reverse, EmptyList
|
176
|
+
end
|
177
|
+
|
178
|
+
self.class.alloc(front.tail, rear)
|
179
|
+
end
|
180
|
+
alias :dequeue :shift
|
181
|
+
|
182
|
+
# Return an empty `Deque` instance, of the same class as this one. Useful if you
|
183
|
+
# have multiple subclasses of `Deque` and want to treat them polymorphically.
|
184
|
+
#
|
185
|
+
# @return [Deque]
|
186
|
+
def clear
|
187
|
+
self.class.empty
|
188
|
+
end
|
189
|
+
|
190
|
+
# Return true if `other` has the same type and contents as this `Deque`.
|
191
|
+
#
|
192
|
+
# @param other [Object] The collection to compare with
|
193
|
+
# @return [Boolean]
|
194
|
+
def eql?(other)
|
195
|
+
return true if other.equal?(self)
|
196
|
+
instance_of?(other.class) && to_ary.eql?(other.to_ary)
|
197
|
+
end
|
198
|
+
alias :== :eql?
|
199
|
+
|
200
|
+
# Return an `Array` with the same elements, in the same order.
|
201
|
+
# @return [Array]
|
202
|
+
def to_a
|
203
|
+
@front.to_a.concat(@rear.to_a.tap { |a| a.reverse! })
|
204
|
+
end
|
205
|
+
alias :entries :to_a
|
206
|
+
alias :to_ary :to_a
|
207
|
+
|
208
|
+
# Return a {List} with the same elements, in the same order.
|
209
|
+
# @return [Hamster::List]
|
210
|
+
def to_list
|
211
|
+
@front.append(@rear.reverse)
|
212
|
+
end
|
213
|
+
|
214
|
+
# Return the contents of this `Deque` as a programmer-readable `String`. If all the
|
215
|
+
# items in the deque are serializable as Ruby literal strings, the returned string can
|
216
|
+
# be passed to `eval` to reconstitute an equivalent `Deque`.
|
217
|
+
#
|
218
|
+
# @return [String]
|
219
|
+
def inspect
|
220
|
+
result = "#{self.class}["
|
221
|
+
i = 0
|
222
|
+
@front.each { |obj| result << ', ' if i > 0; result << obj.inspect; i += 1 }
|
223
|
+
@rear.to_a.tap { |a| a.reverse! }.each { |obj| result << ', ' if i > 0; result << obj.inspect; i += 1 }
|
224
|
+
result << "]"
|
225
|
+
end
|
226
|
+
|
227
|
+
# @private
|
228
|
+
def pretty_print(pp)
|
229
|
+
pp.group(1, "#{self.class}[", "]") do
|
230
|
+
pp.breakable ''
|
231
|
+
pp.seplist(self.to_a) { |obj| obj.pretty_print(pp) }
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
# @return [::Array]
|
236
|
+
# @private
|
237
|
+
def marshal_dump
|
238
|
+
to_a
|
239
|
+
end
|
240
|
+
|
241
|
+
# @private
|
242
|
+
def marshal_load(array)
|
243
|
+
initialize(array)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
# The canonical empty `Deque`. Returned by `Hamster.deque` and `Deque[]` when
|
248
|
+
# invoked with no arguments; also returned by `Deque.empty`. Prefer using this
|
249
|
+
# one rather than creating many empty deques using `Deque.new`.
|
250
|
+
#
|
251
|
+
EmptyDeque = Hamster::Deque.empty
|
252
|
+
end
|
data/lib/hamster/enumerable.rb
CHANGED
@@ -1,141 +1,152 @@
|
|
1
|
-
require 'forwardable'
|
2
|
-
|
3
|
-
require 'hamster/undefined'
|
4
|
-
require 'hamster/tuple'
|
5
|
-
|
6
1
|
module Hamster
|
7
|
-
|
2
|
+
# Helper module for Hamster's sequential collections
|
3
|
+
#
|
4
|
+
# Classes including `Hamster::Enumerable` must implement:
|
5
|
+
#
|
6
|
+
# - `#each` (just like `::Enumerable`).
|
7
|
+
# - `#select`, which takes a block, and returns an instance of the same class
|
8
|
+
# with only the items for which the block returns a true value
|
9
|
+
#
|
8
10
|
module Enumerable
|
11
|
+
include ::Enumerable
|
9
12
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
def_delegator :self, :each, :foreach
|
16
|
-
|
17
|
-
def filter
|
18
|
-
raise NoMethodError, "undefined method `filter' for #{self.class.name}"
|
13
|
+
# Return a new collection with all the elements for which the block returns false.
|
14
|
+
def reject
|
15
|
+
return enum_for(:reject) if not block_given?
|
16
|
+
select { |item| !yield(item) }
|
19
17
|
end
|
20
|
-
|
21
|
-
def_delegator :self, :filter, :find_all
|
18
|
+
alias :delete_if :reject
|
22
19
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
yield(item, index)
|
27
|
-
index + 1
|
28
|
-
end
|
29
|
-
nil
|
30
|
-
end
|
31
|
-
|
32
|
-
def reduce(memo = Undefined)
|
33
|
-
each do |item|
|
34
|
-
memo = memo.equal?(Undefined) ? item : yield(memo, item)
|
35
|
-
end if block_given?
|
36
|
-
Undefined.erase(memo)
|
37
|
-
end
|
38
|
-
def_delegator :self, :reduce, :inject
|
39
|
-
def_delegator :self, :reduce, :fold
|
40
|
-
def_delegator :self, :reduce, :foldr
|
41
|
-
|
42
|
-
def partition(&block)
|
43
|
-
return self unless block_given?
|
44
|
-
Tuple.new(filter(&block), remove(&block))
|
45
|
-
end
|
46
|
-
|
47
|
-
def find
|
48
|
-
return nil unless block_given?
|
49
|
-
each { |item| return item if yield(item) }
|
20
|
+
# Return a new collection with all `nil` elements removed.
|
21
|
+
def compact
|
22
|
+
select { |item| !item.nil? }
|
50
23
|
end
|
51
|
-
def_delegator :self, :find, :detect
|
52
24
|
|
53
|
-
|
54
|
-
|
25
|
+
# Search the collection for elements which are `#===` to `item`. Yield them to
|
26
|
+
# the optional code block if provided, and return them as a new collection.
|
27
|
+
def grep(pattern, &block)
|
28
|
+
result = select { |item| pattern === item }
|
29
|
+
result = result.map(&block) if block_given?
|
30
|
+
result
|
55
31
|
end
|
56
|
-
def_delegator :self, :include?, :member?
|
57
|
-
def_delegator :self, :include?, :contains?
|
58
|
-
def_delegator :self, :include?, :elem?
|
59
32
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
33
|
+
# Yield all integers from 0 up to, but not including, the number of items in
|
34
|
+
# this collection. For collections which provide indexed access, these are all
|
35
|
+
# the valid, non-negative indices into the collection.
|
36
|
+
def each_index(&block)
|
37
|
+
return enum_for(:each_index) unless block_given?
|
38
|
+
0.upto(size-1, &block)
|
39
|
+
self
|
64
40
|
end
|
65
|
-
def_delegator :self, :any?, :exist?
|
66
|
-
def_delegator :self, :any?, :exists?
|
67
41
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
true
|
42
|
+
# Multiply all the items (presumably numeric) in this collection together.
|
43
|
+
def product
|
44
|
+
reduce(1, &:*)
|
72
45
|
end
|
73
|
-
def_delegator :self, :all?, :forall?
|
74
46
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
true
|
47
|
+
# Add up all the items (presumably numeric) in this collection.
|
48
|
+
def sum
|
49
|
+
reduce(0, &:+)
|
79
50
|
end
|
80
51
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
52
|
+
# Return 2 collections, the first containing all the elements for which the block
|
53
|
+
# evaluates to true, the second containing the rest.
|
54
|
+
def partition
|
55
|
+
return enum_for(:partition) if not block_given?
|
56
|
+
a,b = super
|
57
|
+
[self.class.new(a), self.class.new(b)].freeze
|
58
|
+
end
|
59
|
+
|
60
|
+
# Groups the collection into sub-collections by the result of yielding them to
|
61
|
+
# the block. Returns a {Hash} where the keys are return values from the block,
|
62
|
+
# and the values are sub-collections. All the sub-collections are built up from
|
63
|
+
# `empty_group`, which should respond to `#add` by returning a new collection
|
64
|
+
# with an added element.
|
65
|
+
def group_by_with(empty_group, &block)
|
66
|
+
block ||= lambda { |item| item }
|
67
|
+
reduce(EmptyHash) do |hash, item|
|
68
|
+
key = block.call(item)
|
69
|
+
group = hash.get(key) || empty_group
|
70
|
+
hash.put(key, group.add(item))
|
90
71
|
end
|
91
72
|
end
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
73
|
+
protected :group_by_with
|
74
|
+
|
75
|
+
# Groups the collection into sub-collections by the result of yielding them to
|
76
|
+
# the block. Returns a {Hash} where the keys are return values from the block,
|
77
|
+
# and the values are sub-collections (of the same type as this one).
|
78
|
+
def group_by(&block)
|
79
|
+
group_by_with(self.class.empty, &block)
|
80
|
+
end
|
81
|
+
|
82
|
+
# Compare with `other`, and return 0, 1, or -1 if it is (respectively) equal to,
|
83
|
+
# greater than, or less than this collection.
|
84
|
+
def <=>(other)
|
85
|
+
return 0 if self.equal?(other)
|
86
|
+
enum1, enum2 = self.to_enum, other.to_enum
|
87
|
+
loop do
|
88
|
+
item1 = enum1.next
|
89
|
+
item2 = enum2.next
|
90
|
+
comp = (item1 <=> item2)
|
91
|
+
return comp if comp != 0
|
92
|
+
end
|
93
|
+
size1, size2 = self.size, other.size
|
94
|
+
return 0 if size1 == size2
|
95
|
+
size1 > size2 ? 1 : -1
|
96
|
+
end
|
97
|
+
|
98
|
+
# Return true if `other` contains the same elements, in the same order.
|
99
|
+
# @return [Boolean]
|
100
|
+
def ==(other)
|
101
|
+
self.eql?(other) || other.respond_to?(:to_ary) && to_ary.eql?(other.to_ary)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Convert all the elements into strings and join them together, separated by
|
105
|
+
# `separator`. By default, the `separator` is `$,`, the global default string
|
106
|
+
# separator, which is normally `nil`.
|
107
|
+
def join(separator = $,)
|
108
|
+
result = ""
|
109
|
+
if separator
|
110
|
+
each_with_index { |obj, i| result << separator if i > 0; result << obj.to_s }
|
111
|
+
else
|
112
|
+
each { |obj| result << obj.to_s }
|
113
|
+
end
|
114
|
+
result
|
107
115
|
end
|
108
116
|
|
109
|
-
|
110
|
-
|
111
|
-
|
117
|
+
# Convert this collection to a {Set}.
|
118
|
+
def to_set
|
119
|
+
Set.new(self)
|
112
120
|
end
|
113
121
|
|
114
|
-
|
115
|
-
|
122
|
+
# Convert this collection to a programmer-readable `String` representation.
|
123
|
+
def inspect
|
124
|
+
result = "#{self.class}["
|
125
|
+
each_with_index { |obj, i| result << ', ' if i > 0; result << obj.inspect }
|
126
|
+
result << "]"
|
116
127
|
end
|
117
128
|
|
118
|
-
|
119
|
-
|
129
|
+
# @private
|
130
|
+
def pretty_print(pp)
|
131
|
+
pp.group(1, "#{self.class}[", "]") do
|
132
|
+
pp.breakable ''
|
133
|
+
pp.seplist(self) { |obj| obj.pretty_print(pp) }
|
134
|
+
end
|
120
135
|
end
|
121
136
|
|
122
|
-
|
123
|
-
|
124
|
-
filter { |item| !yield(item) }
|
125
|
-
end
|
126
|
-
def_delegator :self, :remove, :reject
|
127
|
-
def_delegator :self, :remove, :delete_if
|
137
|
+
alias :to_ary :to_a
|
138
|
+
alias :index :find_index
|
128
139
|
|
129
|
-
|
130
|
-
remove(&:nil?)
|
131
|
-
end
|
140
|
+
## Compatibility fixes
|
132
141
|
|
133
|
-
|
134
|
-
|
142
|
+
if RUBY_ENGINE == 'rbx'
|
143
|
+
# Rubinius implements Enumerable#sort_by using Enumerable#map
|
144
|
+
# Because we do our own, custom implementations of #map, that doesn't work well
|
145
|
+
# @private
|
146
|
+
def sort_by(&block)
|
147
|
+
result = to_a
|
148
|
+
result.frozen? ? result.sort_by(&block) : result.sort_by!(&block)
|
149
|
+
end
|
135
150
|
end
|
136
|
-
def_delegator :self, :to_a, :entries
|
137
|
-
def_delegator :self, :to_a, :to_ary
|
138
|
-
|
139
151
|
end
|
140
|
-
|
141
|
-
end
|
152
|
+
end
|