Class: Farce::Strict::Vector

Inherits:
Abstract::Vector show all
Includes:
Farce::Shareable::Delegated
Defined in:
lib/farce/strict/vector.rb

Overview

A Ractor-shareable vector that stores and returns shareable values directly.

Instance Method Summary collapse

Methods included from Farce::Shareable

#ractor_shareable?

Methods inherited from Abstract::Vector

#&, #*, #+, #-, #<<, #<=>, #[], #[]=, #append, #as_extended_json, #as_json, #assoc, #at, #bsearch, #bsearch_index, #bson_type, #chunk, #chunk_while, #clear, #combination, #compact, #compact!, #compact_blank, #compare_and_set, #compare_by_identity?, #concat, #deconstruct, #deep_dup, #delete, #delete_at, #delete_if, #difference, #dig, #drop, #drop_while, #each, #each_cons, #each_index, #each_slice, #entries, #excluding, #fetch, #fetch_values, #fifth, #fill, #filter_map, #first, #flat_map, #flatten, #flatten!, #forty_two, #fourth, #from, #get, #grep, #grep_v, #group_by, #in_groups, #in_groups_of, #in_order_of, #include?, #including, #index, #inquiry, #insert, #intersect?, #intersection, #keep_if, #last, #map, #map!, #max, #max_by, #maximum, #min, #min_by, #minimum, #minmax, #minmax_by, #pack, #partition, #permutation, #pick, #pluck, #pop, #product, #push, #rassoc, #reject, #reject!, #repeated_combination, #repeated_permutation, #replace, #reverse, #reverse!, #reverse_each, #rfind, #rindex, #rotate, #rotate!, #sample, #second, #second_to_last, #select, #select!, #shift, #shuffle, #shuffle!, #size, #slice, #slice!, #slice_after, #slice_before, #slice_when, #sort, #sort!, #sort_by, #sort_by!, #split, #store, #store_if_absent, #swap, #take, #take_while, #third, #third_to_last, #to, #to_a, #to_ary, #to_bson, #to_bson_normalized_value, #to_cbor, #to_fs, #to_h, #to_json, #to_msgpack, #to_param, #to_query, #to_sentence, #to_xml, #transpose, #union, #uniq, #uniq!, #unshift, #update, #upsert, #values_at, #wait_until, #wait_until_changed, #wait_until_match, #wait_until_non_nil, #wait_until_value, #wait_while, #wait_while_match, #wait_while_value, #zip, #|

Methods inherited from Abstract::Collection

#<<, [], #clear, #compare_by_identity?, #count, #each, #empty?, #filter, #include?, #join, #length, #member?, #reject, #select, #size, #to_a, #to_s

Methods included from Internal::Copyable

#duplicable?

Constructor Details

#initialize(source = nil, compare_by_identity: false) ⇒ Vector

Returns a new instance of Vector.

Parameters:

  • source (Array, Integer, nil) (defaults to: nil) —

    Initial values or a size filled with nil. The source array is not retained.

  • compare_by_identity (Boolean) (defaults to: false) —

    Whether values are compared by identity.

Raises:

  • (ArgumentError) —

    If the size is negative.



14
15
16
17
# File 'lib/farce/strict/vector.rb', line 14

def initialize(source = nil, compare_by_identity: false)
  @vector = Internal::Vector.new(normalize_vector_source(source), compare_by_identity:)
  super()
end

Instance Method Details

#shareable_values? ⇒ Boolean

Returns Whether stored values must be Ractor-shareable.

Returns:

  • (Boolean) —

    Whether stored values must be Ractor-shareable.



20
# File 'lib/farce/strict/vector.rb', line 20

def shareable_values? = true