diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-22 01:00:18 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-22 01:00:18 +0000 |
commit | 3f0d0b9398b5af9311f8e570c0a8966ed9944d25 (patch) | |
tree | 22ed07f9cf180380f56d3767725522ef6feecb70 /array.c | |
parent | 69743fbd85b659601174bff9fb61abc8c662c13b (diff) |
* *.[chy]: removed trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@25430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 350 |
1 files changed, 175 insertions, 175 deletions
@@ -312,22 +312,22 @@ static VALUE rb_ary_replace _((VALUE, VALUE)); * 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) */ @@ -388,8 +388,8 @@ rb_ary_initialize(argc, argv, 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/ ] @@ -492,7 +492,7 @@ ary_shared_first(argc, argv, ary, last) /* * 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. @@ -511,16 +511,16 @@ rb_ary_push(ary, 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"] */ @@ -555,13 +555,13 @@ rb_ary_pop(ary) * call-seq: * array.pop -> obj or nil * array.pop(n) -> array - * + * * Removes the last element from <i>self</i> and returns it, or * <code>nil</code> if the array is empty. * * If a number _n_ is given, returns an array of the last n elements * (or less) just like <code>array.slice!(-n, n)</code> does. - * + * * a = [ "a", "b", "c", "d" ] * a.pop #=> "d" * a.pop(2) #=> ["b", "c"] @@ -614,14 +614,14 @@ rb_ary_shift(ary) * call-seq: * array.shift -> obj or nil * array.shift(n) -> array - * + * * Returns the first element of <i>self</i> and removes it (shifting all * other elements down by one). Returns <code>nil</code> if the array * is empty. * * If a number _n_ is given, returns an array of the first n elements * (or less) just like <code>array.slice!(0, n)</code> does. - * + * * args = [ "-m", "-q", "filename" ] * args.shift #=> "-m" * args #=> ["-q", "filename"] @@ -685,10 +685,10 @@ rb_ary_unshift(ary, item) /* * call-seq: * array.unshift(obj, ...) -> array - * + * * Prepends objects to the front of <i>array</i>. * 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"] @@ -710,7 +710,7 @@ rb_ary_unshift_m(argc, argv, ary) /* sliding items */ MEMMOVE(RARRAY(ary)->ptr + argc, RARRAY(ary)->ptr, VALUE, len); MEMCPY(RARRAY(ary)->ptr, argv, VALUE, argc); - + return ary; } @@ -768,7 +768,7 @@ rb_ary_subseq(ary, beg, len) return ary2; } -/* +/* * call-seq: * array[index] -> obj or nil * array[start, length] -> an_array or nil @@ -843,7 +843,7 @@ rb_ary_aref(argc, argv, ary) return rb_ary_entry(ary, NUM2LONG(arg)); } -/* +/* * call-seq: * array.at(index) -> obj or nil * @@ -899,10 +899,10 @@ rb_ary_first(argc, argv, ary) * call-seq: * array.last -> obj or nil * array.last(n) -> an_array - * + * * Returns the last element(s) of <i>self</i>. If the array is empty, * the first form returns <code>nil</code>. - * + * * [ "w", "x", "y", "z" ].last #=> "z" */ @@ -926,14 +926,14 @@ rb_ary_last(argc, argv, ary) * array.fetch(index) -> obj * array.fetch(index, default ) -> obj * array.fetch(index) {|index| block } -> obj - * + * * Tries to return the element at position <i>index</i>. If the index * lies outside the array, the first form throws an * <code>IndexError</code> exception, the second form returns * <i>default</i>, and the third form returns the value of invoking * the block, passing in the index. Negative values of <i>index</i> * count from the end of the array. - * + * * a = [ 11, 22, 33, 44 ] * a.fetch(1) #=> 22 * a.fetch(-1) #=> 44 @@ -975,12 +975,12 @@ rb_ary_fetch(argc, argv, ary) * call-seq: * array.index(obj) -> int or nil * array.index {|item| block} -> int or nil - * + * * Returns the index of the first object in <i>self</i> such that is * <code>==</code> to <i>obj</i>. If a block is given instead of an * argument, returns first object for which <em>block</em> is true. * Returns <code>nil</code> if no match is found. - * + * * a = [ "a", "b", "c" ] * a.index("b") #=> 1 * a.index("z") #=> nil @@ -1018,12 +1018,12 @@ rb_ary_index(argc, argv, ary) /* * call-seq: * array.rindex(obj) -> int or nil - * + * * Returns the index of the last object in <i>array</i> * <code>==</code> to <i>obj</i>. If a block is given instead of an * argument, returns first object for which <em>block</em> is * true. Returns <code>nil</code> if no match is found. - * + * * a = [ "a", "b", "b", "b", "c" ] * a.rindex("b") #=> 3 * a.rindex("z") #=> nil @@ -1065,7 +1065,7 @@ rb_ary_rindex(argc, argv, ary) * call-seq: * array.indexes( i1, i2, ... iN ) -> an_array * array.indices( i1, i2, ... iN ) -> an_array - * + * * Deprecated; use <code>Array#values_at</code>. */ @@ -1167,7 +1167,7 @@ rb_ary_splice(ary, beg, len, rpl) } } -/* +/* * call-seq: * array[index] = obj -> obj * array[start, length] = obj or an_array or nil -> obj or an_array or nil @@ -1184,7 +1184,7 @@ rb_ary_splice(ary, beg, len, rpl) * deletes elements from _self_. An +IndexError+ is raised if a * negative index points past the beginning of the array. See also * <code>Array#push</code>, and <code>Array#unshift</code>. - * + * * a = Array.new * a[4] = "4"; #=> [nil, nil, nil, nil, "4"] * a[0, 3] = [ 'a', 'b', 'c' ] #=> ["a", "b", "c", nil, "4"] @@ -1240,10 +1240,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"] @@ -1275,15 +1275,15 @@ rb_ary_insert(argc, argv, ary) /* * call-seq: * array.each {|item| block } -> array - * + * * Calls <i>block</i> once for each element in <i>self</i>, passing that * element as a parameter. - * + * * a = [ "a", "b", "c" ] * a.each {|x| print x, " -- " } - * + * * produces: - * + * * a -- b -- c -- */ @@ -1303,15 +1303,15 @@ rb_ary_each(ary) /* * call-seq: * array.each_index {|index| block } -> array - * + * * Same as <code>Array#each</code>, 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 -- */ @@ -1330,16 +1330,16 @@ rb_ary_each_index(ary) /* * call-seq: - * array.reverse_each {|item| block } - * + * array.reverse_each {|item| block } + * * Same as <code>Array#each</code>, but traverses <i>self</i> in reverse * order. - * + * * a = [ "a", "b", "c" ] * a.reverse_each {|x| print x, " " } - * + * * produces: - * + * * c b a */ @@ -1363,9 +1363,9 @@ rb_ary_reverse_each(ary) /* * call-seq: * array.length -> int - * + * * Returns the number of elements in <i>self</i>. May be zero. - * + * * [ 1, 2, 3, 4, 5 ].length #=> 5 */ @@ -1379,9 +1379,9 @@ rb_ary_length(ary) /* * call-seq: * array.empty? -> true or false - * + * * Returns <code>true</code> if <i>self</i> array contains no elements. - * + * * [].empty? #=> true */ @@ -1469,10 +1469,10 @@ rb_ary_join(ary, sep) /* * call-seq: * array.join(sep=$,) -> str - * + * * Returns a string created by converting each element of the array to * a string, separated by <i>sep</i>. - * + * * [ "a", "b", "c" ].join #=> "abc" * [ "a", "b", "c" ].join("-") #=> "a-b-c" */ @@ -1487,16 +1487,16 @@ rb_ary_join_m(argc, argv, ary) rb_scan_args(argc, argv, "01", &sep); if (NIL_P(sep)) sep = rb_output_fs; - + return rb_ary_join(ary, sep); } /* * call-seq: * array.to_s -> string - * + * * Returns _self_<code>.join</code>. - * + * * [ "a", "e", "i", "o" ].to_s #=> "aeio" * */ @@ -1506,7 +1506,7 @@ rb_ary_to_s(ary) VALUE ary; { if (RARRAY(ary)->len == 0) return rb_str_new(0, 0); - + return rb_ary_join(ary, rb_output_fs); } @@ -1631,7 +1631,7 @@ rb_ary_inspect(ary) /* * call-seq: * array.to_a -> array - * + * * Returns _self_. If called on a subclass of Array, converts * the receiver to an Array object. */ @@ -1651,7 +1651,7 @@ rb_ary_to_a(ary) /* * call-seq: * array.to_ary -> array - * + * * Returns _self_. */ @@ -1685,10 +1685,10 @@ rb_ary_reverse(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"] @@ -1704,9 +1704,9 @@ rb_ary_reverse_bang(ary) /* * call-seq: * array.reverse -> an_array - * + * * Returns a new array containing <i>self</i>'s elements in reverse order. - * + * * [ "a", "b", "c" ].reverse #=> ["c", "b", "a"] * [ 1 ].reverse #=> [1] */ @@ -1795,14 +1795,14 @@ sort_unlock(ary) /* * 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 <code><=></code> operator or using * an optional code block. The block implements a comparison between * <i>a</i> and <i>b</i>, returning -1, 0, or +1. See also * <code>Enumerable#sort_by</code>. - * + * * a = [ "d", "a", "e", "c", "b" ] * a.sort #=> ["a", "b", "c", "d", "e"] * a.sort {|x,y| y <=> x } #=> ["e", "d", "c", "b", "a"] @@ -1822,15 +1822,15 @@ rb_ary_sort_bang(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 <i>self</i>. Comparisons for * the sort will be done using the <code><=></code> operator or using * an optional code block. The block implements a comparison between * <i>a</i> and <i>b</i>, returning -1, 0, or +1. See also * <code>Enumerable#sort_by</code>. - * + * * a = [ "d", "a", "e", "c", "b" ] * a.sort #=> ["a", "b", "c", "d", "e"] * a.sort {|x,y| y <=> x } #=> ["e", "d", "c", "b", "a"] @@ -1849,11 +1849,11 @@ rb_ary_sort(ary) * call-seq: * array.collect {|item| block } -> an_array * array.map {|item| block } -> an_array - * - * Invokes <i>block</i> once for each element of <i>self</i>. Creates a + * + * Invokes <i>block</i> once for each element of <i>self</i>. Creates a * new array containing the values returned by the block. * See also <code>Enumerable#collect</code>. - * + * * a = [ "a", "b", "c", "d" ] * a.collect {|x| x + "!" } #=> ["a!", "b!", "c!", "d!"] * a #=> ["a", "b", "c", "d"] @@ -1877,7 +1877,7 @@ rb_ary_collect(ary) return collect; } -/* +/* * call-seq: * array.collect! {|item| block } -> array * array.map! {|item| block } -> array @@ -1885,7 +1885,7 @@ rb_ary_collect(ary) * Invokes the block once for each element of _self_, replacing the * element with the value returned by _block_. * See also <code>Enumerable#collect</code>. - * + * * a = [ "a", "b", "c", "d" ] * a.collect! {|x| x + "!" } * a #=> [ "a!", "b!", "c!", "d!" ] @@ -1938,15 +1938,15 @@ rb_values_at(obj, olen, argc, argv, func) 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 <code>Array#select</code>. - * + * * a = %w{ a b c d e f } * a.values_at(1, 3, 5) * a.values_at(1, 3, 5, 7) @@ -1966,11 +1966,11 @@ rb_ary_values_at(argc, argv, ary) /* * call-seq: * array.select {|item| block } -> an_array - * + * * Invokes the block passing in successive elements from <i>array</i>, * returning an array containing those elements for which the block * returns a true value (equivalent to <code>Enumerable#select</code>). - * + * * a = %w{ a b c d e f } * a.select {|v| v =~ /[aeiou]/} #=> ["a", "e"] */ @@ -1994,14 +1994,14 @@ rb_ary_select(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 <i>self</i> that are equal to <i>obj</i>. If * the item is not found, returns <code>nil</code>. If the optional * code block is given, returns the result of <i>block</i> if the item * is not found. - * + * * a = [ "a", "b", "b", "b", "c" ] * a.delete("b") #=> "b" * a #=> ["a", "c"] @@ -2072,11 +2072,11 @@ rb_ary_delete_at(ary, pos) /* * call-seq: * array.delete_at(index) -> obj or nil - * + * * Deletes the element at the specified index, returning that element, * or <code>nil</code> if the index is out of range. See also * <code>Array#slice!</code>. - * + * * a = %w( ant bat cat dog ) * a.delete_at(2) #=> "cat" * a #=> ["ant", "bat", "dog"] @@ -2094,18 +2094,18 @@ rb_ary_delete_at_m(ary, 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 * <code>nil</code> if the index is out of range. Equivalent to: - * + * * def slice!(*args) * result = self[*args] * self[*args] = nil * result * end - * + * * a = [ "a", "b", "c" ] * a.slice!(1) #=> "b" * a #=> ["a", "c"] @@ -2166,7 +2166,7 @@ rb_ary_slice_bang(argc, argv, ary) /* * call-seq: * array.reject! {|item| block } -> array or nil - * + * * Equivalent to <code>Array#delete_if</code>, deleting elements from * _self_ for which the block evaluates to true, but returns * <code>nil</code> if no changes were made. Also see @@ -2199,7 +2199,7 @@ rb_ary_reject_bang(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. */ @@ -2217,10 +2217,10 @@ rb_ary_reject(ary) /* * call-seq: * array.delete_if {|item| block } -> array - * + * * Deletes every element of <i>self</i> for which <i>block</i> evaluates * to <code>true</code>. - * + * * a = [ "a", "b", "c" ] * a.delete_if {|x| x >= "b" } #=> ["a"] */ @@ -2238,7 +2238,7 @@ rb_ary_delete_if(ary) * call-seq: * array.zip(arg, ...) -> an_array * array.zip(arg, ...) {| arr | block } -> nil - * + * * Converts any arguments to arrays, then merges elements of * <i>self</i> with corresponding elements from each argument. This * generates a sequence of <code>self.size</code> <em>n</em>-element @@ -2247,10 +2247,10 @@ rb_ary_delete_if(ary) * <code>nil</code> 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]] * [1,2].zip(a,b) #=> [[1, 4, 7], [2, 5, 8]] * a.zip([1,2],[8]) #=> [[4,1,8], [5,2,nil], [6,nil,nil]] @@ -2298,10 +2298,10 @@ rb_ary_zip(argc, argv, ary) /* * call-seq: * array.transpose -> an_array - * + * * Assumes that <i>self</i> 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]] */ @@ -2338,10 +2338,10 @@ rb_ary_transpose(ary) /* * call-seq: * array.replace(other_array) -> array - * + * * Replaces the contents of <i>self</i> with the contents of * <i>other_array</i>, truncating or expanding if necessary. - * + * * a = [ "a", "b", "c", "d", "e" ] * a.replace([ "x", "y", "z" ]) #=> ["x", "y", "z"] * a #=> ["x", "y", "z"] @@ -2367,7 +2367,7 @@ rb_ary_replace(copy, orig) return copy; } -/* +/* * call-seq: * array.clear -> array * @@ -2398,14 +2398,14 @@ rb_ary_clear(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 <i>self</i> (which * may be the entire array) to <i>obj</i>. A <i>start</i> of * <code>nil</code> is equivalent to zero. A <i>length</i> of * <code>nil</code> is equivalent to <i>self.length</i>. 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"] @@ -2489,13 +2489,13 @@ rb_ary_fill(argc, argv, 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 ] */ @@ -2515,12 +2515,12 @@ rb_ary_plus(x, 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" ] */ @@ -2537,7 +2537,7 @@ rb_ary_concat(x, y) } -/* +/* * call-seq: * array * int -> an_array * array * str -> a_string @@ -2585,7 +2585,7 @@ rb_ary_times(ary, times) return ary2; } -/* +/* * call-seq: * array.assoc(obj) -> an_array or nil * @@ -2624,12 +2624,12 @@ rb_ary_assoc(ary, key) /* * call-seq: * array.rassoc(key) -> an_array or nil - * + * * Searches through the array whose elements are also arrays. Compares * <em>key</em> with the second element of each contained array using * <code>==</code>. Returns the first contained array that matches. See * also <code>Array#assoc</code>. - * + * * a = [ [ 1, "one"], [2, "two"], [3, "three"], ["ii", "two"] ] * a.rassoc("two") #=> [2, "two"] * a.rassoc("four") #=> nil @@ -2668,7 +2668,7 @@ recursive_equal(ary1, ary2, recur) return Qtrue; } -/* +/* * call-seq: * array == other_array -> bool * @@ -2772,11 +2772,11 @@ rb_ary_hash(ary) /* * call-seq: * array.include?(obj) -> true or false - * + * * Returns <code>true</code> if the given object is present in * <i>self</i> (that is, if any object <code>==</code> <i>anObject</i>), * <code>false</code> otherwise. - * + * * a = [ "a", "b", "c" ] * a.include?("b") #=> true * a.include?("z") #=> false @@ -2788,7 +2788,7 @@ rb_ary_includes(ary, item) VALUE item; { long i; - + for (i=0; i<RARRAY(ary)->len; i++) { if (rb_equal(RARRAY(ary)->ptr[i], item)) { return Qtrue; @@ -2821,7 +2821,7 @@ recursive_cmp(ary1, ary2, recur) return Qundef; } -/* +/* * call-seq: * array <=> other_array -> -1, 0, +1 * @@ -2835,7 +2835,7 @@ recursive_cmp(ary1, ary2, recur) * ``equal'' according to <code>Array#<=></code> 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 * @@ -2876,7 +2876,7 @@ ary_make_hash(ary1, ary2) return hash; } -/* +/* * call-seq: * array - other_array -> an_array * @@ -2906,7 +2906,7 @@ rb_ary_diff(ary1, ary2) return ary3; } -/* +/* * call-seq: * array & other_array * @@ -2939,7 +2939,7 @@ rb_ary_and(ary1, ary2) return ary3; } -/* +/* * call-seq: * array | other_array -> an_array * @@ -2980,11 +2980,11 @@ rb_ary_or(ary1, ary2) /* * call-seq: * array.uniq! -> array or nil - * + * * Removes duplicate elements from _self_. * Returns <code>nil</code> 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" ] @@ -3017,9 +3017,9 @@ rb_ary_uniq_bang(ary) /* * call-seq: * array.uniq -> an_array - * + * * Returns a new array by removing duplicate values in <i>self</i>. - * + * * a = [ "a", "a", "b", "b", "c" ] * a.uniq #=> ["a", "b", "c"] */ @@ -3033,7 +3033,7 @@ rb_ary_uniq(ary) return ary; } -/* +/* * call-seq: * array.compact! -> array or nil * @@ -3053,7 +3053,7 @@ rb_ary_compact_bang(ary) rb_ary_modify(ary); p = t = RARRAY(ary)->ptr; end = p + RARRAY(ary)->len; - + while (t < end) { if (NIL_P(*t)) t++; else *p++ = *t++; @@ -3089,11 +3089,11 @@ rb_ary_compact(ary) /* * call-seq: * array.nitems -> int - * + * * Returns the number of non-<code>nil</code> elements in _self_. * * May be zero. - * + * * [ 1, nil, 3, nil, 5 ].nitems #=> 3 */ @@ -3117,7 +3117,7 @@ rb_ary_nitems(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 <i>obj</i>. If a block is * given, counts the number of elements yielding a true value. @@ -3223,12 +3223,12 @@ flatten(ary, level, modified) * call-seq: * array.flatten! -> array or nil * array.flatten!(level) -> array or nil - * + * * Flattens _self_ in place. * Returns <code>nil</code> if no modifications were made (i.e., * <i>array</i> contains no subarrays.) If the optional <i>level</i> * argument determines the level of recursion to flatten. - * + * * a = [ 1, 2, [3, [4, 5] ] ] * a.flatten! #=> [1, 2, 3, 4, 5] * a.flatten! #=> nil @@ -3261,12 +3261,12 @@ rb_ary_flatten_bang(argc, argv, 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 * <i>level</i> 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] @@ -3297,7 +3297,7 @@ rb_ary_flatten(argc, argv, ary) /* * call-seq: * array.shuffle! -> array or nil - * + * * Shuffles elements in _self_ in place. */ @@ -3322,9 +3322,9 @@ rb_ary_shuffle_bang(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] */ @@ -3343,11 +3343,11 @@ rb_ary_shuffle(ary) * call-seq: * array.sample -> obj * array.sample(n) -> an_array - * + * * Choose a random element, or the random +n+ elements, fron the array. * If the array is empty, the first form returns <code>nil</code>, and the * second form returns an empty array. - * + * */ @@ -3360,7 +3360,7 @@ rb_ary_sample(argc, argv, ary) VALUE nv, result; int n, len, i, j; - len = RARRAY_LEN(ary); + len = RARRAY_LEN(ary); if (argc == 0) { if (len == 0) return Qnil; i = rb_genrand_real()*len; @@ -3392,11 +3392,11 @@ rb_ary_sample(argc, argv, ary) /* * call-seq: * array.choice -> obj - * + * * Choose a random element from an array. NOTE: This method will be * deprecated in future. Use #sample instead. */ - + static VALUE rb_ary_choice(ary) VALUE ary; @@ -3416,16 +3416,16 @@ rb_ary_choice(ary) * call-seq: * ary.cycle {|obj| block } * ary.cycle(n) {|obj| block } - * + * * Calls <i>block</i> 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 @@ -3461,9 +3461,9 @@ rb_ary_cycle(argc, argv, 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 @@ -3483,7 +3483,7 @@ permute0(n, r, p, index, used, 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 { @@ -3508,15 +3508,15 @@ permute0(n, r, p, index, used, values) * ary.permutation -> enumerator * ary.permutation(n) { |p| block } -> array * ary.permutation(n) -> enumerator - * + * * When invoked with a block, yield all permutations of length <i>n</i> * of the elements of <i>ary</i>, then return the array itself. * If <i>n</i> 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] @@ -3542,7 +3542,7 @@ rb_ary_permutation(argc, argv, 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 */ @@ -3594,14 +3594,14 @@ combi_len(n, k) * call-seq: * ary.combination(n) { |c| block } -> ary * ary.combination(n) -> enumerator - * - * When invoked with a block, yields all combinations of length <i>n</i> + * + * When invoked with a block, yields all combinations of length <i>n</i> * of elements from <i>ary</i> and then returns <i>ary</i> 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] @@ -3611,7 +3611,7 @@ combi_len(n, 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 @@ -3663,11 +3663,11 @@ rb_ary_combination(ary, 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], @@ -3697,7 +3697,7 @@ rb_ary_product(argc, argv, 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; @@ -3743,12 +3743,12 @@ rb_ary_product(argc, argv, ary) /* * call-seq: * ary.take(n) => array - * + * * Returns first n elements from <i>ary</i>. - * + * * a = [1, 2, 3, 4, 5, 0] * a.take(3) # => [1, 2, 3] - * + * */ static VALUE @@ -3767,13 +3767,13 @@ rb_ary_take(obj, 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 @@ -3792,13 +3792,13 @@ rb_ary_take_while(ary) /* * call-seq: * ary.drop(n) => array - * + * * Drops first n elements from <i>ary</i>, and returns rest elements * in an array. - * + * * a = [1, 2, 3, 4, 5, 0] * a.drop(3) # => [4, 5, 0] - * + * */ static VALUE @@ -3820,14 +3820,14 @@ rb_ary_drop(ary, 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 @@ -3845,11 +3845,11 @@ rb_ary_drop_while(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 |