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!

Community
  • 1
  • 1
codeObserver
  • 6,521
  • 16
  • 76
  • 121
  • 1
    Why don't you just browse the classes offered in the [Ruby core](http://ruby-doc.org/core-1.9.3/) & [standard library](http://ruby-doc.org/stdlib-1.9.3/)? 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. – Andrew Marshall Nov 18 '12 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. – codeObserver Nov 18 '12 at 20:56

1 Answers1

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.

hd1
  • 33,938
  • 5
  • 80
  • 91
  • Thanks hd1. Is there a tree based implementation of hash (ordered traversal ?) – codeObserver Nov 18 '12 at 20:42
  • 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 http://docs.oracle.com/javase/1.5.0/docs/guide/collections/reference.html. – codeObserver Nov 18 '12 at 20:53
  • The built-in hash is thread-safe, unless you're talking about jruby – hd1 Nov 18 '12 at 22:11