From a22b40afb40ecb02659a42c192055a6f78afffc8 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 22 Feb 2009 14:23:33 +0000 Subject: stripped trailing spaces. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@22552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- array.c | 380 ++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 190 insertions(+), 190 deletions(-) (limited to 'array.c') diff --git a/array.c b/array.c index 8ec325c0c..796740eba 100644 --- a/array.c +++ b/array.c @@ -95,7 +95,7 @@ memfill(register VALUE *mem, register long size, register VALUE val) ARY_SET_HEAP_LEN(ary, n); \ } \ assert(RARRAY_LEN(ary) == n); \ -} while (0) +} while (0) #define ARY_INCREASE_PTR(ary, n) do { \ assert(!ARY_EMBED_P(ary)); \ assert(!OBJ_FROZEN(ary)); \ @@ -144,31 +144,31 @@ static void ary_resize_capa(VALUE ary, long capacity) { assert(RARRAY_LEN(ary) <= capacity); - assert(!OBJ_FROZEN(ary)); - assert(!ARY_SHARED_P(ary)); + assert(!OBJ_FROZEN(ary)); + assert(!ARY_SHARED_P(ary)); if (capacity > RARRAY_EMBED_LEN_MAX) { if (ARY_EMBED_P(ary)) { - long len = ARY_EMBED_LEN(ary); + long len = ARY_EMBED_LEN(ary); VALUE *ptr = ALLOC_N(VALUE, (capacity)); - MEMCPY(ptr, ARY_EMBED_PTR(ary), VALUE, len); - FL_UNSET_EMBED(ary); - ARY_SET_PTR(ary, ptr); - ARY_SET_HEAP_LEN(ary, len); + MEMCPY(ptr, ARY_EMBED_PTR(ary), VALUE, len); + FL_UNSET_EMBED(ary); + ARY_SET_PTR(ary, ptr); + ARY_SET_HEAP_LEN(ary, len); } - else { + else { REALLOC_N(RARRAY(ary)->as.heap.ptr, VALUE, (capacity)); } - ARY_SET_CAPA(ary, (capacity)); + ARY_SET_CAPA(ary, (capacity)); } else { if (!ARY_EMBED_P(ary)) { - long len = RARRAY_LEN(ary); + long len = RARRAY_LEN(ary); VALUE *ptr = RARRAY_PTR(ary); if (len > capacity) len = capacity; - MEMCPY(RARRAY(ary)->as.ary, ptr, VALUE, len); - FL_SET_EMBED(ary); - ARY_SET_LEN(ary, len); - xfree(ptr); + MEMCPY(RARRAY(ary)->as.ary, ptr, VALUE, len); + FL_SET_EMBED(ary); + ARY_SET_LEN(ary, len); + xfree(ptr); } } } @@ -458,11 +458,11 @@ rb_check_array_type(VALUE ary) * Try to convert obj into an array, using to_ary method. * Returns converted array or nil if obj cannot be converted * for any reason. This method is to check if an argument is an - * array. + * array. * * Array.try_convert([1]) # => [1] * Array.try_convert("1") # => nil - * + * * if tmp = Array.try_convert(arg) * # the argument is an array * elsif tmp = String.try_convert(arg) @@ -496,22 +496,22 @@ rb_ary_s_try_convert(VALUE dummy, VALUE ary) * Array.new * Array.new(2) * Array.new(5, "A") - * + * * # only one copy of the object is created * a = Array.new(2, Hash.new) * a[0]['cat'] = 'feline' * a * a[1]['cat'] = 'Felix' * a - * + * * # here multiple copies are created * a = Array.new(2) { Hash.new } * a[0]['cat'] = 'feline' * a - * + * * squares = Array.new(5) {|i| i*i} * squares - * + * * copy = Array.new(squares) */ @@ -571,8 +571,8 @@ rb_ary_initialize(int argc, VALUE *argv, VALUE ary) } -/* -* Returns a new array populated with the given objects. +/* +* Returns a new array populated with the given objects. * * Array.[]( 1, 'a', /^A/ ) * Array[ 1, 'a', /^A/ ] @@ -678,7 +678,7 @@ ary_take_first_or_last(int argc, VALUE *argv, VALUE ary, enum ary_take_pos_flags /* * call-seq: * array << obj -> array - * + * * Append---Pushes the given object on to the end of this array. This * expression returns the array itself, so several appends * may be chained together. @@ -695,16 +695,16 @@ rb_ary_push(VALUE ary, VALUE item) return ary; } -/* +/* * call-seq: * array.push(obj, ... ) -> array - * + * * Append---Pushes the given object(s) on to the end of this array. This * expression returns the array itself, so several appends * may be chained together. * * a = [ "a", "b", "c" ] - * a.push("d", "e", "f") + * a.push("d", "e", "f") * #=> ["a", "b", "c", "d", "e", "f"] */ @@ -739,13 +739,13 @@ rb_ary_pop(VALUE ary) * call-seq: * array.pop -> obj or nil * array.pop(n) -> array - * + * * Removes the last element from self and returns it, or * nil if the array is empty. * * If a number _n_ is given, returns an array of the last n elements * (or less) just like array.slice!(-n, n) does. - * + * * a = [ "a", "b", "c", "d" ] * a.pop #=> "d" * a.pop(2) #=> ["b", "c"] @@ -796,14 +796,14 @@ rb_ary_shift(VALUE ary) * call-seq: * array.shift -> obj or nil * array.shift(n) -> array - * + * * Returns the first element of self and removes it (shifting all * other elements down by one). Returns nil if the array * is empty. * * If a number _n_ is given, returns an array of the first n elements * (or less) just like array.slice!(0, n) does. - * + * * args = [ "-m", "-q", "filename" ] * args.shift #=> "-m" * args #=> ["-q", "filename"] @@ -840,10 +840,10 @@ rb_ary_shift_m(int argc, VALUE *argv, VALUE ary) /* * call-seq: * array.unshift(obj, ...) -> array - * + * * Prepends objects to the front of array. * other elements up one. - * + * * a = [ "b", "c", "d" ] * a.unshift("a") #=> ["a", "b", "c", "d"] * a.unshift(1, 2) #=> [ 1, 2, "a", "b", "c", "d"] @@ -864,7 +864,7 @@ rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary) MEMMOVE(RARRAY_PTR(ary) + argc, RARRAY_PTR(ary), VALUE, len); MEMCPY(RARRAY_PTR(ary), argv, VALUE, argc); ARY_INCREASE_LEN(ary, argc); - + return ary; } @@ -911,7 +911,7 @@ rb_ary_subseq(VALUE ary, long beg, long len) return ary_make_partial(ary, klass, beg, len); } -/* +/* * call-seq: * array[index] -> obj or nil * array[start, length] -> an_array or nil @@ -977,7 +977,7 @@ rb_ary_aref(int argc, VALUE *argv, VALUE ary) return rb_ary_entry(ary, NUM2LONG(arg)); } -/* +/* * call-seq: * array.at(index) -> obj or nil * @@ -1000,11 +1000,11 @@ rb_ary_at(VALUE ary, VALUE pos) * call-seq: * array.first -> obj or nil * array.first(n) -> an_array - * + * * Returns the first element, or the first +n+ elements, of the array. * If the array is empty, the first form returns nil, and the * second form returns an empty array. - * + * * a = [ "q", "r", "s", "t" ] * a.first #=> "q" * a.first(2) #=> ["q", "r"] @@ -1026,10 +1026,10 @@ rb_ary_first(int argc, VALUE *argv, VALUE ary) * call-seq: * array.last -> obj or nil * array.last(n) -> an_array - * + * * Returns the last element(s) of self. If the array is empty, * the first form returns nil. - * + * * a = [ "w", "x", "y", "z" ] * a.last #=> "z" * a.last(2) #=> ["y", "z"] @@ -1052,14 +1052,14 @@ rb_ary_last(int argc, VALUE *argv, VALUE ary) * array.fetch(index) -> obj * array.fetch(index, default ) -> obj * array.fetch(index) {|index| block } -> obj - * + * * Tries to return the element at position index. If the index * lies outside the array, the first form throws an * IndexError exception, the second form returns * default, and the third form returns the value of invoking * the block, passing in the index. Negative values of index * count from the end of the array. - * + * * a = [ 11, 22, 33, 44 ] * a.fetch(1) #=> 22 * a.fetch(-1) #=> 44 @@ -1098,12 +1098,12 @@ rb_ary_fetch(int argc, VALUE *argv, VALUE ary) * call-seq: * array.index(obj) -> int or nil * array.index {|item| block} -> int or nil - * + * * Returns the index of the first object in self such that is * == to obj. If a block is given instead of an * argument, returns first object for which block is true. * Returns nil if no match is found. - * + * * a = [ "a", "b", "c" ] * a.index("b") #=> 1 * a.index("z") #=> nil @@ -1138,12 +1138,12 @@ rb_ary_index(int argc, VALUE *argv, VALUE ary) /* * call-seq: * array.rindex(obj) -> int or nil - * + * * Returns the index of the last object in array * == to obj. If a block is given instead of an * argument, returns first object for which block is * true. Returns nil if no match is found. - * + * * a = [ "a", "b", "b", "b", "c" ] * a.rindex("b") #=> 3 * a.rindex("z") #=> nil @@ -1248,7 +1248,7 @@ rb_ary_splice(VALUE ary, long beg, long len, VALUE rpl) } } -/* +/* * call-seq: * array[index] = obj -> obj * array[start, length] = obj or an_array or nil -> obj or an_array or nil @@ -1264,7 +1264,7 @@ rb_ary_splice(VALUE ary, long beg, long len, VALUE rpl) * zero. An +IndexError+ is raised if a negative index points * past the beginning of the array. See also * Array#push, and Array#unshift. - * + * * a = Array.new * a[4] = "4"; #=> [nil, nil, nil, nil, "4"] * a[0, 3] = [ 'a', 'b', 'c' ] #=> ["a", "b", "c", nil, "4"] @@ -1309,10 +1309,10 @@ fixnum: /* * call-seq: * array.insert(index, obj...) -> array - * + * * Inserts the given values before the element with the given index * (which may be negative). - * + * * a = %w{ a b c d } * a.insert(2, 99) #=> ["a", "b", 99, "c", "d"] * a.insert(-2, 1, 2, 3) #=> ["a", "b", 99, "c", 1, 2, 3, "d"] @@ -1341,15 +1341,15 @@ rb_ary_insert(int argc, VALUE *argv, VALUE ary) /* * call-seq: * array.each {|item| block } -> array - * + * * Calls block once for each element in self, passing that * element as a parameter. - * + * * a = [ "a", "b", "c" ] * a.each {|x| print x, " -- " } - * + * * produces: - * + * * a -- b -- c -- */ @@ -1368,15 +1368,15 @@ rb_ary_each(VALUE ary) /* * call-seq: * array.each_index {|index| block } -> array - * + * * Same as Array#each, but passes the index of the element * instead of the element itself. - * + * * a = [ "a", "b", "c" ] * a.each_index {|x| print x, " -- " } - * + * * produces: - * + * * 0 -- 1 -- 2 -- */ @@ -1394,16 +1394,16 @@ rb_ary_each_index(VALUE ary) /* * call-seq: - * array.reverse_each {|item| block } - * + * array.reverse_each {|item| block } + * * Same as Array#each, but traverses self in reverse * order. - * + * * a = [ "a", "b", "c" ] * a.reverse_each {|x| print x, " " } - * + * * produces: - * + * * c b a */ @@ -1426,9 +1426,9 @@ rb_ary_reverse_each(VALUE ary) /* * call-seq: * array.length -> int - * + * * Returns the number of elements in self. May be zero. - * + * * [ 1, 2, 3, 4, 5 ].length #=> 5 */ @@ -1442,9 +1442,9 @@ rb_ary_length(VALUE ary) /* * call-seq: * array.empty? -> true or false - * + * * Returns true if self array contains no elements. - * + * * [].empty? #=> true */ @@ -1543,10 +1543,10 @@ rb_ary_join(VALUE ary, VALUE sep) /* * call-seq: * array.join(sep=$,) -> str - * + * * Returns a string created by converting each element of the array to * a string, separated by sep. - * + * * [ "a", "b", "c" ].join #=> "abc" * [ "a", "b", "c" ].join("-") #=> "a-b-c" */ @@ -1558,7 +1558,7 @@ rb_ary_join_m(int argc, VALUE *argv, VALUE ary) rb_scan_args(argc, argv, "01", &sep); if (NIL_P(sep)) sep = rb_output_fs; - + return rb_ary_join(ary, sep); } @@ -1609,7 +1609,7 @@ rb_ary_to_s(VALUE ary) /* * call-seq: * array.to_a -> array - * + * * Returns _self_. If called on a subclass of Array, converts * the receiver to an Array object. */ @@ -1628,7 +1628,7 @@ rb_ary_to_a(VALUE ary) /* * call-seq: * array.to_ary -> array - * + * * Returns _self_. */ @@ -1660,10 +1660,10 @@ rb_ary_reverse(VALUE ary) /* * call-seq: - * array.reverse! -> array - * + * array.reverse! -> array + * * Reverses _self_ in place. - * + * * a = [ "a", "b", "c" ] * a.reverse! #=> ["c", "b", "a"] * a #=> ["c", "b", "a"] @@ -1678,9 +1678,9 @@ rb_ary_reverse_bang(VALUE ary) /* * call-seq: * array.reverse -> an_array - * + * * Returns a new array containing self's elements in reverse order. - * + * * [ "a", "b", "c" ].reverse #=> ["c", "b", "a"] * [ 1 ].reverse #=> [1] */ @@ -1763,14 +1763,14 @@ sort_2(const void *ap, const void *bp, void *dummy) /* * call-seq: * array.sort! -> array - * array.sort! {| a,b | block } -> array - * + * array.sort! {| a,b | block } -> array + * * Sorts _self_. Comparisons for * the sort will be done using the <=> operator or using * an optional code block. The block implements a comparison between * a and b, returning -1, 0, or +1. See also * Enumerable#sort_by. - * + * * a = [ "d", "a", "e", "c", "b" ] * a.sort #=> ["a", "b", "c", "d", "e"] * a.sort {|x,y| y <=> x } #=> ["e", "d", "c", "b", "a"] @@ -1823,7 +1823,7 @@ rb_ary_sort_bang(VALUE ary) ARY_SET_PTR(ary, RARRAY_PTR(tmp)); ARY_SET_HEAP_LEN(ary, RARRAY_LEN(tmp)); ARY_SET_CAPA(ary, ARY_CAPA(tmp)); - } + } /* tmp was lost ownership for the ptr */ FL_UNSET(tmp, FL_FREEZE); FL_SET_EMBED(tmp); @@ -1838,15 +1838,15 @@ rb_ary_sort_bang(VALUE ary) /* * call-seq: - * array.sort -> an_array - * array.sort {| a,b | block } -> an_array - * + * array.sort -> an_array + * array.sort {| a,b | block } -> an_array + * * Returns a new array created by sorting self. Comparisons for * the sort will be done using the <=> operator or using * an optional code block. The block implements a comparison between * a and b, returning -1, 0, or +1. See also * Enumerable#sort_by. - * + * * a = [ "d", "a", "e", "c", "b" ] * a.sort #=> ["a", "b", "c", "d", "e"] * a.sort {|x,y| y <=> x } #=> ["e", "d", "c", "b", "a"] @@ -1892,11 +1892,11 @@ rb_ary_sort_by_bang(VALUE ary) * call-seq: * array.collect {|item| block } -> an_array * array.map {|item| block } -> an_array - * - * Invokes block once for each element of self. Creates a + * + * Invokes block once for each element of self. Creates a * new array containing the values returned by the block. * See also Enumerable#collect. - * + * * a = [ "a", "b", "c", "d" ] * a.collect {|x| x + "!" } #=> ["a!", "b!", "c!", "d!"] * a #=> ["a", "b", "c", "d"] @@ -1917,7 +1917,7 @@ rb_ary_collect(VALUE ary) } -/* +/* * call-seq: * array.collect! {|item| block } -> array * array.map! {|item| block } -> array @@ -1925,7 +1925,7 @@ rb_ary_collect(VALUE ary) * Invokes the block once for each element of _self_, replacing the * element with the value returned by _block_. * See also Enumerable#collect. - * + * * a = [ "a", "b", "c", "d" ] * a.collect! {|x| x + "!" } * a #=> [ "a!", "b!", "c!", "d!" ] @@ -1972,15 +1972,15 @@ rb_get_values_at(VALUE obj, long olen, int argc, VALUE *argv, VALUE (*func) (VAL return result; } -/* +/* * call-seq: * array.values_at(selector,... ) -> an_array * * Returns an array containing the elements in * _self_ corresponding to the given selector(s). The selectors - * may be either integer indices or ranges. + * may be either integer indices or ranges. * See also Array#select. - * + * * a = %w{ a b c d e f } * a.values_at(1, 3, 5) * a.values_at(1, 3, 5, 7) @@ -1998,11 +1998,11 @@ rb_ary_values_at(int argc, VALUE *argv, VALUE ary) /* * call-seq: * array.select {|item| block } -> an_array - * + * * Invokes the block passing in successive elements from array, * returning an array containing those elements for which the block * returns a true value (equivalent to Enumerable#select). - * + * * a = %w{ a b c d e f } * a.select {|v| v =~ /[aeiou]/} #=> ["a", "e"] */ @@ -2025,14 +2025,14 @@ rb_ary_select(VALUE ary) /* * call-seq: - * array.delete(obj) -> obj or nil + * array.delete(obj) -> obj or nil * array.delete(obj) { block } -> obj or nil - * + * * Deletes items from self that are equal to obj. If * the item is not found, returns nil. If the optional * code block is given, returns the result of block if the item * is not found. - * + * * a = [ "a", "b", "b", "b", "c" ] * a.delete("b") #=> "b" * a #=> ["a", "c"] @@ -2101,11 +2101,11 @@ rb_ary_delete_at(VALUE ary, long pos) /* * call-seq: * array.delete_at(index) -> obj or nil - * + * * Deletes the element at the specified index, returning that element, * or nil if the index is out of range. See also * Array#slice!. - * + * * a = %w( ant bat cat dog ) * a.delete_at(2) #=> "cat" * a #=> ["ant", "bat", "dog"] @@ -2122,12 +2122,12 @@ rb_ary_delete_at_m(VALUE ary, VALUE pos) * call-seq: * array.slice!(index) -> obj or nil * array.slice!(start, length) -> sub_array or nil - * array.slice!(range) -> sub_array or nil - * + * array.slice!(range) -> sub_array or nil + * * Deletes the element(s) given by an index (optionally with a length) * or by a range. Returns the deleted object, subarray, or * nil if the index is out of range. - * + * * a = [ "a", "b", "c" ] * a.slice!(1) #=> "b" * a #=> ["a", "c"] @@ -2185,7 +2185,7 @@ rb_ary_slice_bang(int argc, VALUE *argv, VALUE ary) /* * call-seq: * array.reject! {|item| block } -> array or nil - * + * * Equivalent to Array#delete_if, deleting elements from * _self_ for which the block evaluates to true, but returns * nil if no changes were made. Also see @@ -2217,7 +2217,7 @@ rb_ary_reject_bang(VALUE ary) /* * call-seq: * array.reject {|item| block } -> an_array - * + * * Returns a new array containing the items in _self_ * for which the block is not true. */ @@ -2234,10 +2234,10 @@ rb_ary_reject(VALUE ary) /* * call-seq: * array.delete_if {|item| block } -> array - * + * * Deletes every element of self for which block evaluates * to true. - * + * * a = [ "a", "b", "c" ] * a.delete_if {|x| x >= "b" } #=> ["a"] */ @@ -2277,7 +2277,7 @@ take_items(VALUE obj, long n) * call-seq: * array.zip(arg, ...) -> an_array * array.zip(arg, ...) {| arr | block } -> nil - * + * * Converts any arguments to arrays, then merges elements of * self with corresponding elements from each argument. This * generates a sequence of self.size n-element @@ -2286,7 +2286,7 @@ take_items(VALUE obj, long n) * nil values are supplied. If a block given, it is * invoked for each output array, otherwise an array of arrays is * returned. - * + * * a = [ 4, 5, 6 ] * b = [ 7, 8, 9 ] * [1,2,3].zip(a, b) #=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]] @@ -2329,10 +2329,10 @@ rb_ary_zip(int argc, VALUE *argv, VALUE ary) /* * call-seq: * array.transpose -> an_array - * + * * Assumes that self is an array of arrays and transposes the * rows and columns. - * + * * a = [[1,2], [3,4], [5,6]] * a.transpose #=> [[1, 3, 5], [2, 4, 6]] */ @@ -2368,10 +2368,10 @@ rb_ary_transpose(VALUE ary) /* * call-seq: * array.replace(other_array) -> array - * + * * Replaces the contents of self with the contents of * other_array, truncating or expanding if necessary. - * + * * a = [ "a", "b", "c", "d", "e" ] * a.replace([ "x", "y", "z" ]) #=> ["x", "y", "z"] * a #=> ["x", "y", "z"] @@ -2387,7 +2387,7 @@ rb_ary_replace(VALUE copy, VALUE orig) if (RARRAY_LEN(orig) <= RARRAY_EMBED_LEN_MAX) { VALUE *ptr; VALUE shared = 0; - + if (ARY_OWNS_HEAP_P(copy)) { xfree(RARRAY_PTR(copy)); } @@ -2419,7 +2419,7 @@ rb_ary_replace(VALUE copy, VALUE orig) return copy; } -/* +/* * call-seq: * array.clear -> array * @@ -2448,14 +2448,14 @@ rb_ary_clear(VALUE ary) * array.fill {|index| block } -> array * array.fill(start [, length] ) {|index| block } -> array * array.fill(range) {|index| block } -> array - * + * * The first three forms set the selected elements of self (which * may be the entire array) to obj. A start of * nil is equivalent to zero. A length of * nil is equivalent to self.length. The last three * forms fill the array with the value of the block. The block is * passed the absolute index of each element to be filled. - * + * * a = [ "a", "b", "c", "d" ] * a.fill("x") #=> ["x", "x", "x", "x"] * a.fill("z", 2, 2) #=> ["x", "x", "z", "z"] @@ -2535,13 +2535,13 @@ rb_ary_fill(int argc, VALUE *argv, VALUE ary) return ary; } -/* +/* * call-seq: * array + other_array -> an_array * * Concatenation---Returns a new array built by concatenating the * two arrays together to produce a third array. - * + * * [ 1, 2, 3 ] + [ 4, 5 ] #=> [ 1, 2, 3, 4, 5 ] */ @@ -2560,12 +2560,12 @@ rb_ary_plus(VALUE x, VALUE y) return z; } -/* +/* * call-seq: * array.concat(other_array) -> array * * Appends the elements in other_array to _self_. - * + * * [ "a", "b" ].concat( ["c", "d"] ) #=> [ "a", "b", "c", "d" ] */ @@ -2581,7 +2581,7 @@ rb_ary_concat(VALUE x, VALUE y) } -/* +/* * call-seq: * array * int -> an_array * array * str -> a_string @@ -2632,7 +2632,7 @@ rb_ary_times(VALUE ary, VALUE times) return ary2; } -/* +/* * call-seq: * array.assoc(obj) -> an_array or nil * @@ -2670,12 +2670,12 @@ rb_ary_assoc(VALUE ary, VALUE key) /* * call-seq: * array.rassoc(obj) -> an_array or nil - * + * * Searches through the array whose elements are also arrays. Compares * _obj_ with the second element of each contained array using * ==. Returns the first contained array that matches. See * also Array#assoc. - * + * * a = [ [ 1, "one"], [2, "two"], [3, "three"], ["ii", "two"] ] * a.rassoc("two") #=> [2, "two"] * a.rassoc("four") #=> nil @@ -2710,7 +2710,7 @@ recursive_equal(VALUE ary1, VALUE ary2, int recur) return Qtrue; } -/* +/* * call-seq: * array == other_array -> bool * @@ -2803,11 +2803,11 @@ rb_ary_hash(VALUE ary) /* * call-seq: * array.include?(obj) -> true or false - * + * * Returns true if the given object is present in * self (that is, if any object == anObject), * false otherwise. - * + * * a = [ "a", "b", "c" ] * a.include?("b") #=> true * a.include?("z") #=> false @@ -2817,7 +2817,7 @@ VALUE rb_ary_includes(VALUE ary, VALUE item) { long i; - + for (i=0; i other_array -> -1, 0, +1 * @@ -2860,7 +2860,7 @@ recursive_cmp(VALUE ary1, VALUE ary2, int recur) * ``equal'' according to Array#<=> if and only if they have * the same length and the value of each element is equal to the * value of the corresponding element in the other array. - * + * * [ "a", "a", "c" ] <=> [ "a", "b", "c" ] #=> -1 * [ 1, 2, 3, 4, 5, 6 ] <=> [ 1, 2 ] #=> +1 * @@ -2940,7 +2940,7 @@ ary_recycle_hash(VALUE hash) } } -/* +/* * call-seq: * array - other_array -> an_array * @@ -2970,7 +2970,7 @@ rb_ary_diff(VALUE ary1, VALUE ary2) return ary3; } -/* +/* * call-seq: * array & other_array * @@ -3006,7 +3006,7 @@ rb_ary_and(VALUE ary1, VALUE ary2) return ary3; } -/* +/* * call-seq: * array | other_array -> an_array * @@ -3054,17 +3054,17 @@ push_value(st_data_t key, st_data_t val, st_data_t ary) /* * call-seq: * array.uniq! -> array or nil - * + * * Removes duplicate elements from _self_. * Returns nil if no changes are made (that is, no * duplicates are found). - * + * * a = [ "a", "a", "b", "b", "c" ] * a.uniq! #=> ["a", "b", "c"] * b = [ "a", "b", "c" ] * b.uniq! #=> nil * c = [ "a:def", "a:xyz", "b:abc", "b:xyz", "c:jkl" ] - * c.uniq! {|s| s[/^\w+/]} #=> [ "a:def", "b:abc", "c:jkl" ] + * c.uniq! {|s| s[/^\w+/]} #=> [ "a:def", "b:abc", "c:jkl" ] */ static VALUE @@ -3103,13 +3103,13 @@ rb_ary_uniq_bang(VALUE ary) /* * call-seq: * array.uniq -> an_array - * + * * Returns a new array by removing duplicate values in self. - * + * * a = [ "a", "a", "b", "b", "c" ] * a.uniq #=> ["a", "b", "c"] * c = [ "a:def", "a:xyz", "b:abc", "b:xyz", "c:jkl" ] - * c.uniq {|s| s[/^\w+/]} #=> [ "a:def", "b:abc", "c:jkl" ] + * c.uniq {|s| s[/^\w+/]} #=> [ "a:def", "b:abc", "c:jkl" ] */ static VALUE @@ -3138,7 +3138,7 @@ rb_ary_uniq(VALUE ary) return uniq; } -/* +/* * call-seq: * array.compact! -> array or nil * @@ -3158,7 +3158,7 @@ rb_ary_compact_bang(VALUE ary) rb_ary_modify(ary); p = t = RARRAY_PTR(ary); end = p + RARRAY_LEN(ary); - + while (t < end) { if (NIL_P(*t)) t++; else *p++ = *t++; @@ -3198,7 +3198,7 @@ rb_ary_compact(VALUE ary) * array.count -> int * array.count(obj) -> int * array.count { |item| block } -> int - * + * * Returns the number of elements. If an argument is given, counts * the number of elements which equals to obj. If a block is * given, counts the number of elements yielding a true value. @@ -3298,12 +3298,12 @@ flatten(VALUE ary, int level, int *modified) * call-seq: * array.flatten! -> array or nil * array.flatten!(level) -> array or nil - * + * * Flattens _self_ in place. * Returns nil if no modifications were made (i.e., * array contains no subarrays.) If the optional level * argument determines the level of recursion to flatten. - * + * * a = [ 1, 2, [3, [4, 5] ] ] * a.flatten! #=> [1, 2, 3, 4, 5] * a.flatten! #=> nil @@ -3333,12 +3333,12 @@ rb_ary_flatten_bang(int argc, VALUE *argv, VALUE ary) * call-seq: * array.flatten -> an_array * array.flatten(level) -> an_array - * + * * Returns a new array that is a one-dimensional flattening of this * array (recursively). That is, for every element that is an array, * extract its elements into the new array. If the optional * level argument determines the level of recursion to flatten. - * + * * s = [ 1, 2, 3 ] #=> [1, 2, 3] * t = [ 4, 5, 6, [7, 8] ] #=> [4, 5, 6, [7, 8]] * a = [ s, t, 9, 10 ] #=> [[1, 2, 3], [4, 5, 6, [7, 8]], 9, 10] @@ -3366,7 +3366,7 @@ rb_ary_flatten(int argc, VALUE *argv, VALUE ary) /* * call-seq: * array.shuffle! -> array - * + * * Shuffles elements in _self_ in place. */ @@ -3390,9 +3390,9 @@ rb_ary_shuffle_bang(VALUE ary) /* * call-seq: * array.shuffle -> an_array - * + * * Returns a new array with elements of this array shuffled. - * + * * a = [ 1, 2, 3 ] #=> [1, 2, 3] * a.shuffle #=> [2, 3, 1] */ @@ -3410,11 +3410,11 @@ rb_ary_shuffle(VALUE ary) * call-seq: * array.sample -> obj * array.sample(n) -> an_array - * + * * Choose a random element, or the random +n+ elements, from the array. * If the array is empty, the first form returns nil, and the * second form returns an empty array. - * + * */ @@ -3424,7 +3424,7 @@ rb_ary_sample(int argc, VALUE *argv, VALUE ary) VALUE nv, result, *ptr; long n, len, i, j, k, idx[10]; - len = RARRAY_LEN(ary); + len = RARRAY_LEN(ary); if (argc == 0) { if (len == 0) return Qnil; i = len == 1 ? 0 : rb_genrand_real()*len; @@ -3432,8 +3432,8 @@ rb_ary_sample(int argc, VALUE *argv, VALUE ary) } rb_scan_args(argc, argv, "1", &nv); n = NUM2LONG(nv); - ptr = RARRAY_PTR(ary); - len = RARRAY_LEN(ary); + ptr = RARRAY_PTR(ary); + len = RARRAY_LEN(ary); if (n > len) n = len; switch (n) { case 0: return rb_ary_new2(0); @@ -3492,16 +3492,16 @@ rb_ary_sample(int argc, VALUE *argv, VALUE ary) * call-seq: * ary.cycle {|obj| block } * ary.cycle(n) {|obj| block } - * + * * Calls block for each element repeatedly _n_ times or * forever if none or nil is given. If a non-positive number is * given or the array is empty, does nothing. Returns nil if the * loop has finished without getting interrupted. - * + * * a = ["a", "b", "c"] * a.cycle {|x| puts x } # print, a, b, c, a, b, c,.. forever. * a.cycle(2) {|x| puts x } # print, a, b, c, a, b, c. - * + * */ static VALUE @@ -3534,9 +3534,9 @@ rb_ary_cycle(int argc, VALUE *argv, VALUE ary) /* * Recursively compute permutations of r elements of the set [0..n-1]. * When we have a complete permutation of array indexes, copy the values - * at those indexes into a new array and yield that array. + * at those indexes into a new array and yield that array. * - * n: the size of the set + * n: the size of the set * r: the number of elements in each permutation * p: the array (of size r) that we're filling in * index: what index we're filling in now @@ -3553,7 +3553,7 @@ permute0(long n, long r, long *p, long index, int *used, VALUE values) if (index < r-1) { /* if not done yet */ used[i] = 1; /* mark index used */ permute0(n, r, p, index+1, /* recurse */ - used, values); + used, values); used[i] = 0; /* index unused */ } else { @@ -3578,15 +3578,15 @@ permute0(long n, long r, long *p, long index, int *used, VALUE values) * ary.permutation -> enumerator * ary.permutation(n) { |p| block } -> array * ary.permutation(n) -> enumerator - * + * * When invoked with a block, yield all permutations of length n * of the elements of ary, then return the array itself. * If n is not specified, yield all permutations of all elements. - * The implementation makes no guarantees about the order in which + * The implementation makes no guarantees about the order in which * the permutations are yielded. * * When invoked without a block, return an enumerator object instead. - * + * * Examples: * * a = [1, 2, 3] @@ -3609,7 +3609,7 @@ rb_ary_permutation(int argc, VALUE *argv, VALUE ary) rb_scan_args(argc, argv, "01", &num); r = NIL_P(num) ? n : NUM2LONG(num); /* Permutation size from argument */ - if (r < 0 || n < r) { + if (r < 0 || n < r) { /* no permutations: yield nothing */ } else if (r == 0) { /* exactly one permutation: the zero-length array */ @@ -3662,14 +3662,14 @@ combi_len(long n, long k) * call-seq: * ary.combination(n) { |c| block } -> ary * ary.combination(n) -> enumerator - * - * When invoked with a block, yields all combinations of length n + * + * When invoked with a block, yields all combinations of length n * of elements from ary and then returns ary itself. - * The implementation makes no guarantees about the order in which + * The implementation makes no guarantees about the order in which * the combinations are yielded. * * When invoked without a block, returns an enumerator object instead. - * + * * Examples: * * a = [1, 2, 3, 4] @@ -3679,7 +3679,7 @@ combi_len(long n, long k) * a.combination(4).to_a #=> [[1,2,3,4]] * a.combination(0).to_a #=> [[]] # one combination of length 0 * a.combination(5).to_a #=> [] # no combinations of length 5 - * + * */ static VALUE @@ -3729,11 +3729,11 @@ rb_ary_combination(VALUE ary, VALUE num) /* * call-seq: * ary.product(other_ary, ...) - * + * * Returns an array of all combinations of elements from all arrays. * The length of the returned array is the product of the length * of ary and the argument arrays - * + * * [1,2,3].product([4,5]) # => [[1,4],[1,5],[2,4],[2,5],[3,4],[3,5]] * [1,2].product([1,2]) # => [[1,1],[1,2],[2,1],[2,2]] * [1,2].product([3,4],[5,6]) # => [[1,3,5],[1,3,6],[1,4,5],[1,4,6], @@ -3760,7 +3760,7 @@ rb_ary_product(int argc, VALUE *argv, VALUE ary) /* initialize the arrays of arrays */ arrays[0] = ary; for (i = 1; i < n; i++) arrays[i] = to_ary(argv[i-1]); - + /* initialize the counters for the arrays */ for (i = 0; i < n; i++) counters[i] = 0; @@ -3806,12 +3806,12 @@ rb_ary_product(int argc, VALUE *argv, VALUE ary) /* * call-seq: * ary.take(n) => array - * + * * Returns first n elements from ary. - * + * * a = [1, 2, 3, 4, 5, 0] * a.take(3) # => [1, 2, 3] - * + * */ static VALUE @@ -3827,13 +3827,13 @@ rb_ary_take(VALUE obj, VALUE n) /* * call-seq: * ary.take_while {|arr| block } => array - * + * * Passes elements to the block until the block returns nil or false, * then stops iterating and returns an array of all prior elements. - * + * * a = [1, 2, 3, 4, 5, 0] * a.take_while {|i| i < 3 } # => [1, 2] - * + * */ static VALUE @@ -3851,13 +3851,13 @@ rb_ary_take_while(VALUE ary) /* * call-seq: * ary.drop(n) => array - * + * * Drops first n elements from ary, and returns rest elements * in an array. - * + * * a = [1, 2, 3, 4, 5, 0] * a.drop(3) # => [4, 5, 0] - * + * */ static VALUE @@ -3877,14 +3877,14 @@ rb_ary_drop(VALUE ary, VALUE n) /* * call-seq: * ary.drop_while {|arr| block } => array - * + * * Drops elements up to, but not including, the first element for * which the block returns nil or false and returns an array * containing the remaining elements. - * + * * a = [1, 2, 3, 4, 5, 0] * a.drop_while {|i| i < 3 } # => [3, 4, 5, 0] - * + * */ static VALUE @@ -3901,11 +3901,11 @@ rb_ary_drop_while(VALUE ary) -/* Arrays are ordered, integer-indexed collections of any object. - * Array indexing starts at 0, as in C or Java. A negative index is - * assumed to be relative to the end of the array---that is, an index of -1 - * indicates the last element of the array, -2 is the next to last - * element in the array, and so on. +/* Arrays are ordered, integer-indexed collections of any object. + * Array indexing starts at 0, as in C or Java. A negative index is + * assumed to be relative to the end of the array---that is, an index of -1 + * indicates the last element of the array, -2 is the next to last + * element in the array, and so on. */ void -- cgit