Class: Farce::Unshared::Vector

Inherits:
Abstract::Vector show all
Includes:
Farce::Unshareable
Defined in:
lib/farce/unshared/vector.rb

Overview

A thread-safe vector for mutable values used within one Ractor.

Instance Method Summary collapse

Methods included from Farce::Unshareable

#ractor_shareable?

Methods inherited from Abstract::Vector

#&, #*, #+, #-, #<<, #[], #[]=, #append, #as_extended_json, #as_json, #assoc, #at, #bsearch, #bsearch_index, #bson_type, #chunk, #chunk_while, #clear, #compact, #compact_blank, #compare_and_set, #compare_by_identity?, #concat, #deconstruct, #deep_dup, #difference, #dig, #drop, #drop_while, #each, #each_cons, #each_index, #each_slice, #entries, #excluding, #fetch, #fetch_values, #fifth, #filter_map, #first, #flat_map, #forty_two, #fourth, #from, #get, #grep, #grep_v, #group_by, #in_groups, #in_groups_of, #in_order_of, #include?, #including, #index, #inquiry, #intersect?, #intersection, #last, #map, #max, #max_by, #maximum, #min, #min_by, #minimum, #minmax, #minmax_by, #pack, #partition, #pick, #pluck, #pop, #push, #rassoc, #reject, #reverse, #reverse_each, #rfind, #rindex, #rotate, #sample, #second, #second_to_last, #select, #shareable_values?, #shuffle, #size, #slice, #slice_after, #slice_before, #slice_when, #sort, #sort_by, #split, #store, #store_if_absent, #swap, #take, #take_while, #third, #third_to_last, #to, #to_a, #to_bson, #to_bson_normalized_value, #to_cbor, #to_fs, #to_h, #to_json, #to_msgpack, #to_param, #to_query, #to_sentence, #to_xml, #union, #uniq, #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, nil) (defaults to: nil) —

    Initial values. Values are retained directly.

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

    Whether values are compared by identity.



13
14
15
16
# File 'lib/farce/unshared/vector.rb', line 13

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