【文件属性】:
文件名称:money-collection:优化 Money 对象集合操作
文件大小:9KB
文件格式:ZIP
更新时间:2021-07-13 18:39:05
Ruby
金钱::收藏
准确高效地计算一堆 Money 对象的总和/最小值/最大值。
这是通过最小化货币转换和对象创建的数量来实现的。
对于大型集合,sum/min/max 的执行速度最多可提高 4 倍。 对于小型集合 (n<10),它的执行速度至少可以提高 2 倍。
安装
将此行添加到应用程序的 Gemfile 中:
gem 'money-collection'
然后执行:
$ bundle
或者自己安装:
$ gem install money-collection
用法
这是 Money::Collection 库的演示:
require 'money'
require 'money/collection'
c = Money :: Collection . new ( [ money1 , money2 ] )
c << money3
c . concat [ mone
【文件预览】:
money-collection-master
----LICENSE.txt(1KB)
----lib()
--------money()
----Gemfile(101B)
----spec()
--------helper.rb(431B)
--------money()
----Rakefile(190B)
----benchmark()
--------max.rb(1KB)
--------helper.rb(378B)
--------sum.rb(1KB)
----README.md(1KB)
----money-collection.gemspec(949B)
----.gitignore(118B)