small medium large xlarge

Back to: All Forums  The dRuby Book
Generic-user-small
19 Jul 2012, 16:42
José A. S. Alegria (4 posts)

Hi! It seems that TupleSpace bin’s are Last In First Out (LIFO). Is there a reason why they are not instead First In First Out (FIFO)?

  def find(&blk)
    @bin.reverse_each do |x|
      return x if yield(x)
    end
    nil
  end

Regards,

José Alegria

Generic-user-small
20 Jul 2012, 06:05
Makoto Inoue (9 posts)

Hi, José.

I asked Seki san.

Apparently it’s result of the performance tuning. When you are dealing with lots of tuples (eg: 100,000), then deleting from the bottom of Array makes operation faster.

If you want to guarantee the order, then you can either pass the index number (as explained in page 130), or could use Drip.

Thanks.

Makoto

  You must be logged in to comment