2

I am coming form a java world and usually think about a collection interface (set, list, map) that is required and depending on different use case select which concrete implementation to use, something like this reference of Java Question

I am wondering if there is a good summary of analogous ruby data strucutres corresponding to those in java that is available ?

If not can someone provide the favourite implementations people use for:

  1. listed here in the table in middle of page http://docs.oracle.com/javase/1.5.0/docs/guide/collections/overview.html
    1. some other ones like say queues: blocking, delayed, linked-blocking queue, circular etc trie trees etc

Better if most are from ruby standard library, otherwise popular gems are fine as well.

My intention is to have a place to refer when selecting good data structure implementations in ruby world

Thanks!

2
  • 1
    Why don't you just browse the classes offered in the Ruby core & standard library? There's not too many that it'd take a long time to go through. Reading docs may be dry, but it certainly is useful. Commented Nov 18, 2012 at 19:12
  • Thanks I will take a look. I was looking for a parallel table with 2 columns java DS, Corresponding Ruby DS . Especially useful when I am looking for a linkedHashMap vs concurrentHashMap, vs sortedMap etc and I dont have to go through a lot of searching and browsing for each of them. It just sounded like a common use case for many so thought may be something like that is already there on the web. Commented Nov 18, 2012 at 20:56

1 Answer 1

1

ruby has sets with along with their sorted counterpart. The array class handles your list equivalencies from Java, and there is a hash class to function like maps. Anything else? Leave a comment.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks hd1. Is there a tree based implementation of hash (ordered traversal ?)
Thanks hd1. Is there a tree based implementation of hash (ordered traversal ?) .LinkedHashSet like implementation . The queue implementations I mentioned in the question . Also there are bunch of other ones that guarantee thread safety like ConcurrentHashMap. There are lot more mentioned here docs.oracle.com/javase/1.5.0/docs/guide/collections/….
The built-in hash is thread-safe, unless you're talking about jruby

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.