Performance of Arrays and Hashes in Ruby

后端 未结 4 1420
旧巷少年郎
旧巷少年郎 2020-11-29 18:39

I have a program that will store many instances of one class, let\'s say up to 10.000 or more. The class instances have several properties that I need from time to time, but

4条回答
  •  执笔经年
    2020-11-29 19:30

    Ruby has a set class in its standard library, have you considering keeping an (additional) set of IDs only?

    http://stdlib.rubyonrails.org/libdoc/set/rdoc/index.html

    To quote the docs: "This is a hybrid of Array’s intuitive inter-operation facilities and Hash’s fast lookup".

提交回复
热议问题