Speed of uniq

R

Ralph Shnelvar

These are general questions about Ruby and not specific to uniq.

(1) How can I tell if a method like uniq is "native" to Ruby. That is, it's not been added as a C extension and/or is not a Ruby method.

(2) A C++ program is producing YAML from a ragged array. As I go through each row of the ragged array in the C++ program, I could detect if all items are unique ... or I can do this in Ruby. I'd prefer to do this in Ruby if the cost is not "too high".

(3) Is there an easy way to find out how uniq is implemented in 1.8 and 1.9?
 
P

Phrogz

(1) How can I tell if a method like uniq is "native" to Ruby.  That is,it's not been added as a C extension and/or is not a Ruby method.

Look in the source code.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/

In this case, look for "rb_ary_uniq".
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/array.c?view=markup

(You can search for a phrase from the ri documentation to find the
method.)
(2) A C++ program is producing YAML from a ragged array.  As I go through each row of the ragged array in the C++ program, I could detect if all items are unique ... or I can do this in Ruby.  I'd prefer to do this in Ruby if the cost is not "too high".

If this is a question, I don't understand it.

(3) Is there an easy way to find out how uniq is implemented in 1.8 and 1..9?

Look in the source code.
You can find the different branches of Ruby here:
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,416
Latest member
LionelQ387

Latest Threads

Top